viberss

RSS feed aggregator with a vibecoded reader app.
git clone https://unitehenry.com/git/viberss.git
Log | Files | Refs | README

sidebar.tsx (21223B)


      1 "use client"
      2 
      3 import * as React from "react"
      4 import { cva, type VariantProps } from "class-variance-authority"
      5 import { Slot } from "radix-ui"
      6 
      7 import { useIsMobile } from "@/hooks/use-mobile"
      8 import { cn } from "@/lib/utils"
      9 import { Button } from "@/components/ui/button"
     10 import { Input } from "@/components/ui/input"
     11 import { Separator } from "@/components/ui/separator"
     12 import {
     13   Sheet,
     14   SheetContent,
     15   SheetDescription,
     16   SheetHeader,
     17   SheetTitle,
     18 } from "@/components/ui/sheet"
     19 import { Skeleton } from "@/components/ui/skeleton"
     20 import {
     21   Tooltip,
     22   TooltipContent,
     23   TooltipTrigger,
     24 } from "@/components/ui/tooltip"
     25 import { PanelLeftIcon } from "lucide-react"
     26 
     27 const SIDEBAR_COOKIE_NAME = "sidebar_state"
     28 const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
     29 const SIDEBAR_WIDTH = "16rem"
     30 const SIDEBAR_WIDTH_MOBILE = "18rem"
     31 const SIDEBAR_WIDTH_ICON = "3rem"
     32 const SIDEBAR_KEYBOARD_SHORTCUT = "b"
     33 
     34 type SidebarContextProps = {
     35   state: "expanded" | "collapsed"
     36   open: boolean
     37   setOpen: (open: boolean) => void
     38   openMobile: boolean
     39   setOpenMobile: (open: boolean) => void
     40   isMobile: boolean
     41   toggleSidebar: () => void
     42 }
     43 
     44 const SidebarContext = React.createContext<SidebarContextProps | null>(null)
     45 
     46 function useSidebar() {
     47   const context = React.useContext(SidebarContext)
     48   if (!context) {
     49     throw new Error("useSidebar must be used within a SidebarProvider.")
     50   }
     51 
     52   return context
     53 }
     54 
     55 function SidebarProvider({
     56   defaultOpen = true,
     57   open: openProp,
     58   onOpenChange: setOpenProp,
     59   className,
     60   style,
     61   children,
     62   ...props
     63 }: React.ComponentProps<"div"> & {
     64   defaultOpen?: boolean
     65   open?: boolean
     66   onOpenChange?: (open: boolean) => void
     67 }) {
     68   const isMobile = useIsMobile()
     69   const [openMobile, setOpenMobile] = React.useState(false)
     70 
     71   // This is the internal state of the sidebar.
     72   // We use openProp and setOpenProp for control from outside the component.
     73   const [_open, _setOpen] = React.useState(defaultOpen)
     74   const open = openProp ?? _open
     75   const setOpen = React.useCallback(
     76     (value: boolean | ((value: boolean) => boolean)) => {
     77       const openState = typeof value === "function" ? value(open) : value
     78       if (setOpenProp) {
     79         setOpenProp(openState)
     80       } else {
     81         _setOpen(openState)
     82       }
     83 
     84       // This sets the cookie to keep the sidebar state.
     85       document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
     86     },
     87     [setOpenProp, open]
     88   )
     89 
     90   // Helper to toggle the sidebar.
     91   const toggleSidebar = React.useCallback(() => {
     92     return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
     93   }, [isMobile, setOpen, setOpenMobile])
     94 
     95   // Adds a keyboard shortcut to toggle the sidebar.
     96   React.useEffect(() => {
     97     const handleKeyDown = (event: KeyboardEvent) => {
     98       if (
     99         event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
    100         (event.metaKey || event.ctrlKey)
    101       ) {
    102         event.preventDefault()
    103         toggleSidebar()
    104       }
    105     }
    106 
    107     window.addEventListener("keydown", handleKeyDown)
    108     return () => window.removeEventListener("keydown", handleKeyDown)
    109   }, [toggleSidebar])
    110 
    111   // We add a state so that we can do data-state="expanded" or "collapsed".
    112   // This makes it easier to style the sidebar with Tailwind classes.
    113   const state = open ? "expanded" : "collapsed"
    114 
    115   const contextValue = React.useMemo<SidebarContextProps>(
    116     () => ({
    117       state,
    118       open,
    119       setOpen,
    120       isMobile,
    121       openMobile,
    122       setOpenMobile,
    123       toggleSidebar,
    124     }),
    125     [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
    126   )
    127 
    128   return (
    129     <SidebarContext.Provider value={contextValue}>
    130       <div
    131         data-slot="sidebar-wrapper"
    132         style={
    133           {
    134             "--sidebar-width": SIDEBAR_WIDTH,
    135             "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
    136             ...style,
    137           } as React.CSSProperties
    138         }
    139         className={cn(
    140           "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
    141           className
    142         )}
    143         {...props}
    144       >
    145         {children}
    146       </div>
    147     </SidebarContext.Provider>
    148   )
    149 }
    150 
    151 function Sidebar({
    152   side = "left",
    153   variant = "sidebar",
    154   collapsible = "offcanvas",
    155   className,
    156   children,
    157   dir,
    158   ...props
    159 }: React.ComponentProps<"div"> & {
    160   side?: "left" | "right"
    161   variant?: "sidebar" | "floating" | "inset"
    162   collapsible?: "offcanvas" | "icon" | "none"
    163 }) {
    164   const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
    165 
    166   if (collapsible === "none") {
    167     return (
    168       <div
    169         data-slot="sidebar"
    170         className={cn(
    171           "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
    172           className
    173         )}
    174         {...props}
    175       >
    176         {children}
    177       </div>
    178     )
    179   }
    180 
    181   if (isMobile) {
    182     return (
    183       <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
    184         <SheetContent
    185           dir={dir}
    186           data-sidebar="sidebar"
    187           data-slot="sidebar"
    188           data-mobile="true"
    189           className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
    190           style={
    191             {
    192               "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
    193             } as React.CSSProperties
    194           }
    195           side={side}
    196         >
    197           <SheetHeader className="sr-only">
    198             <SheetTitle>Sidebar</SheetTitle>
    199             <SheetDescription>Displays the mobile sidebar.</SheetDescription>
    200           </SheetHeader>
    201           <div className="flex h-full w-full flex-col">{children}</div>
    202         </SheetContent>
    203       </Sheet>
    204     )
    205   }
    206 
    207   return (
    208     <div
    209       className="group peer hidden text-sidebar-foreground md:block"
    210       data-state={state}
    211       data-collapsible={state === "collapsed" ? collapsible : ""}
    212       data-variant={variant}
    213       data-side={side}
    214       data-slot="sidebar"
    215     >
    216       {/* This is what handles the sidebar gap on desktop */}
    217       <div
    218         data-slot="sidebar-gap"
    219         className={cn(
    220           "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
    221           "group-data-[collapsible=offcanvas]:w-0",
    222           "group-data-[side=right]:rotate-180",
    223           variant === "floating" || variant === "inset"
    224             ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
    225             : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
    226         )}
    227       />
    228       <div
    229         data-slot="sidebar-container"
    230         data-side={side}
    231         className={cn(
    232           "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
    233           // Adjust the padding for floating and inset variants.
    234           variant === "floating" || variant === "inset"
    235             ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
    236             : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
    237           className
    238         )}
    239         {...props}
    240       >
    241         <div
    242           data-sidebar="sidebar"
    243           data-slot="sidebar-inner"
    244           className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
    245         >
    246           {children}
    247         </div>
    248       </div>
    249     </div>
    250   )
    251 }
    252 
    253 function SidebarTrigger({
    254   className,
    255   onClick,
    256   ...props
    257 }: React.ComponentProps<typeof Button>) {
    258   const { toggleSidebar } = useSidebar()
    259 
    260   return (
    261     <Button
    262       data-sidebar="trigger"
    263       data-slot="sidebar-trigger"
    264       variant="ghost"
    265       size="icon-sm"
    266       className={cn(className)}
    267       onClick={(event) => {
    268         onClick?.(event)
    269         toggleSidebar()
    270       }}
    271       {...props}
    272     >
    273       <PanelLeftIcon />
    274       <span className="sr-only">Toggle Sidebar</span>
    275     </Button>
    276   )
    277 }
    278 
    279 function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
    280   const { toggleSidebar } = useSidebar()
    281 
    282   return (
    283     <button
    284       data-sidebar="rail"
    285       data-slot="sidebar-rail"
    286       aria-label="Toggle Sidebar"
    287       tabIndex={-1}
    288       onClick={toggleSidebar}
    289       title="Toggle Sidebar"
    290       className={cn(
    291         "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
    292         "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
    293         "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
    294         "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
    295         "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
    296         "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
    297         className
    298       )}
    299       {...props}
    300     />
    301   )
    302 }
    303 
    304 function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
    305   return (
    306     <main
    307       data-slot="sidebar-inset"
    308       className={cn(
    309         "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
    310         className
    311       )}
    312       {...props}
    313     />
    314   )
    315 }
    316 
    317 function SidebarInput({
    318   className,
    319   ...props
    320 }: React.ComponentProps<typeof Input>) {
    321   return (
    322     <Input
    323       data-slot="sidebar-input"
    324       data-sidebar="input"
    325       className={cn("h-8 w-full bg-background shadow-none", className)}
    326       {...props}
    327     />
    328   )
    329 }
    330 
    331 function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
    332   return (
    333     <div
    334       data-slot="sidebar-header"
    335       data-sidebar="header"
    336       className={cn("flex flex-col gap-2 p-2", className)}
    337       {...props}
    338     />
    339   )
    340 }
    341 
    342 function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
    343   return (
    344     <div
    345       data-slot="sidebar-footer"
    346       data-sidebar="footer"
    347       className={cn("flex flex-col gap-2 p-2", className)}
    348       {...props}
    349     />
    350   )
    351 }
    352 
    353 function SidebarSeparator({
    354   className,
    355   ...props
    356 }: React.ComponentProps<typeof Separator>) {
    357   return (
    358     <Separator
    359       data-slot="sidebar-separator"
    360       data-sidebar="separator"
    361       className={cn("mx-2 w-auto bg-sidebar-border", className)}
    362       {...props}
    363     />
    364   )
    365 }
    366 
    367 function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
    368   return (
    369     <div
    370       data-slot="sidebar-content"
    371       data-sidebar="content"
    372       className={cn(
    373         "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
    374         className
    375       )}
    376       {...props}
    377     />
    378   )
    379 }
    380 
    381 function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
    382   return (
    383     <div
    384       data-slot="sidebar-group"
    385       data-sidebar="group"
    386       className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
    387       {...props}
    388     />
    389   )
    390 }
    391 
    392 function SidebarGroupLabel({
    393   className,
    394   asChild = false,
    395   ...props
    396 }: React.ComponentProps<"div"> & { asChild?: boolean }) {
    397   const Comp = asChild ? Slot.Root : "div"
    398 
    399   return (
    400     <Comp
    401       data-slot="sidebar-group-label"
    402       data-sidebar="group-label"
    403       className={cn(
    404         "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
    405         className
    406       )}
    407       {...props}
    408     />
    409   )
    410 }
    411 
    412 function SidebarGroupAction({
    413   className,
    414   asChild = false,
    415   ...props
    416 }: React.ComponentProps<"button"> & { asChild?: boolean }) {
    417   const Comp = asChild ? Slot.Root : "button"
    418 
    419   return (
    420     <Comp
    421       data-slot="sidebar-group-action"
    422       data-sidebar="group-action"
    423       className={cn(
    424         "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
    425         className
    426       )}
    427       {...props}
    428     />
    429   )
    430 }
    431 
    432 function SidebarGroupContent({
    433   className,
    434   ...props
    435 }: React.ComponentProps<"div">) {
    436   return (
    437     <div
    438       data-slot="sidebar-group-content"
    439       data-sidebar="group-content"
    440       className={cn("w-full text-sm", className)}
    441       {...props}
    442     />
    443   )
    444 }
    445 
    446 function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
    447   return (
    448     <ul
    449       data-slot="sidebar-menu"
    450       data-sidebar="menu"
    451       className={cn("flex w-full min-w-0 flex-col gap-0", className)}
    452       {...props}
    453     />
    454   )
    455 }
    456 
    457 function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
    458   return (
    459     <li
    460       data-slot="sidebar-menu-item"
    461       data-sidebar="menu-item"
    462       className={cn("group/menu-item relative", className)}
    463       {...props}
    464     />
    465   )
    466 }
    467 
    468 const sidebarMenuButtonVariants = cva(
    469   "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
    470   {
    471     variants: {
    472       variant: {
    473         default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
    474         outline:
    475           "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
    476       },
    477       size: {
    478         default: "h-8 text-sm",
    479         sm: "h-7 text-xs",
    480         lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
    481       },
    482     },
    483     defaultVariants: {
    484       variant: "default",
    485       size: "default",
    486     },
    487   }
    488 )
    489 
    490 function SidebarMenuButton({
    491   asChild = false,
    492   isActive = false,
    493   variant = "default",
    494   size = "default",
    495   tooltip,
    496   className,
    497   ...props
    498 }: React.ComponentProps<"button"> & {
    499   asChild?: boolean
    500   isActive?: boolean
    501   tooltip?: string | React.ComponentProps<typeof TooltipContent>
    502 } & VariantProps<typeof sidebarMenuButtonVariants>) {
    503   const Comp = asChild ? Slot.Root : "button"
    504   const { isMobile, state } = useSidebar()
    505 
    506   const button = (
    507     <Comp
    508       data-slot="sidebar-menu-button"
    509       data-sidebar="menu-button"
    510       data-size={size}
    511       data-active={isActive}
    512       className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
    513       {...props}
    514     />
    515   )
    516 
    517   if (!tooltip) {
    518     return button
    519   }
    520 
    521   if (typeof tooltip === "string") {
    522     tooltip = {
    523       children: tooltip,
    524     }
    525   }
    526 
    527   return (
    528     <Tooltip>
    529       <TooltipTrigger asChild>{button}</TooltipTrigger>
    530       <TooltipContent
    531         side="right"
    532         align="center"
    533         hidden={state !== "collapsed" || isMobile}
    534         {...tooltip}
    535       />
    536     </Tooltip>
    537   )
    538 }
    539 
    540 function SidebarMenuAction({
    541   className,
    542   asChild = false,
    543   showOnHover = false,
    544   ...props
    545 }: React.ComponentProps<"button"> & {
    546   asChild?: boolean
    547   showOnHover?: boolean
    548 }) {
    549   const Comp = asChild ? Slot.Root : "button"
    550 
    551   return (
    552     <Comp
    553       data-slot="sidebar-menu-action"
    554       data-sidebar="menu-action"
    555       className={cn(
    556         "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
    557         showOnHover &&
    558           "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
    559         className
    560       )}
    561       {...props}
    562     />
    563   )
    564 }
    565 
    566 function SidebarMenuBadge({
    567   className,
    568   ...props
    569 }: React.ComponentProps<"div">) {
    570   return (
    571     <div
    572       data-slot="sidebar-menu-badge"
    573       data-sidebar="menu-badge"
    574       className={cn(
    575         "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
    576         className
    577       )}
    578       {...props}
    579     />
    580   )
    581 }
    582 
    583 function SidebarMenuSkeleton({
    584   className,
    585   showIcon = false,
    586   ...props
    587 }: React.ComponentProps<"div"> & {
    588   showIcon?: boolean
    589 }) {
    590   // Random width between 50 to 90%.
    591   const [width] = React.useState(() => {
    592     return `${Math.floor(Math.random() * 40) + 50}%`
    593   })
    594 
    595   return (
    596     <div
    597       data-slot="sidebar-menu-skeleton"
    598       data-sidebar="menu-skeleton"
    599       className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
    600       {...props}
    601     >
    602       {showIcon && (
    603         <Skeleton
    604           className="size-4 rounded-md"
    605           data-sidebar="menu-skeleton-icon"
    606         />
    607       )}
    608       <Skeleton
    609         className="h-4 max-w-(--skeleton-width) flex-1"
    610         data-sidebar="menu-skeleton-text"
    611         style={
    612           {
    613             "--skeleton-width": width,
    614           } as React.CSSProperties
    615         }
    616       />
    617     </div>
    618   )
    619 }
    620 
    621 function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
    622   return (
    623     <ul
    624       data-slot="sidebar-menu-sub"
    625       data-sidebar="menu-sub"
    626       className={cn(
    627         "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
    628         className
    629       )}
    630       {...props}
    631     />
    632   )
    633 }
    634 
    635 function SidebarMenuSubItem({
    636   className,
    637   ...props
    638 }: React.ComponentProps<"li">) {
    639   return (
    640     <li
    641       data-slot="sidebar-menu-sub-item"
    642       data-sidebar="menu-sub-item"
    643       className={cn("group/menu-sub-item relative", className)}
    644       {...props}
    645     />
    646   )
    647 }
    648 
    649 function SidebarMenuSubButton({
    650   asChild = false,
    651   size = "md",
    652   isActive = false,
    653   className,
    654   ...props
    655 }: React.ComponentProps<"a"> & {
    656   asChild?: boolean
    657   size?: "sm" | "md"
    658   isActive?: boolean
    659 }) {
    660   const Comp = asChild ? Slot.Root : "a"
    661 
    662   return (
    663     <Comp
    664       data-slot="sidebar-menu-sub-button"
    665       data-sidebar="menu-sub-button"
    666       data-size={size}
    667       data-active={isActive}
    668       className={cn(
    669         "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
    670         className
    671       )}
    672       {...props}
    673     />
    674   )
    675 }
    676 
    677 export {
    678   Sidebar,
    679   SidebarContent,
    680   SidebarFooter,
    681   SidebarGroup,
    682   SidebarGroupAction,
    683   SidebarGroupContent,
    684   SidebarGroupLabel,
    685   SidebarHeader,
    686   SidebarInput,
    687   SidebarInset,
    688   SidebarMenu,
    689   SidebarMenuAction,
    690   SidebarMenuBadge,
    691   SidebarMenuButton,
    692   SidebarMenuItem,
    693   SidebarMenuSkeleton,
    694   SidebarMenuSub,
    695   SidebarMenuSubButton,
    696   SidebarMenuSubItem,
    697   SidebarProvider,
    698   SidebarRail,
    699   SidebarSeparator,
    700   SidebarTrigger,
    701 }