a tool for shared writing and social publishing
at feature/analytics 56 lines 1.6 kB view raw
1import * as Dialog from "@radix-ui/react-dialog"; 2import React from "react"; 3import { CloseTiny } from "./Icons/CloseTiny"; 4 5export const Modal = ({ 6 className, 7 open, 8 onOpenChange, 9 asChild, 10 trigger, 11 title, 12 children, 13}: { 14 className?: string; 15 open?: boolean; 16 onOpenChange?: (open: boolean) => void; 17 asChild?: boolean; 18 trigger: React.ReactNode; 19 title?: React.ReactNode; 20 children: React.ReactNode; 21}) => { 22 return ( 23 <Dialog.Root open={open} onOpenChange={onOpenChange}> 24 <Dialog.Trigger asChild={asChild}>{trigger}</Dialog.Trigger> 25 <Dialog.Portal> 26 <Dialog.Overlay className="fixed z-10 inset-0 bg-primary data-[state=open]:animate-overlayShow opacity-60" /> 27 <Dialog.Content 28 className={` 29 z-20 fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 30 overflow-y-scroll no-scrollbar w-max max-w-screen h-fit max-h-screen p-3 flex flex-col 31 32 `} 33 > 34 <Dialog.Close className="bg-bg-page rounded-full -mb-3 mr-2 z-10 w-fit p-1 place-self-end border border-border-light text-tertiary"> 35 <CloseTiny /> 36 </Dialog.Close> 37 <div 38 className={` 39 opaque-container p-3 40 flex flex-col gap-1 rounded-lg! 41 ${className}`} 42 > 43 {title ? ( 44 <Dialog.Title> 45 <h3>{title}</h3> 46 </Dialog.Title> 47 ) : ( 48 <Dialog.Title /> 49 )} 50 <Dialog.Description>{children}</Dialog.Description> 51 </div> 52 </Dialog.Content> 53 </Dialog.Portal> 54 </Dialog.Root> 55 ); 56};