|
1 | 1 | import React from 'react'; |
2 | | - |
3 | 2 | import { NavLink, Link, useLocation, useNavigate } from 'react-router-dom'; // Import useNavigate |
4 | | - |
5 | 3 | import { motion } from 'framer-motion'; |
6 | 4 |
|
7 | 5 | import { |
@@ -31,9 +29,7 @@ import { |
31 | 29 | } from '@phosphor-icons/react'; |
32 | 30 |
|
33 | 31 | import Fez from './Fez'; |
34 | | - |
35 | 32 | import { version } from '../version'; |
36 | | - |
37 | 33 | import usePersistentState from '../hooks/usePersistentState'; |
38 | 34 | import { KEY_SIDEBAR_STATE } from '../utils/LocalStorageManager'; |
39 | 35 |
|
@@ -66,18 +62,20 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
66 | 62 | const getLinkClass = ({ isActive }) => |
67 | 63 | `flex items-center space-x-3 px-3 py-1 rounded-md transition-colors ${ |
68 | 64 | isActive |
69 | | - ? 'text-sidebar-highlight bg-sidebar-highlight-alpha-10' |
| 65 | + ? 'text-sidebar-highlight bg-sidebar-highlight-alpha-10' // border-l-4 border-red-500 |
70 | 66 | : 'text-gray-100 hover:text-white hover:bg-gray-800' |
71 | 67 | }`; |
72 | 68 |
|
| 69 | + const getGroupClass = ( isActive ) => { return `space-y-2 border-l-2 ml-3 pl-3 ${ isActive ? 'border-sidebar-highlight-alpha-50' : 'border-gray-700' }` }; |
| 70 | + |
73 | 71 | const isMainActive = |
74 | 72 | location.pathname === '/' || location.pathname === '/about'; |
75 | 73 |
|
76 | 74 | const isContentActive = |
77 | 75 | location.pathname.startsWith('/blog') || |
78 | 76 | location.pathname.startsWith('/projects') || |
79 | 77 | location.pathname.startsWith('/logs') || |
80 | | - location.pathname.startsWith('/stories'); |
| 78 | + location.pathname.startsWith('/news'); |
81 | 79 |
|
82 | 80 | const isAppsActive = location.pathname.startsWith('/apps') || location.pathname.startsWith('/commands'); |
83 | 81 |
|
@@ -133,7 +131,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
133 | 131 | /> |
134 | 132 | </button> |
135 | 133 | {sidebarState.isMainOpen && ( |
136 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 134 | + <nav className={getGroupClass(isMainActive)}> |
137 | 135 | <NavLink to="/" className={getLinkClass}> |
138 | 136 | <HouseIcon size={24} /> |
139 | 137 | <span>Home</span> |
@@ -165,7 +163,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
165 | 163 | /> |
166 | 164 | </button> |
167 | 165 | {sidebarState.isContentOpen && ( |
168 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 166 | + <nav className={getGroupClass(isContentActive)}> |
169 | 167 | <NavLink to="/blog" className={getLinkClass}> |
170 | 168 | <BookOpenIcon size={24} /> |
171 | 169 | <span>Blog</span> |
@@ -205,7 +203,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
205 | 203 | /> |
206 | 204 | </button> |
207 | 205 | {sidebarState.isAppsOpen && ( |
208 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 206 | + <nav className={getGroupClass(isAppsActive)}> |
209 | 207 | <NavLink to="/apps" className={getLinkClass}> |
210 | 208 | <SquaresFourIcon size={24} /> |
211 | 209 | <span>All Apps</span> |
@@ -234,7 +232,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
234 | 232 | /> |
235 | 233 | </button> |
236 | 234 | {sidebarState.isExtrasOpen && ( |
237 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 235 | + <nav className={getGroupClass(false)}> |
238 | 236 | <NavLink to="/stories" className={getLinkClass}> |
239 | 237 | <SwordIcon className="text-yellow-500" size={24} /> |
240 | 238 | <span> |
@@ -270,7 +268,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
270 | 268 | /> |
271 | 269 | </button> |
272 | 270 | {sidebarState.isGamesOpen && ( |
273 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 271 | + <nav className={getGroupClass(false)}> |
274 | 272 | <a |
275 | 273 | href="https://www.nytimes.com/games/wordle/index.html" |
276 | 274 | target="_blank" |
@@ -309,7 +307,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => { |
309 | 307 | /> |
310 | 308 | </button> |
311 | 309 | {sidebarState.isExternalLinksOpen && ( |
312 | | - <nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3"> |
| 310 | + <nav className={getGroupClass(false)}> |
313 | 311 | <a |
314 | 312 | href="https://github.com/fezcode" |
315 | 313 | target="_blank" |
|
0 commit comments