From 9e3f0c518bf30872dc240515fda7b9d282812804 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:47 +0530 Subject: [PATCH] refactor: restyle dialog with header, body and footer parts --- app/components/ui/dialog.tsx | 150 ++++++++++------------------------- 1 file changed, 40 insertions(+), 110 deletions(-) diff --git a/app/components/ui/dialog.tsx b/app/components/ui/dialog.tsx index 222b777..d33226e 100644 --- a/app/components/ui/dialog.tsx +++ b/app/components/ui/dialog.tsx @@ -1,119 +1,49 @@ -import * as React from 'react'; -import * as DialogPrimitive from '@radix-ui/react-dialog'; +import type { ComponentProps } from 'react'; +import { Root, Trigger, Portal, Close, Overlay, Content, Title, Description } from '@radix-ui/react-dialog'; import { X } from 'lucide-react'; import { cn } from '~/lib/utils'; -const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = DialogPrimitive.Portal; -const DialogClose = DialogPrimitive.Close; +export const Dialog = Root; +export const DialogTrigger = Trigger; +export const DialogClose = Close; -const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; +export function DialogContent({ className, children, ...props }: ComponentProps) { + return ( + + + + {children} + + + Close + + + + ); +} -const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - - - - {children} - - - Close - - - -)); -DialogContent.displayName = DialogPrimitive.Content.displayName; +export function DialogHeader({ className, ...props }: ComponentProps<'div'>) { + return
; +} -const DialogHeader = ({ - className, - ...props -}: React.HTMLAttributes) => ( -
-); -DialogHeader.displayName = 'DialogHeader'; +export function DialogBody({ className, ...props }: ComponentProps<'div'>) { + return
; +} -const DialogFooter = ({ - className, - ...props -}: React.HTMLAttributes) => ( -
-); -DialogFooter.displayName = 'DialogFooter'; +export function DialogFooter({ className, ...props }: ComponentProps<'div'>) { + return
; +} -const DialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -DialogTitle.displayName = DialogPrimitive.Title.displayName; +export function DialogTitle({ className, ...props }: ComponentProps) { + return ; +} -const DialogDescription = React.forwardRef< - React.ElementRef<typeof DialogPrimitive.Description>, - React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> ->(({ className, ...props }, ref) => ( - <DialogPrimitive.Description - ref={ref} - className={cn('text-sm text-neutral-400', className)} - {...props} - /> -)); -DialogDescription.displayName = DialogPrimitive.Description.displayName; - -export { - Dialog, - DialogPortal, - DialogOverlay, - DialogClose, - DialogTrigger, - DialogContent, - DialogHeader, - DialogFooter, - DialogTitle, - DialogDescription, -}; +export function DialogDescription({ className, ...props }: ComponentProps<typeof Description>) { + return <Description className={cn('text-sm text-text-subtle', className)} {...props} />; +}