diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Footer.tsx | 20 | ||||
| -rw-r--r-- | src/components/Gallery.tsx | 100 | ||||
| -rw-r--r-- | src/components/Map.tsx | 40 | ||||
| -rw-r--r-- | src/components/Navbar.tsx | 24 | ||||
| -rw-r--r-- | src/components/ThemeToggle.tsx | 29 | ||||
| -rw-r--r-- | src/components/ui/aspect-ratio.tsx | 11 | ||||
| -rw-r--r-- | src/components/ui/badge.tsx | 46 | ||||
| -rw-r--r-- | src/components/ui/button.tsx | 59 | ||||
| -rw-r--r-- | src/components/ui/card.tsx | 92 | ||||
| -rw-r--r-- | src/components/ui/navigation-menu.tsx | 168 | ||||
| -rw-r--r-- | src/components/ui/separator.tsx | 26 | ||||
| -rw-r--r-- | src/components/ui/sheet.tsx | 137 |
12 files changed, 0 insertions, 752 deletions
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx deleted file mode 100644 index 2b3be02..0000000 --- a/src/components/Footer.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Github, Mail } from "lucide-react"; - -export default function Footer() { - const year = new Date().getFullYear(); - return ( - <footer className="flex flex-col items-center gap-2 py-4"> - <div className="flex gap-6"> - <a href="https://github.com/schererleander" target="_blank" rel="noopener noreferrer" aria-label="Leander Scherer's GitHub"> - <Github className="w-4 h-4" strokeWidth={3} /> - </a> - - <a href="mailto:leander@schererleander.de" aria-label="Send email to Leander Scherer"> - <Mail className="w-4 h-4" strokeWidth={3} /> - </a> - </div> - - <span className="text-sm">© {year} Leander Scherer — ʕっ•ᴥ•ʔっ</span> - </footer> - ); -} diff --git a/src/components/Gallery.tsx b/src/components/Gallery.tsx deleted file mode 100644 index ffcf0e1..0000000 --- a/src/components/Gallery.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import React, { useState, useEffect } from 'react'; - -interface ImageItems { - images: Array<{ - src: string; - alt?: string; - id?: string | number; - }>; -} - -export default function Gallery({ images }: ImageItems) { - const [selectedIndex, setSelectedIndex] = useState<number | null>(null); - const closeModal = () => setSelectedIndex(null); - const prev = (e?: React.MouseEvent) => { - e?.stopPropagation(); - setSelectedIndex((i) => (i !== null && i > 0 ? i - 1 : i)); - }; - const next = (e?: React.MouseEvent) => { - e?.stopPropagation(); - setSelectedIndex((i) => (i !== null && i < images.length - 1 ? i + 1 : i)); - }; - - useEffect(() => { - function handleKeyDown(event: KeyboardEvent) { - if (selectedIndex === null) return; - if (event.key === 'ArrowLeft') { - prev(); - } else if (event.key === 'ArrowRight') { - next(); - } - } - - window.addEventListener('keydown', handleKeyDown); - return () => window.removeEventListener('keydown', handleKeyDown); - }, [selectedIndex, images.length]); - - return ( - <> - <div className="grid gap-2 grid-cols-4 max-sm:grid-cols-3 p-4"> - {images.map((image, idx) => ( - <button - key={image.id ?? image.src} - className="relative overflow-hidden rounded-xl shadow-lg aspect-square group cursor-pointer" - onClick={() => setSelectedIndex(idx)} - > - <img - src={image.src} - alt={image.alt || 'Gallery image'} - className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" - /> - </button> - ))} - </div> - - {/* Overlay */} - {selectedIndex !== null && ( - <div - className="fixed inset-0 bg-white/50 dark:bg-black/50 backdrop-blur-sm flex items-center justify-center z-50" - onClick={closeModal} - role="dialog" - aria-modal="true" - > - {/* Prev arrow */} - <button - onClick={prev} - className="absolute left-4 text-black dark:text-white text-4xl disabled:opacity-30" - disabled={selectedIndex === 0} - > - ← - </button> - - <img - src={images[selectedIndex].src} - alt={images[selectedIndex].alt || 'Enlarged gallery'} - className="w-2/3 h-2/3 object-contain rounded-lg" - /> - - {/* Next arrow */} - <button - onClick={next} - className="absolute right-4 text-black dark:text-white text-4xl disabled:opacity-30" - disabled={selectedIndex === images.length - 1} - aria-label='Next image' - > - → - </button> - <button - onClick={(e) => { - e.stopPropagation(); - closeModal(); - }} - className="absolute top-4 right-4 text-black dark:text-white text-3xl" - > - × - </button> - </div> - )} - </> - ); -} diff --git a/src/components/Map.tsx b/src/components/Map.tsx deleted file mode 100644 index 1e4038f..0000000 --- a/src/components/Map.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { useEffect } from "react"; -import { MapContainer, TileLayer, Marker, useMap } from "react-leaflet"; -import L from "leaflet"; -import "leaflet/dist/leaflet.css"; - -const KARLSRUHE: [number, number] = [49.0069, 8.4037]; - -const icon = L.divIcon({ - html: `<div style="width:12px;height:12px;background:var(--background);border-radius:50%;border:2px solid var(--foreground);box-shadow:0 0 10px rgba(0,0,0,0.5)"></div>`, - className: "", - iconSize: [12, 12], -}); - -function MapEffects() { - const map = useMap(); - useEffect(() => { - map.flyTo(KARLSRUHE, 14, { duration: 3 }); - }, [map]); - return null; -} - -export default function Map() { - const tileUrl = "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png"; - - return ( - <div - className="relative h-[450px] w-full overflow-hidden rounded-xl border border-border z-0" - style={{ - maskImage: "linear-gradient(to bottom, black 50%, transparent 100%)", - WebkitMaskImage: "linear-gradient(to bottom, black 50%, transparent 100%)", - }} - > - <MapContainer center={[49, 8.4]} zoom={10} scrollWheelZoom={false} className="h-full w-full" zoomControl={false} attributionControl={false}> - <TileLayer url={tileUrl} /> - <Marker position={KARLSRUHE} icon={icon} /> - <MapEffects /> - </MapContainer> - </div> - ); -} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx deleted file mode 100644 index 720274b..0000000 --- a/src/components/Navbar.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Button } from "./ui/button"; -import ThemeToggle from "./ThemeToggle"; - -const navItems = [ - { label: "Home", href: "/" }, - { label: "Blog", href: "/blog" }, -]; - -export default function Navbar() { - return ( - <nav className="sticky top-0 z-50 w-full backdrop-blur"> - <div className="max-w-2xl mx-auto flex items-center justify-between px-4 py-4"> - <div className="flex gap-4 justify-center flex-1"> - {navItems.map(({ label, href }) => ( - <Button key={label} variant="ghost" asChild> - <a href={href}>{label}</a> - </Button> - ))} - </div> - <ThemeToggle /> - </div> - </nav> - ); -} diff --git a/src/components/ThemeToggle.tsx b/src/components/ThemeToggle.tsx deleted file mode 100644 index fa269b1..0000000 --- a/src/components/ThemeToggle.tsx +++ /dev/null @@ -1,29 +0,0 @@ -// components/ThemeToggle.tsx -import { useTheme } from "../hooks/theme"; - -export default function ThemeToggle() { - const { theme, toggleTheme } = useTheme(); - return ( - <button type="button" aria-label="Toogle dark mode" onClick={toggleTheme}> - {theme === 'dark' ? ( - <svg - className="w-5 h-5" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - aria-hidden="true" - > - <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path></svg> - ) : ( - <svg - className="w-5 h-5" - fill="none" - viewBox="0 0 24 24" - stroke="currentColor" - aria-hidden="true" - > - <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path></svg> - )} - </button> - ); -}
\ No newline at end of file diff --git a/src/components/ui/aspect-ratio.tsx b/src/components/ui/aspect-ratio.tsx deleted file mode 100644 index 3df3fd0..0000000 --- a/src/components/ui/aspect-ratio.tsx +++ /dev/null @@ -1,11 +0,0 @@ -"use client" - -import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" - -function AspectRatio({ - ...props -}: React.ComponentProps<typeof AspectRatioPrimitive.Root>) { - return <AspectRatioPrimitive.Root data-slot="aspect-ratio" {...props} /> -} - -export { AspectRatio } diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx deleted file mode 100644 index ec8d7f7..0000000 --- a/src/components/ui/badge.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const badgeVariants = cva( - "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", - { - variants: { - variant: { - default: - "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", - secondary: - "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", - destructive: - "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", - outline: - "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", - }, - }, - defaultVariants: { - variant: "default", - }, - } -) - -function Badge({ - className, - variant, - asChild = false, - ...props -}: React.ComponentProps<"span"> & - VariantProps<typeof badgeVariants> & { asChild?: boolean }) { - const Comp = asChild ? Slot : "span" - - return ( - <Comp - data-slot="badge" - className={cn(badgeVariants({ variant }), className)} - {...props} - /> - ) -} -export { Badge, badgeVariants } - diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx deleted file mode 100644 index a2df8dc..0000000 --- a/src/components/ui/button.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const buttonVariants = cva( - "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", - { - variants: { - variant: { - default: - "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", - destructive: - "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", - outline: - "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50", - secondary: - "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", - ghost: - "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-9 px-4 py-2 has-[>svg]:px-3", - sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", - lg: "h-10 rounded-md px-6 has-[>svg]:px-4", - icon: "size-9", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - } -) - -function Button({ - className, - variant, - size, - asChild = false, - ...props -}: React.ComponentProps<"button"> & - VariantProps<typeof buttonVariants> & { - asChild?: boolean - }) { - const Comp = asChild ? Slot : "button" - - return ( - <Comp - data-slot="button" - className={cn(buttonVariants({ variant, size, className }))} - {...props} - /> - ) -} - -export { Button, buttonVariants } diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx deleted file mode 100644 index d05bbc6..0000000 --- a/src/components/ui/card.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Card({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card" - className={cn( - "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", - className - )} - {...props} - /> - ) -} - -function CardHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-header" - className={cn( - "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", - className - )} - {...props} - /> - ) -} - -function CardTitle({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-title" - className={cn("leading-none font-semibold", className)} - {...props} - /> - ) -} - -function CardDescription({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-description" - className={cn("text-muted-foreground text-sm", className)} - {...props} - /> - ) -} - -function CardAction({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-action" - className={cn( - "col-start-2 row-span-2 row-start-1 self-start justify-self-end", - className - )} - {...props} - /> - ) -} - -function CardContent({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-content" - className={cn("px-6", className)} - {...props} - /> - ) -} - -function CardFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="card-footer" - className={cn("flex items-center px-6 [.border-t]:pt-6", className)} - {...props} - /> - ) -} - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardAction, - CardDescription, - CardContent, -} diff --git a/src/components/ui/navigation-menu.tsx b/src/components/ui/navigation-menu.tsx deleted file mode 100644 index 1199945..0000000 --- a/src/components/ui/navigation-menu.tsx +++ /dev/null @@ -1,168 +0,0 @@ -import * as React from "react" -import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu" -import { cva } from "class-variance-authority" -import { ChevronDownIcon } from "lucide-react" - -import { cn } from "@/lib/utils" - -function NavigationMenu({ - className, - children, - viewport = true, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & { - viewport?: boolean -}) { - return ( - <NavigationMenuPrimitive.Root - data-slot="navigation-menu" - data-viewport={viewport} - className={cn( - "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center", - className - )} - {...props} - > - {children} - {viewport && <NavigationMenuViewport />} - </NavigationMenuPrimitive.Root> - ) -} - -function NavigationMenuList({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) { - return ( - <NavigationMenuPrimitive.List - data-slot="navigation-menu-list" - className={cn( - "group flex flex-1 list-none items-center justify-center gap-1", - className - )} - {...props} - /> - ) -} - -function NavigationMenuItem({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) { - return ( - <NavigationMenuPrimitive.Item - data-slot="navigation-menu-item" - className={cn("relative", className)} - {...props} - /> - ) -} - -const navigationMenuTriggerStyle = cva( - "group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1" -) - -function NavigationMenuTrigger({ - className, - children, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) { - return ( - <NavigationMenuPrimitive.Trigger - data-slot="navigation-menu-trigger" - className={cn(navigationMenuTriggerStyle(), "group", className)} - {...props} - > - {children}{" "} - <ChevronDownIcon - className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180" - aria-hidden="true" - /> - </NavigationMenuPrimitive.Trigger> - ) -} - -function NavigationMenuContent({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) { - return ( - <NavigationMenuPrimitive.Content - data-slot="navigation-menu-content" - className={cn( - "data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto", - "group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none", - className - )} - {...props} - /> - ) -} - -function NavigationMenuViewport({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) { - return ( - <div - className={cn( - "absolute top-full left-0 isolate z-50 flex justify-center" - )} - > - <NavigationMenuPrimitive.Viewport - data-slot="navigation-menu-viewport" - className={cn( - "origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]", - className - )} - {...props} - /> - </div> - ) -} - -function NavigationMenuLink({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) { - return ( - <NavigationMenuPrimitive.Link - data-slot="navigation-menu-link" - className={cn( - "data-[active=true]:focus:bg-accent data-[active=true]:hover:bg-accent data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-ring/50 [&_svg:not([class*='text-'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4", - className - )} - {...props} - /> - ) -} - -function NavigationMenuIndicator({ - className, - ...props -}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) { - return ( - <NavigationMenuPrimitive.Indicator - data-slot="navigation-menu-indicator" - className={cn( - "data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden", - className - )} - {...props} - > - <div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" /> - </NavigationMenuPrimitive.Indicator> - ) -} - -export { - NavigationMenu, - NavigationMenuList, - NavigationMenuItem, - NavigationMenuContent, - NavigationMenuTrigger, - NavigationMenuLink, - NavigationMenuIndicator, - NavigationMenuViewport, - navigationMenuTriggerStyle, -} diff --git a/src/components/ui/separator.tsx b/src/components/ui/separator.tsx deleted file mode 100644 index bb3ad74..0000000 --- a/src/components/ui/separator.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from "react" -import * as SeparatorPrimitive from "@radix-ui/react-separator" - -import { cn } from "@/lib/utils" - -function Separator({ - className, - orientation = "horizontal", - decorative = true, - ...props -}: React.ComponentProps<typeof SeparatorPrimitive.Root>) { - return ( - <SeparatorPrimitive.Root - data-slot="separator" - decorative={decorative} - orientation={orientation} - className={cn( - "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px", - className - )} - {...props} - /> - ) -} - -export { Separator } diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx deleted file mode 100644 index 6906f5b..0000000 --- a/src/components/ui/sheet.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import * as React from "react" -import * as SheetPrimitive from "@radix-ui/react-dialog" -import { XIcon } from "lucide-react" - -import { cn } from "@/lib/utils" - -function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) { - return <SheetPrimitive.Root data-slot="sheet" {...props} /> -} - -function SheetTrigger({ - ...props -}: React.ComponentProps<typeof SheetPrimitive.Trigger>) { - return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} /> -} - -function SheetClose({ - ...props -}: React.ComponentProps<typeof SheetPrimitive.Close>) { - return <SheetPrimitive.Close data-slot="sheet-close" {...props} /> -} - -function SheetPortal({ - ...props -}: React.ComponentProps<typeof SheetPrimitive.Portal>) { - return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} /> -} - -function SheetOverlay({ - className, - ...props -}: React.ComponentProps<typeof SheetPrimitive.Overlay>) { - return ( - <SheetPrimitive.Overlay - data-slot="sheet-overlay" - className={cn( - "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", - className - )} - {...props} - /> - ) -} - -function SheetContent({ - className, - children, - side = "right", - ...props -}: React.ComponentProps<typeof SheetPrimitive.Content> & { - side?: "top" | "right" | "bottom" | "left" -}) { - return ( - <SheetPortal> - <SheetOverlay /> - <SheetPrimitive.Content - data-slot="sheet-content" - className={cn( - "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500", - side === "right" && - "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm", - side === "left" && - "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm", - side === "top" && - "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b", - side === "bottom" && - "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t", - className - )} - {...props} - > - {children} - <SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"> - <XIcon className="size-4" /> - <span className="sr-only">Close</span> - </SheetPrimitive.Close> - </SheetPrimitive.Content> - </SheetPortal> - ) -} - -function SheetHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="sheet-header" - className={cn("flex flex-col gap-1.5 p-4", className)} - {...props} - /> - ) -} - -function SheetFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( - <div - data-slot="sheet-footer" - className={cn("mt-auto flex flex-col gap-2 p-4", className)} - {...props} - /> - ) -} - -function SheetTitle({ - className, - ...props -}: React.ComponentProps<typeof SheetPrimitive.Title>) { - return ( - <SheetPrimitive.Title - data-slot="sheet-title" - className={cn("text-foreground font-semibold", className)} - {...props} - /> - ) -} - -function SheetDescription({ - className, - ...props -}: React.ComponentProps<typeof SheetPrimitive.Description>) { - return ( - <SheetPrimitive.Description - data-slot="sheet-description" - className={cn("text-muted-foreground text-sm", className)} - {...props} - /> - ) -} - -export { - Sheet, - SheetTrigger, - SheetClose, - SheetContent, - SheetHeader, - SheetFooter, - SheetTitle, - SheetDescription, -} |
