mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 09:16:22 +02:00
refactor: add isActive prop to SidebarButton and NavSection for improved active state management; update styles accordingly
This commit is contained in:
parent
020d806b1f
commit
44f59bfb61
3 changed files with 8 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ interface SidebarButtonProps {
|
|||
label: string;
|
||||
onClick?: () => void;
|
||||
isCollapsed?: boolean;
|
||||
isActive?: boolean;
|
||||
badge?: React.ReactNode;
|
||||
/** Overlay in the top-right corner of the collapsed icon (e.g. status badge) */
|
||||
collapsedOverlay?: React.ReactNode;
|
||||
|
|
@ -37,12 +38,15 @@ export function SidebarButton({
|
|||
label,
|
||||
onClick,
|
||||
isCollapsed = false,
|
||||
isActive = false,
|
||||
badge,
|
||||
collapsedOverlay,
|
||||
expandedIconNode,
|
||||
className,
|
||||
buttonProps,
|
||||
}: SidebarButtonProps) {
|
||||
const activeClassName = "bg-accent text-accent-foreground";
|
||||
|
||||
if (isCollapsed) {
|
||||
return (
|
||||
<Tooltip>
|
||||
|
|
@ -50,7 +54,7 @@ export function SidebarButton({
|
|||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={cn(collapsedClassName, className)}
|
||||
className={cn(collapsedClassName, isActive && activeClassName, className)}
|
||||
{...buttonProps}
|
||||
>
|
||||
<Icon className="h-4 w-4" />
|
||||
|
|
@ -70,7 +74,7 @@ export function SidebarButton({
|
|||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={cn(expandedClassName, className)}
|
||||
className={cn(expandedClassName, isActive && activeClassName, className)}
|
||||
{...buttonProps}
|
||||
>
|
||||
{expandedIconNode ?? <Icon className="h-4 w-4 shrink-0" />}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue