|
1 | 1 | import "./sidebar.css";
|
2 |
| -import Link from 'next/link'; |
3 |
| -import { BridgeIcon, TethIcon, ScanIcon, GasStationIcon, EcosystemIcon } from "@/app/components/icons" |
| 2 | +import Link from "next/link"; |
| 3 | +import { |
| 4 | + BridgeIcon, |
| 5 | + TethIcon, |
| 6 | + ScanIcon, |
| 7 | + GasStationIcon, |
| 8 | + EcosystemIcon, |
| 9 | + TusdIcon, |
| 10 | +} from "@/app/components/icons"; |
4 | 11 | import { NetworkSwitcher } from "../Deposit/NetworkSwitcher";
|
5 | 12 | import { useState, type ReactNode } from "react";
|
6 | 13 | import { toKebabCase } from "@/lib/stringUtils";
|
7 |
| -import { usePathname } from 'next/navigation' |
8 |
| -import { composeEclipsescanUrl, useNetwork } from "@/app/contexts/NetworkContext"; |
9 |
| - |
| 14 | +import { usePathname } from "next/navigation"; |
| 15 | +import { |
| 16 | + composeEclipsescanUrl, |
| 17 | + useNetwork, |
| 18 | +} from "@/app/contexts/NetworkContext"; |
10 | 19 |
|
11 | 20 | const ToggleIcon: React.FC<{ isExtended: boolean }> = ({ isExtended }) => {
|
12 | 21 | return (
|
13 |
| - <svg width="20" |
14 |
| - height="20" |
15 |
| - viewBox="0 0 20 20" |
16 |
| - fill="none" |
17 |
| - xmlns="http://www.w3.org/2000/svg" |
18 |
| - style={ !isExtended ? { transform: "rotate(180deg)", transition: "transform 0.1s" } : { transition: "transform 0.1s" }}> |
19 |
| - <path d="M8.33509 13.3333L5.88564 10.8839C5.39749 10.3957 5.39749 9.60421 5.88564 9.11604L8.33509 6.66663M14.1685 13.3333L11.719 10.8839C11.2308 10.3957 11.2308 9.60421 11.719 9.11604L14.1685 6.66663" stroke="white" stroke-opacity="0.3" stroke-width="1.7971" stroke-linecap="round" stroke-linejoin="round"/> |
| 22 | + <svg |
| 23 | + width="20" |
| 24 | + height="20" |
| 25 | + viewBox="0 0 20 20" |
| 26 | + fill="none" |
| 27 | + xmlns="http://www.w3.org/2000/svg" |
| 28 | + style={ |
| 29 | + !isExtended |
| 30 | + ? { transform: "rotate(180deg)", transition: "transform 0.1s" } |
| 31 | + : { transition: "transform 0.1s" } |
| 32 | + } |
| 33 | + > |
| 34 | + <path |
| 35 | + d="M8.33509 13.3333L5.88564 10.8839C5.39749 10.3957 5.39749 9.60421 5.88564 9.11604L8.33509 6.66663M14.1685 13.3333L11.719 10.8839C11.2308 10.3957 11.2308 9.60421 11.719 9.11604L14.1685 6.66663" |
| 36 | + stroke="white" |
| 37 | + stroke-opacity="0.3" |
| 38 | + stroke-width="1.7971" |
| 39 | + stroke-linecap="round" |
| 40 | + stroke-linejoin="round" |
| 41 | + /> |
20 | 42 | </svg>
|
21 | 43 | );
|
22 |
| -} |
| 44 | +}; |
23 | 45 |
|
24 |
| -const SidebarItem: React.FC<{name: string, icon: ReactNode, isExtended: boolean}> = ({ name, icon, isExtended }) => { |
25 |
| - const { selectedOption } = useNetwork() |
| 46 | +const SidebarItem: React.FC<{ |
| 47 | + name: string; |
| 48 | + icon: ReactNode; |
| 49 | + isExtended: boolean; |
| 50 | +}> = ({ name, icon, isExtended }) => { |
| 51 | + const { selectedOption } = useNetwork(); |
26 | 52 | const [hover, setHover] = useState(false);
|
27 | 53 | const pathName = usePathname();
|
28 |
| - let targetHref = toKebabCase(name) |
29 |
| - if (targetHref === "eclipsescan") { targetHref = composeEclipsescanUrl(selectedOption) } |
30 |
| - if (targetHref === "ecosystem") { targetHref = "https://www.eclipse.xyz/ecosystem" } |
| 54 | + let targetHref = toKebabCase(name); |
| 55 | + if (targetHref === "eclipsescan") { |
| 56 | + targetHref = composeEclipsescanUrl(selectedOption); |
| 57 | + } |
| 58 | + if (targetHref === "ecosystem") { |
| 59 | + targetHref = "https://www.eclipse.xyz/ecosystem"; |
| 60 | + } |
31 | 61 |
|
32 | 62 | return (
|
33 |
| - <Link href={targetHref} target={targetHref.includes("https") ? "_blank" : ""}> |
34 |
| - <div className={ `side-item flex flex-row items-center ${ pathName.slice(1) === toKebabCase(name) ? "highlight-icon" : "" }`} |
35 |
| - style={{ gap: "11px", padding: isExtended ? "4px" : "0px", background: !isExtended ? "none" : ""}} |
36 |
| - onMouseEnter={() => setHover(true)} |
37 |
| - onMouseLeave={() => setHover(false)} |
38 |
| - > |
39 |
| - <div className={ `flex items-center justify-center side-icon-box` } style={{width: "38px", height: "38px"}}> |
40 |
| - {icon} |
| 63 | + <Link |
| 64 | + href={targetHref} |
| 65 | + target={targetHref.includes("https") ? "_blank" : ""} |
| 66 | + > |
| 67 | + <div |
| 68 | + className={`side-item flex flex-row items-center ${pathName.slice(1) === toKebabCase(name) ? "highlight-icon" : ""}`} |
| 69 | + style={{ |
| 70 | + gap: "11px", |
| 71 | + padding: isExtended ? "4px" : "0px", |
| 72 | + background: !isExtended ? "none" : "", |
| 73 | + }} |
| 74 | + onMouseEnter={() => setHover(true)} |
| 75 | + onMouseLeave={() => setHover(false)} |
| 76 | + > |
| 77 | + <div |
| 78 | + className={`flex items-center justify-center side-icon-box`} |
| 79 | + style={{ width: "38px", height: "38px" }} |
| 80 | + > |
| 81 | + {icon} |
| 82 | + </div> |
| 83 | + {isExtended && ( |
| 84 | + <span style={{ fontWeight: "500", fontSize: "16px" }}>{name}</span> |
| 85 | + )} |
| 86 | + |
| 87 | + {hover && !isExtended && ( |
| 88 | + <> |
| 89 | + <svg |
| 90 | + width="5" |
| 91 | + height="8" |
| 92 | + viewBox="0 0 5 8" |
| 93 | + fill="none" |
| 94 | + xmlns="http://www.w3.org/2000/svg" |
| 95 | + style={{ marginLeft: "-7px" }} |
| 96 | + > |
| 97 | + <path |
| 98 | + style={{ stroke: "none" }} |
| 99 | + d="M5 7.5V0.5L1.17033 3.18077C0.601614 3.57887 0.601616 4.42113 1.17033 4.81923L5 7.5Z" |
| 100 | + fill="white" |
| 101 | + fill-opacity="0.08" |
| 102 | + /> |
| 103 | + </svg> |
| 104 | + <div className="sidebar-hover flex items-center justify-center"> |
| 105 | + <span>{name}</span> |
| 106 | + </div> |
| 107 | + </> |
| 108 | + )} |
41 | 109 | </div>
|
42 |
| - { isExtended && <span style={{fontWeight: "500", fontSize: "16px"}}>{name}</span> } |
43 |
| - |
44 |
| - { hover && !isExtended && ( |
45 |
| - <> |
46 |
| - <svg width="5" height="8" viewBox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: "-7px"}}> |
47 |
| - <path style={{ stroke: "none" }} d="M5 7.5V0.5L1.17033 3.18077C0.601614 3.57887 0.601616 4.42113 1.17033 4.81923L5 7.5Z" fill="white" fill-opacity="0.08"/> |
48 |
| - </svg> |
49 |
| - <div className="sidebar-hover flex items-center justify-center"> |
50 |
| - <span>{ name }</span> |
51 |
| - </div> |
52 |
| - </> |
53 |
| - )} |
54 |
| - </div> |
55 | 110 | </Link>
|
56 | 111 | );
|
57 |
| -} |
| 112 | +}; |
58 | 113 |
|
59 |
| -export const Sidebar: React.FC<{ isExtended: boolean, setIsExtended: React.Dispatch<React.SetStateAction<boolean>>}> = ({ isExtended, setIsExtended }) => { |
| 114 | +export const Sidebar: React.FC<{ |
| 115 | + isExtended: boolean; |
| 116 | + setIsExtended: React.Dispatch<React.SetStateAction<boolean>>; |
| 117 | +}> = ({ isExtended, setIsExtended }) => { |
60 | 118 | return (
|
61 |
| - <div className="sidebar flex flex-col justify-between sm:flex hidden sm:block" style={{ width: isExtended ? "215px" : "66px"}}> |
| 119 | + <div |
| 120 | + className="sidebar flex flex-col justify-between sm:flex hidden sm:block" |
| 121 | + style={{ width: isExtended ? "215px" : "66px" }} |
| 122 | + > |
62 | 123 | <div>
|
63 | 124 | <NetworkSwitcher isExtended={isExtended} />
|
64 |
| - <div className="sidebar-tabs flex flex-col" style={{ marginTop: "14px", marginLeft: "14px" }}> |
65 |
| - <SidebarItem isExtended={isExtended} name="Bridge" icon={<BridgeIcon />} /> |
66 |
| - <SidebarItem isExtended={isExtended} name="Gas Station" icon={<GasStationIcon />} /> |
67 |
| - <SidebarItem isExtended={isExtended} name="Mint tETH" icon={<TethIcon />} /> |
68 |
| - <SidebarItem isExtended={isExtended} name="Eclipsescan" icon={<ScanIcon />} /> |
69 |
| - <SidebarItem isExtended={isExtended} name="Ecosystem" icon={<EcosystemIcon />} /> |
| 125 | + <div |
| 126 | + className="sidebar-tabs flex flex-col" |
| 127 | + style={{ marginTop: "14px", marginLeft: "14px" }} |
| 128 | + > |
| 129 | + <SidebarItem |
| 130 | + isExtended={isExtended} |
| 131 | + name="Bridge" |
| 132 | + icon={<BridgeIcon />} |
| 133 | + /> |
| 134 | + <SidebarItem |
| 135 | + isExtended={isExtended} |
| 136 | + name="Gas Station" |
| 137 | + icon={<GasStationIcon />} |
| 138 | + /> |
| 139 | + <SidebarItem |
| 140 | + isExtended={isExtended} |
| 141 | + name="Mint tETH" |
| 142 | + icon={<TethIcon />} |
| 143 | + /> |
| 144 | + <SidebarItem |
| 145 | + isExtended={isExtended} |
| 146 | + name="Mint tUSD" |
| 147 | + icon={<TusdIcon />} |
| 148 | + /> |
| 149 | + <SidebarItem |
| 150 | + isExtended={isExtended} |
| 151 | + name="Eclipsescan" |
| 152 | + icon={<ScanIcon />} |
| 153 | + /> |
| 154 | + <SidebarItem |
| 155 | + isExtended={isExtended} |
| 156 | + name="Ecosystem" |
| 157 | + icon={<EcosystemIcon />} |
| 158 | + /> |
70 | 159 | </div>
|
71 | 160 | </div>
|
72 |
| - <div className="flex w-[31px] mb-[20px] h-[31px] rounded-full cursor-pointer |
| 161 | + <div |
| 162 | + className="flex w-[31px] mb-[20px] h-[31px] rounded-full cursor-pointer |
73 | 163 | border-[#ffffff1a] bg-black border-[1.35px] items-center
|
74 | 164 | justify-center ml-[calc(100%-15.5px)] transition-all
|
75 | 165 | close-sidebar-icon
|
76 | 166 | "
|
77 |
| - onClick={() => {setIsExtended((current) => !current)}}> |
78 |
| - <ToggleIcon isExtended={ isExtended }/> |
| 167 | + onClick={() => { |
| 168 | + setIsExtended((current) => !current); |
| 169 | + }} |
| 170 | + > |
| 171 | + <ToggleIcon isExtended={isExtended} /> |
79 | 172 | </div>
|
80 | 173 | </div>
|
81 | 174 | );
|
82 | 175 | };
|
83 |
| - |
|
0 commit comments