viberss

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

sheet.tsx (4542B)


      1 import * as React from "react"
      2 import { Dialog as SheetPrimitive } from "radix-ui"
      3 
      4 import { cn } from "@/lib/utils"
      5 import { Button } from "@/components/ui/button"
      6 import { XIcon } from "lucide-react"
      7 
      8 function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
      9   return <SheetPrimitive.Root data-slot="sheet" {...props} />
     10 }
     11 
     12 function SheetTrigger({
     13   ...props
     14 }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
     15   return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
     16 }
     17 
     18 function SheetClose({
     19   ...props
     20 }: React.ComponentProps<typeof SheetPrimitive.Close>) {
     21   return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
     22 }
     23 
     24 function SheetPortal({
     25   ...props
     26 }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
     27   return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
     28 }
     29 
     30 function SheetOverlay({
     31   className,
     32   ...props
     33 }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
     34   return (
     35     <SheetPrimitive.Overlay
     36       data-slot="sheet-overlay"
     37       className={cn(
     38         "fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
     39         className
     40       )}
     41       {...props}
     42     />
     43   )
     44 }
     45 
     46 function SheetContent({
     47   className,
     48   children,
     49   side = "right",
     50   showCloseButton = true,
     51   ...props
     52 }: React.ComponentProps<typeof SheetPrimitive.Content> & {
     53   side?: "top" | "right" | "bottom" | "left"
     54   showCloseButton?: boolean
     55 }) {
     56   return (
     57     <SheetPortal>
     58       <SheetOverlay />
     59       <SheetPrimitive.Content
     60         data-slot="sheet-content"
     61         data-side={side}
     62         className={cn(
     63           "fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",
     64           className
     65         )}
     66         {...props}
     67       >
     68         {children}
     69         {showCloseButton && (
     70           <SheetPrimitive.Close data-slot="sheet-close" asChild>
     71             <Button
     72               variant="ghost"
     73               className="absolute top-3 right-3"
     74               size="icon-sm"
     75             >
     76               <XIcon />
     77               <span className="sr-only">Close</span>
     78             </Button>
     79           </SheetPrimitive.Close>
     80         )}
     81       </SheetPrimitive.Content>
     82     </SheetPortal>
     83   )
     84 }
     85 
     86 function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
     87   return (
     88     <div
     89       data-slot="sheet-header"
     90       className={cn("flex flex-col gap-0.5 p-4", className)}
     91       {...props}
     92     />
     93   )
     94 }
     95 
     96 function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
     97   return (
     98     <div
     99       data-slot="sheet-footer"
    100       className={cn("mt-auto flex flex-col gap-2 p-4", className)}
    101       {...props}
    102     />
    103   )
    104 }
    105 
    106 function SheetTitle({
    107   className,
    108   ...props
    109 }: React.ComponentProps<typeof SheetPrimitive.Title>) {
    110   return (
    111     <SheetPrimitive.Title
    112       data-slot="sheet-title"
    113       className={cn(
    114         "font-heading text-base font-medium text-foreground",
    115         className
    116       )}
    117       {...props}
    118     />
    119   )
    120 }
    121 
    122 function SheetDescription({
    123   className,
    124   ...props
    125 }: React.ComponentProps<typeof SheetPrimitive.Description>) {
    126   return (
    127     <SheetPrimitive.Description
    128       data-slot="sheet-description"
    129       className={cn("text-sm text-muted-foreground", className)}
    130       {...props}
    131     />
    132   )
    133 }
    134 
    135 export {
    136   Sheet,
    137   SheetTrigger,
    138   SheetClose,
    139   SheetContent,
    140   SheetHeader,
    141   SheetFooter,
    142   SheetTitle,
    143   SheetDescription,
    144 }