瀏覽代碼

Implement tooltip to sidebar

Aykut Saraç 3 年之前
父節點
當前提交
79bf1eb878
共有 1 個文件被更改,包括 83 次插入68 次删除
  1. 83 68
      src/components/Sidebar/index.tsx

+ 83 - 68
src/components/Sidebar/index.tsx

@@ -29,6 +29,7 @@ import { StorageConfig } from "src/typings/global";
 import { CanvasDirection } from "reaflow";
 import { CanvasDirection } from "reaflow";
 import { defaultConfig } from "src/constants/data";
 import { defaultConfig } from "src/constants/data";
 import toast from "react-hot-toast";
 import toast from "react-hot-toast";
+import { Tooltip } from "../Tooltip";
 
 
 const StyledSidebar = styled.div`
 const StyledSidebar = styled.div`
   display: flex;
   display: flex;
@@ -154,75 +155,89 @@ const Sidebar: React.FC<{
           </StyledElement>
           </StyledElement>
         </Link>
         </Link>
         <Link passHref href="/">
         <Link passHref href="/">
-          <StyledElement as="a" title="Home">
-            <AiFillHome />
-          </StyledElement>
+          <Tooltip title="Home">
+            <StyledElement as="a">
+              <AiFillHome />
+            </StyledElement>
+          </Tooltip>
         </Link>
         </Link>
-        <StyledElement
-          as="a"
-          title="Auto Format"
-          onClick={() => {
-            toggle("autoformat");
-            toast(`Auto format has been ${config.autoformat ? "disabled." : "enabled."}`);
-          }}
-        >
-          {config.autoformat ? <MdAutoFixHigh /> : <MdOutlineAutoFixOff />}
-        </StyledElement>
-        <StyledElement
-          as="a"
-          onClick={() => {
-            setJson("[]");
-            localStorage.removeItem("json");
-            toast.success(`Cleared JSON and removed from memory.`);
-          }}
-          title="Clear JSON"
-        >
-          <AiOutlineClear />
-        </StyledElement>
-        <StyledElement
-          as="a"
-          onClick={() =>
-            setConfig((c) => ({
-              ...c,
-              layout: getNextLayout(c.layout),
-            }))
-          }
-          title="Change Layout"
-        >
-          {getLayoutIcon(config.layout)}
-        </StyledElement>
-        <StyledElement
-          title="Toggle Controls"
-          as="a"
-          onClick={() => {
-            toggle("controls");
-            toast(`Controls ${config.controls ? "disabled." : "enabled."}`);
-          }}
-        >
-          {config.controls ? <AiFillControl /> : <AiOutlineControl />}
-        </StyledElement>
-
-        <StyledElement
-          as="a"
-          title="Toggle Expand/Collapse"
-          onClick={() => {
-            toggle("expand");
-            toast(`${config.expand ? "Collapsed" : "Expanded"} nodes.`);
-          }}
-        >
-          {config.expand ? <MdUnfoldMore /> : <MdUnfoldLess />}
-        </StyledElement>
-        <StyledElement as="a" title="Import JSON File">
-          <StyledImportFile>
-            <input
-              key={jsonFile?.name}
-              onChange={handleFileChange}
-              type="file"
-              accept="application/JSON"
-            />
-            <FaFileImport />
-          </StyledImportFile>
-        </StyledElement>
+        <Tooltip title="Auto Format">
+          <StyledElement
+            as="a"
+            onClick={() => {
+              toggle("autoformat");
+              toast(
+                `Auto format has been ${
+                  config.autoformat ? "disabled." : "enabled."
+                }`
+              );
+            }}
+          >
+            {config.autoformat ? <MdAutoFixHigh /> : <MdOutlineAutoFixOff />}
+          </StyledElement>
+        </Tooltip>
+        <Tooltip title="Clear JSON">
+          <StyledElement
+            as="a"
+            onClick={() => {
+              setJson("[]");
+              localStorage.removeItem("json");
+              toast.success(`Cleared JSON and removed from memory.`);
+            }}
+          >
+            <AiOutlineClear />
+          </StyledElement>
+        </Tooltip>
+        <Tooltip title="Change Layout">
+          <StyledElement
+            as="a"
+            onClick={() =>
+              setConfig((c) => ({
+                ...c,
+                layout: getNextLayout(c.layout),
+              }))
+            }
+          >
+            {getLayoutIcon(config.layout)}
+          </StyledElement>
+        </Tooltip>
+        <Tooltip title="Toggle Control Buttons">
+          <StyledElement
+            title="Toggle Controls"
+            as="a"
+            onClick={() => {
+              toggle("controls");
+              toast(`Controls ${config.controls ? "disabled." : "enabled."}`);
+            }}
+          >
+            {config.controls ? <AiFillControl /> : <AiOutlineControl />}
+          </StyledElement>
+        </Tooltip>
+        <Tooltip title="Toggle Compact Nodes">
+          <StyledElement
+            as="a"
+            title="Toggle Expand/Collapse"
+            onClick={() => {
+              toggle("expand");
+              toast(`${config.expand ? "Collapsed" : "Expanded"} nodes.`);
+            }}
+          >
+            {config.expand ? <MdUnfoldMore /> : <MdUnfoldLess />}
+          </StyledElement>
+        </Tooltip>
+        <Tooltip title="Import File">
+          <StyledElement as="a">
+            <StyledImportFile>
+              <input
+                key={jsonFile?.name}
+                onChange={handleFileChange}
+                type="file"
+                accept="application/JSON"
+              />
+              <FaFileImport />
+            </StyledImportFile>
+          </StyledElement>
+        </Tooltip>
       </StyledTopWrapper>
       </StyledTopWrapper>
       <StyledBottomWrapper>
       <StyledBottomWrapper>
         <StyledElement>
         <StyledElement>