Skip to content

Commit 093c684

Browse files
samejrericallam
authored andcommitted
Optionally hide the Close button in the Dialog title bar
1 parent e7b2794 commit 093c684

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

apps/webapp/app/components/primitives/Dialog.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
3636

3737
const DialogContent = React.forwardRef<
3838
React.ElementRef<typeof DialogPrimitive.Content>,
39-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
40-
>(({ className, children, ...props }, ref) => (
39+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
40+
showCloseButton?: boolean;
41+
}
42+
>(({ className, children, showCloseButton = true, ...props }, ref) => (
4143
<DialogPortal>
4244
<DialogOverlay />
4345
<DialogPrimitive.Content
@@ -50,16 +52,18 @@ const DialogContent = React.forwardRef<
5052
>
5153
<hr className="absolute left-0 top-11 w-full" />
5254
{children}
53-
<DialogPrimitive.Close className="data-[state=open]:bg-accent data-[state=open]:text-muted-foreground group absolute right-2 top-[0.5625rem] flex items-center gap-1 rounded-sm p-1 py-1 pl-0 pr-1 opacity-70 transition focus-custom hover:bg-charcoal-750 hover:opacity-100 focus-visible:focus-custom disabled:pointer-events-none">
54-
<ShortcutKey
55-
shortcut={{
56-
key: "esc",
57-
}}
58-
variant="medium"
59-
/>
60-
<XMarkIcon className="size-4 text-text-dimmed transition group-hover:text-text-bright" />
61-
<span className="sr-only">Close</span>
62-
</DialogPrimitive.Close>
55+
{showCloseButton && (
56+
<DialogPrimitive.Close className="data-[state=open]:bg-accent data-[state=open]:text-muted-foreground group absolute right-2 top-[0.5625rem] flex items-center gap-1 rounded-sm p-1 py-1 pl-0 pr-1 opacity-70 transition focus-custom hover:bg-charcoal-750 hover:opacity-100 focus-visible:focus-custom disabled:pointer-events-none">
57+
<ShortcutKey
58+
shortcut={{
59+
key: "esc",
60+
}}
61+
variant="medium"
62+
/>
63+
<XMarkIcon className="size-4 text-text-dimmed transition group-hover:text-text-bright" />
64+
<span className="sr-only">Close</span>
65+
</DialogPrimitive.Close>
66+
)}
6367
</DialogPrimitive.Content>
6468
</DialogPortal>
6569
));

0 commit comments

Comments
 (0)