"use client"; import type { LucideIcon } from "lucide-react"; import type React from "react"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { cn } from "@/lib/utils"; interface SidebarButtonProps { icon: LucideIcon; label: string; onClick?: () => void; isCollapsed?: boolean; isActive?: boolean; badge?: React.ReactNode; collapsedOverlay?: React.ReactNode; collapsedIconNode?: React.ReactNode; expandedIconNode?: React.ReactNode; trailingContent?: React.ReactNode; tooltipContent?: React.ReactNode; className?: string; buttonProps?: React.ButtonHTMLAttributes; } const baseClassName = cn( "group/sidebar-button relative h-9 justify-start gap-0 rounded-md mx-2 px-2 text-sm text-left", "transition-colors hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" ); export function SidebarButton({ icon: Icon, label, onClick, isCollapsed = false, isActive = false, badge, collapsedOverlay, collapsedIconNode, expandedIconNode, trailingContent, tooltipContent, className, buttonProps, }: SidebarButtonProps) { const activeClassName = "bg-accent text-accent-foreground"; const iconNode = isCollapsed ? (collapsedIconNode ?? ) : (expandedIconNode ?? ); const button = ( ); const renderTooltip = isCollapsed || !!tooltipContent; if (!renderTooltip) { return button; } return ( {button} {isCollapsed ? (tooltipContent ?? ( <> {label} {typeof badge === "string" && ` (${badge})`} )) : tooltipContent} ); }