add primary color highlight to sidebar nav

This commit is contained in:
jeffvli
2025-11-22 04:23:35 -08:00
parent 6978516f79
commit 9801337c61
2 changed files with 10 additions and 1 deletions
@@ -41,6 +41,10 @@
}
}
.link.active {
color: var(--theme-colors-primary-filled);
}
.link.disabled {
pointer-events: none;
opacity: 0.6;
@@ -1,6 +1,6 @@
import clsx from 'clsx';
import { memo } from 'react';
import { Link, LinkProps } from 'react-router';
import { Link, LinkProps, useLocation } from 'react-router';
import styles from './sidebar-item.module.css';
@@ -11,6 +11,10 @@ interface SidebarItemProps extends ButtonProps {
}
export const SidebarItem = ({ children, className, to, ...props }: SidebarItemProps) => {
const location = useLocation();
const toPath = typeof to === 'string' ? to : to.pathname || '';
const isActive = location.pathname === toPath;
return (
<Button
className={clsx(
@@ -18,6 +22,7 @@ export const SidebarItem = ({ children, className, to, ...props }: SidebarItemPr
[styles.disabled]: props.disabled,
[styles.link]: true,
[styles.root]: true,
[styles.active]: isActive,
},
className,
)}