mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add primary color highlight to sidebar nav
This commit is contained in:
@@ -41,6 +41,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link.active {
|
||||||
|
color: var(--theme-colors-primary-filled);
|
||||||
|
}
|
||||||
|
|
||||||
.link.disabled {
|
.link.disabled {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { Link, LinkProps } from 'react-router';
|
import { Link, LinkProps, useLocation } from 'react-router';
|
||||||
|
|
||||||
import styles from './sidebar-item.module.css';
|
import styles from './sidebar-item.module.css';
|
||||||
|
|
||||||
@@ -11,6 +11,10 @@ interface SidebarItemProps extends ButtonProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SidebarItem = ({ children, className, to, ...props }: SidebarItemProps) => {
|
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 (
|
return (
|
||||||
<Button
|
<Button
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -18,6 +22,7 @@ export const SidebarItem = ({ children, className, to, ...props }: SidebarItemPr
|
|||||||
[styles.disabled]: props.disabled,
|
[styles.disabled]: props.disabled,
|
||||||
[styles.link]: true,
|
[styles.link]: true,
|
||||||
[styles.root]: true,
|
[styles.root]: true,
|
||||||
|
[styles.active]: isActive,
|
||||||
},
|
},
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user