diff options
| author | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2025-08-19 13:23:56 +0200 |
|---|---|---|
| committer | Wolfboy248 <georgejvindkarlsen@gmail.com> | 2025-08-19 13:23:56 +0200 |
| commit | 97be0afd140c7c9e1fd03ba5ab4e486d90907129 (patch) | |
| tree | ab9dcf8ebab077b5fc7ab149c6ce8c13c21caaab /frontend/src/components/Sidebar.tsx | |
| parent | organised pages, started work on theme (diff) | |
| download | lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.tar.gz lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.tar.bz2 lphub-97be0afd140c7c9e1fd03ba5ab4e486d90907129.zip | |
organised pages, started work on theme
Diffstat (limited to 'frontend/src/components/Sidebar.tsx')
| -rw-r--r-- | frontend/src/components/Sidebar.tsx | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 88a5297..0083a3e 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx | |||
| @@ -23,15 +23,15 @@ interface SidebarProps { | |||
| 23 | onUploadRun: () => void; | 23 | onUploadRun: () => void; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | function OpenSidebarIcon(){ | 26 | function OpenSidebarIcon() { |
| 27 | return ( | 27 | return ( |
| 28 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="lucide lucide-panel-right-close-icon lucide-panel-right-close"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/><path d="m8 9 3 3-3 3"/></svg> | 28 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="lucide lucide-panel-right-close-icon lucide-panel-right-close"><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" /><path d="m8 9 3 3-3 3" /></svg> |
| 29 | ) | 29 | ) |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | function ClosedSidebarIcon(){ | 32 | function ClosedSidebarIcon() { |
| 33 | return ( | 33 | return ( |
| 34 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="lucide lucide-panel-right-open-icon lucide-panel-right-open"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/><path d="m10 15-3-3 3-3"/></svg> ) | 34 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="lucide lucide-panel-right-open-icon lucide-panel-right-open"><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" /><path d="m10 15-3-3 3-3" /></svg>) |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | const Sidebar: React.FC<SidebarProps> = ({ | 37 | const Sidebar: React.FC<SidebarProps> = ({ |
| @@ -43,7 +43,7 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 43 | const [searchData, setSearchData] = React.useState<Search | undefined>( | 43 | const [searchData, setSearchData] = React.useState<Search | undefined>( |
| 44 | undefined | 44 | undefined |
| 45 | ); | 45 | ); |
| 46 | const [isSidebarLocked, setIsSidebarLocked] = React.useState<boolean>(false); | 46 | // const [isSidebarLocked, setIsSidebarLocked] = React.useState<boolean>(false); |
| 47 | const [isSidebarOpen, setSidebarOpen] = React.useState<boolean>(false); | 47 | const [isSidebarOpen, setSidebarOpen] = React.useState<boolean>(false); |
| 48 | const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1); | 48 | const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1); |
| 49 | 49 | ||
| @@ -100,17 +100,16 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 100 | const getButtonClasses = (buttonIndex: number) => { | 100 | const getButtonClasses = (buttonIndex: number) => { |
| 101 | const baseClasses = "flex items-center gap-3 w-full text-left bg-inherit cursor-pointer border-none rounded-lg py-3 px-3 transition-all duration-300 hover:bg-surface1"; | 101 | const baseClasses = "flex items-center gap-3 w-full text-left bg-inherit cursor-pointer border-none rounded-lg py-3 px-3 transition-all duration-300 hover:bg-surface1"; |
| 102 | const selectedClasses = selectedButtonIndex === buttonIndex ? "bg-primary text-background" : "bg-transparent text-foreground"; | 102 | const selectedClasses = selectedButtonIndex === buttonIndex ? "bg-primary text-background" : "bg-transparent text-foreground"; |
| 103 | 103 | ||
| 104 | return `${baseClasses} ${selectedClasses}`; | 104 | return `${baseClasses} ${selectedClasses}`; |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | const iconClasses = "w-6 h-6 flex-shrink-0"; | 107 | const iconClasses = "w-6 h-6 flex-shrink-0"; |
| 108 | 108 | ||
| 109 | return ( | 109 | return ( |
| 110 | <div className={`fixed top-0 left-0 h-screen bg-surface border-r border-border transition-all duration-300 z-10 overflow-hidden ${ | 110 | <div className={`w-80 not-md:w-full text-white bg-block |
| 111 | isSidebarOpen ? 'w-80' : 'w-20' | 111 | }`}> |
| 112 | }`}> | 112 | <div className="flex items-center px-4 border-b border-border"> |
| 113 | <div className="flex items-center h-20 px-4 border-b border-border"> | ||
| 114 | <Link to="/" tabIndex={-1} className="flex items-center flex-1 cursor-pointer select-none min-w-0"> | 113 | <Link to="/" tabIndex={-1} className="flex items-center flex-1 cursor-pointer select-none min-w-0"> |
| 115 | <img src={LogoIcon} alt="Logo" className="w-12 h-12 flex-shrink-0" /> | 114 | <img src={LogoIcon} alt="Logo" className="w-12 h-12 flex-shrink-0" /> |
| 116 | {isSidebarOpen && ( | 115 | {isSidebarOpen && ( |
| @@ -124,7 +123,7 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 124 | </div> | 123 | </div> |
| 125 | )} | 124 | )} |
| 126 | </Link> | 125 | </Link> |
| 127 | 126 | ||
| 128 | <button | 127 | <button |
| 129 | onClick={_handle_sidebar_toggle} | 128 | onClick={_handle_sidebar_toggle} |
| 130 | className="ml-2 p-2 rounded-lg hover:bg-surface1 transition-colors text-foreground" | 129 | className="ml-2 p-2 rounded-lg hover:bg-surface1 transition-colors text-foreground" |
| @@ -135,9 +134,9 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 135 | </div> | 134 | </div> |
| 136 | 135 | ||
| 137 | {/* Sidebar Content */} | 136 | {/* Sidebar Content */} |
| 138 | <div | 137 | <div |
| 139 | ref={sidebarRef} | 138 | ref={sidebarRef} |
| 140 | className="flex flex-col h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden" | 139 | className="flex flex-col overflow-y-auto overflow-x-hidden" |
| 141 | > | 140 | > |
| 142 | {isSidebarOpen && ( | 141 | {isSidebarOpen && ( |
| 143 | <div className="p-4 border-b border-border min-w-0"> | 142 | <div className="p-4 border-b border-border min-w-0"> |
| @@ -145,7 +144,7 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 145 | <img src={SearchIcon} alt="Search" className={iconClasses} /> | 144 | <img src={SearchIcon} alt="Search" className={iconClasses} /> |
| 146 | <span className="text-white font-[--font-barlow-semicondensed-regular] truncate">Search</span> | 145 | <span className="text-white font-[--font-barlow-semicondensed-regular] truncate">Search</span> |
| 147 | </div> | 146 | </div> |
| 148 | 147 | ||
| 149 | <div className="min-w-0"> | 148 | <div className="min-w-0"> |
| 150 | <input | 149 | <input |
| 151 | ref={searchbarRef} | 150 | ref={searchbarRef} |
| @@ -214,7 +213,9 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 214 | ].map(({ to, refIndex, icon, alt, label }) => ( | 213 | ].map(({ to, refIndex, icon, alt, label }) => ( |
| 215 | <Link to={to} tabIndex={-1} key={refIndex}> | 214 | <Link to={to} tabIndex={-1} key={refIndex}> |
| 216 | <button | 215 | <button |
| 217 | ref={el => sidebarButtonRefs.current[refIndex] = el} | 216 | ref={el => { |
| 217 | sidebarButtonRefs.current[refIndex] = el | ||
| 218 | }} | ||
| 218 | className={getButtonClasses(refIndex)} | 219 | className={getButtonClasses(refIndex)} |
| 219 | onClick={() => handle_sidebar_click(refIndex)} | 220 | onClick={() => handle_sidebar_click(refIndex)} |
| 220 | > | 221 | > |
| @@ -254,8 +255,10 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 254 | </div> | 255 | </div> |
| 255 | 256 | ||
| 256 | <Link to="/rules" tabIndex={-1}> | 257 | <Link to="/rules" tabIndex={-1}> |
| 257 | <button | 258 | <button |
| 258 | ref={el => sidebarButtonRefs.current[5] = el} | 259 | ref={el => { |
| 260 | sidebarButtonRefs.current[5] = el | ||
| 261 | }} | ||
| 259 | className={getButtonClasses(5)} | 262 | className={getButtonClasses(5)} |
| 260 | onClick={() => handle_sidebar_click(5)} | 263 | onClick={() => handle_sidebar_click(5)} |
| 261 | > | 264 | > |
| @@ -265,8 +268,10 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 265 | </Link> | 268 | </Link> |
| 266 | 269 | ||
| 267 | <Link to="/about" tabIndex={-1}> | 270 | <Link to="/about" tabIndex={-1}> |
| 268 | <button | 271 | <button |
| 269 | ref={el => sidebarButtonRefs.current[6] = el} | 272 | ref={el => { |
| 273 | sidebarButtonRefs.current[6] = el | ||
| 274 | }} | ||
| 270 | className={getButtonClasses(6)} | 275 | className={getButtonClasses(6)} |
| 271 | onClick={() => handle_sidebar_click(6)} | 276 | onClick={() => handle_sidebar_click(6)} |
| 272 | > | 277 | > |