Files
gpx.studio/website/src/lib/components/ui/dialog/dialog-content.svelte

49 lines
1.6 KiB
Svelte
Raw Normal View History

2025-06-21 21:07:36 +02:00
<script lang="ts">
import { Dialog as DialogPrimitive } from "bits-ui";
2026-04-06 18:22:01 +02:00
import DialogPortal from "./dialog-portal.svelte";
2025-06-21 21:07:36 +02:00
import type { Snippet } from "svelte";
import * as Dialog from "./index.js";
import { cn, type WithoutChildrenOrChild } from "$lib/utils.js";
2026-04-06 18:22:01 +02:00
import type { ComponentProps } from "svelte";
import { Button } from "$lib/components/ui/button/index.js";
import XIcon from '@lucide/svelte/icons/x';
2025-06-21 21:07:36 +02:00
let {
ref = $bindable(null),
class: className,
portalProps,
children,
showCloseButton = true,
...restProps
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
2026-04-06 18:22:01 +02:00
portalProps?: WithoutChildrenOrChild<ComponentProps<typeof DialogPortal>>;
2025-06-21 21:07:36 +02:00
children: Snippet;
showCloseButton?: boolean;
} = $props();
</script>
2026-04-06 18:22:01 +02:00
<DialogPortal {...portalProps}>
2025-06-21 21:07:36 +02:00
<Dialog.Overlay />
<DialogPrimitive.Content
bind:ref
data-slot="dialog-content"
class={cn(
2026-04-06 18:22:01 +02:00
"bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none",
2025-06-21 21:07:36 +02:00
className
)}
{...restProps}
>
{@render children?.()}
{#if showCloseButton}
2026-04-06 18:22:01 +02:00
<DialogPrimitive.Close data-slot="dialog-close">
{#snippet child({ props })}
<Button variant="ghost" class="absolute top-2 right-2" size="icon-sm" {...props}>
<XIcon />
<span class="sr-only">Close</span>
</Button>
{/snippet}
2025-06-21 21:07:36 +02:00
</DialogPrimitive.Close>
{/if}
</DialogPrimitive.Content>
2026-04-06 18:22:01 +02:00
</DialogPortal>