Skip to content

Commit 77a5d50

Browse files
committed
fix: sidebar news active
1 parent b4b8b12 commit 77a5d50

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/components/Sidebar.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
2-
32
import { NavLink, Link, useLocation, useNavigate } from 'react-router-dom'; // Import useNavigate
4-
53
import { motion } from 'framer-motion';
64

75
import {
@@ -31,9 +29,7 @@ import {
3129
} from '@phosphor-icons/react';
3230

3331
import Fez from './Fez';
34-
3532
import { version } from '../version';
36-
3733
import usePersistentState from '../hooks/usePersistentState';
3834
import { KEY_SIDEBAR_STATE } from '../utils/LocalStorageManager';
3935

@@ -66,18 +62,20 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
6662
const getLinkClass = ({ isActive }) =>
6763
`flex items-center space-x-3 px-3 py-1 rounded-md transition-colors ${
6864
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
7066
: 'text-gray-100 hover:text-white hover:bg-gray-800'
7167
}`;
7268

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+
7371
const isMainActive =
7472
location.pathname === '/' || location.pathname === '/about';
7573

7674
const isContentActive =
7775
location.pathname.startsWith('/blog') ||
7876
location.pathname.startsWith('/projects') ||
7977
location.pathname.startsWith('/logs') ||
80-
location.pathname.startsWith('/stories');
78+
location.pathname.startsWith('/news');
8179

8280
const isAppsActive = location.pathname.startsWith('/apps') || location.pathname.startsWith('/commands');
8381

@@ -133,7 +131,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
133131
/>
134132
</button>
135133
{sidebarState.isMainOpen && (
136-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
134+
<nav className={getGroupClass(isMainActive)}>
137135
<NavLink to="/" className={getLinkClass}>
138136
<HouseIcon size={24} />
139137
<span>Home</span>
@@ -165,7 +163,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
165163
/>
166164
</button>
167165
{sidebarState.isContentOpen && (
168-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
166+
<nav className={getGroupClass(isContentActive)}>
169167
<NavLink to="/blog" className={getLinkClass}>
170168
<BookOpenIcon size={24} />
171169
<span>Blog</span>
@@ -205,7 +203,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
205203
/>
206204
</button>
207205
{sidebarState.isAppsOpen && (
208-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
206+
<nav className={getGroupClass(isAppsActive)}>
209207
<NavLink to="/apps" className={getLinkClass}>
210208
<SquaresFourIcon size={24} />
211209
<span>All Apps</span>
@@ -234,7 +232,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
234232
/>
235233
</button>
236234
{sidebarState.isExtrasOpen && (
237-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
235+
<nav className={getGroupClass(false)}>
238236
<NavLink to="/stories" className={getLinkClass}>
239237
<SwordIcon className="text-yellow-500" size={24} />
240238
<span>
@@ -270,7 +268,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
270268
/>
271269
</button>
272270
{sidebarState.isGamesOpen && (
273-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
271+
<nav className={getGroupClass(false)}>
274272
<a
275273
href="https://www.nytimes.com/games/wordle/index.html"
276274
target="_blank"
@@ -309,7 +307,7 @@ const Sidebar = ({ isOpen, toggleSidebar, toggleModal, setIsPaletteOpen }) => {
309307
/>
310308
</button>
311309
{sidebarState.isExternalLinksOpen && (
312-
<nav className="space-y-2 border-l-2 border-gray-700 ml-3 pl-3">
310+
<nav className={getGroupClass(false)}>
313311
<a
314312
href="https://github.com/fezcode"
315313
target="_blank"

src/pages/apps/RoguelikeGamePage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,4 @@ function RoguelikeGamePage() {
314314
);
315315
}
316316

317-
export default RoguelikeGamePage;
317+
export default RoguelikeGamePage;

0 commit comments

Comments
 (0)