import * as DialogPrimitive from "@radix-ui/react-dialog"; import { cva } from "class-variance-authority"; import { XIcon } from "lucide-react"; import { type ComponentProps } from "react"; import { cn } from "../hooks"; type ModalProps = ComponentProps; /** * Modal root based on Radix Dialog. */ function Modal({ ...props }: ModalProps) { return ; } type ModalTriggerProps = ComponentProps; /** Trigger element that opens the modal. */ function ModalTrigger({ ...props }: ModalTriggerProps) { return ; } type ModalPortalProps = ComponentProps; /** Portal for modal content/overlay. */ function ModalPortal({ ...props }: ModalPortalProps) { return ; } type ModalCloseProps = ComponentProps; /** Close control for the modal. */ function ModalClose({ ...props }: ModalCloseProps) { return ; } const modalOverlayVariants = cva([ "fixed", "inset-0", "z-10", "bg-bg-mask", "transition-all", "duration-200", ]); type ModalOverlayProps = ComponentProps; /** Fullscreen overlay displayed behind the modal. */ function ModalOverlay({ className, ...props }: ModalOverlayProps) { return ( ); } const modalContentVariants = cva([ "pb-xl", "px-xl", "bg-bg-primary", "rounded-uk-xl", "shadow-[0_4px_16px_0_var(--color-shadow-secondary)]", "duration-200", "transition-all", "fixed", "translate-x-[-50%]", "translate-y-[-50%]", "z-11", "left-1/2", "top-1/2", "data-[state=open]:animate-in", "data-[state=closed]:animate-out", "data-[state=closed]:fade-out-0", "data-[state=open]:fade-in-0", "data-[state=closed]:zoom-out-95", "data-[state=open]:zoom-in-95", "liquid-dark:liquid-dark-bg", "liquid-light:liquid-light-bg", ]); interface ModalContentProps extends ComponentProps { showCloseButton?: boolean; } /** * Modal content panel with optional close button. */ function ModalContent({ className, children, showCloseButton = true, ...props }: ModalContentProps) { return ( {children} {showCloseButton && ( Close )} ); } type ModalHeaderProps = ComponentProps<"div">; /** Header container inside modal. */ function ModalHeader({ className, ...props }: ModalHeaderProps) { return
; } type ModalTitleProps = ComponentProps; /** Title element for the modal. */ function ModalTitle({ className, ...props }: ModalTitleProps) { return ( ); } type ModalDescriptionProps = ComponentProps; /** Secondary descriptive text within the modal. */ function ModalDescription({ className, ...props }: ModalDescriptionProps) { return ( ); } type ModalFooterProps = ComponentProps<"div">; /** Footer row aligning actions to the end. */ function ModalFooter({ className, ...props }: ModalFooterProps) { return (
); } export { Modal, ModalTrigger, ModalPortal, ModalOverlay, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalFooter, ModalClose, }; export type { ModalProps, ModalTriggerProps, ModalPortalProps, ModalOverlayProps, ModalContentProps, ModalHeaderProps, ModalTitleProps, ModalDescriptionProps, ModalFooterProps, ModalCloseProps, };