Skip to content

Commit 0842cba

Browse files
committed
feat: Improve Alert Dialog and Dialog mobile UI
1 parent 628e3b8 commit 0842cba

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

tools/server/webui/src/lib/components/ui/alert-dialog/alert-dialog-content.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@
1111
}: WithoutChild<AlertDialogPrimitive.ContentProps> & {
1212
portalProps?: WithoutChildrenOrChild<AlertDialogPrimitive.PortalProps>;
1313
} = $props();
14+
15+
let innerHeight = $state(0);
1416
</script>
1517

18+
<svelte:window bind:innerHeight />
19+
1620
<AlertDialogPrimitive.Portal {...portalProps}>
1721
<AlertDialogOverlay />
1822
<AlertDialogPrimitive.Content
1923
bind:ref
2024
data-slot="alert-dialog-content"
2125
class={cn(
22-
'fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg',
26+
'fixed z-[999999] grid w-full gap-4 border bg-background p-6 shadow-lg duration-200',
27+
// Mobile: Bottom sheet behavior
28+
`right-0 bottom-0 left-0 max-h-[${innerHeight}px] translate-x-0 translate-y-0 overflow-y-auto rounded-t-lg`,
29+
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-bottom-full',
30+
'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-bottom-full',
31+
// Desktop: Centered dialog behavior
32+
'sm:top-[50%] sm:right-auto sm:bottom-auto sm:left-[50%] sm:max-h-none sm:max-w-lg sm:translate-x-[-50%] sm:translate-y-[-50%] sm:rounded-lg',
33+
'sm:data-[state=closed]:slide-out-to-bottom-0 sm:data-[state=closed]:zoom-out-95',
34+
'sm:data-[state=open]:slide-in-from-bottom-0 sm:data-[state=open]:zoom-in-95',
2335
className
2436
)}
2537
{...restProps}

tools/server/webui/src/lib/components/ui/alert-dialog/alert-dialog-footer.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<div
1414
bind:this={ref}
1515
data-slot="alert-dialog-footer"
16-
class={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
16+
class={cn(
17+
'mt-6 flex flex-row gap-2 sm:mt-0 sm:justify-end [&>*]:flex-1 sm:[&>*]:flex-none',
18+
className
19+
)}
1720
{...restProps}
1821
>
1922
{@render children?.()}

tools/server/webui/src/lib/components/ui/dialog/dialog-content.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@
1717
children: Snippet;
1818
showCloseButton?: boolean;
1919
} = $props();
20+
21+
let innerHeight = $state(0);
2022
</script>
2123

24+
<svelte:window bind:innerHeight />
25+
2226
<Dialog.Portal {...portalProps}>
2327
<Dialog.Overlay />
2428
<DialogPrimitive.Content
2529
bind:ref
2630
data-slot="dialog-content"
2731
class={cn(
28-
'fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border/30 bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg',
32+
`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border/30 bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg max-h-[${innerHeight}px] overflow-y-auto`,
2933
className
3034
)}
3135
{...restProps}

0 commit comments

Comments
 (0)