shadcn base

This commit is contained in:
wip
2026-11-04 22:31:12 +01:00
commit d16a94324b
94 changed files with 15927 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
import * as React from "react"
import { cn } from "@/lib/cn"
import { usePortalContainer } from "@/lib/portal"
import { XIcon } from "lucide-react"
import { Dialog as DialogPrimitive } from "radix-ui"
import { buttonVariants } from "@/components/ui/button"
function Dialog(props: React.ComponentProps<typeof DialogPrimitive.Root>) {
return <DialogPrimitive.Root data-slot="dialog" {...props} />
}
function DialogTrigger(props: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
}
function DialogPortal(props: React.ComponentProps<typeof DialogPrimitive.Portal>) {
return <DialogPrimitive.Portal data-slot="dialog-portal" container={usePortalContainer()} {...props} />
}
function DialogClose(props: React.ComponentProps<typeof DialogPrimitive.Close>) {
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
}
/** Dimmed, blurred backdrop. */
function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
return (
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn("fixed inset-0 z-[60] bg-scrim backdrop-blur-[6px] data-[state=open]:animate-fade-in", className)}
{...props}
/>
)
}
/** Close button in the design's ghost style. */
const closeButtonClass = cn(buttonVariants({ variant: "ghost", size: "sm", iconOnly: true }), "text-fg-subtle")
function DialogContent({
className,
children,
showCloseButton = true,
...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean
}) {
return (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
"fixed top-[10vh] left-1/2 z-[61] box-border max-w-[calc(100vw-32px)] -translate-x-1/2 rounded-2xl border border-line-strong bg-raised text-fg shadow-dialog outline-none data-[state=open]:animate-panel-in",
className
)}
{...props}
>
{children}
{showCloseButton && (
<DialogPrimitive.Close data-slot="dialog-close" aria-label="Schließen" className={cn(closeButtonClass, "absolute top-5 right-4")}>
<XIcon size={16} strokeWidth={1.75} />
</DialogPrimitive.Close>
)}
</DialogPrimitive.Content>
</DialogPortal>
)
}
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="dialog-header" className={cn("flex flex-col gap-1", className)} {...props} />
}
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-footer"
className={cn("flex justify-end gap-2.5 border-t border-line-divider px-[22px] py-3.5", className)}
{...props}
/>
)
}
function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
return <DialogPrimitive.Title data-slot="dialog-title" className={cn("m-0 text-lg font-bold", className)} {...props} />
}
function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>) {
return (
<DialogPrimitive.Description
data-slot="dialog-description"
className={cn("m-0 text-sm text-fg-subtle", className)}
{...props}
/>
)
}
export {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogTitle,
DialogTrigger,
closeButtonClass,
}