mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-28 18:26:36 +00:00
42 lines
1.3 KiB
Svelte
42 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import { Dialog as DialogPrimitive } from 'bits-ui';
|
|
import X from 'lucide-svelte/icons/x';
|
|
import * as Dialog from './index.js';
|
|
import { cn, flyAndScale } from '$lib/utils/style.js';
|
|
|
|
type $$Props = DialogPrimitive.ContentProps & {
|
|
closeButton?: boolean;
|
|
};
|
|
|
|
let className: $$Props['class'] = undefined;
|
|
export let transition: $$Props['transition'] = flyAndScale;
|
|
export let closeButton: $$Props['closeButton'] = true;
|
|
export let transitionConfig: $$Props['transitionConfig'] = {
|
|
duration: 200
|
|
};
|
|
export { className as class };
|
|
</script>
|
|
|
|
<Dialog.Portal>
|
|
<Dialog.Overlay />
|
|
<DialogPrimitive.Content
|
|
{transition}
|
|
{transitionConfig}
|
|
class={cn(
|
|
'bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg sm:rounded-lg md:w-full',
|
|
className
|
|
)}
|
|
{...$$restProps}
|
|
>
|
|
<slot />
|
|
{#if closeButton}
|
|
<DialogPrimitive.Close
|
|
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none"
|
|
>
|
|
<X class="h-4 w-4" />
|
|
<span class="sr-only">Close</span>
|
|
</DialogPrimitive.Close>
|
|
{/if}
|
|
</DialogPrimitive.Content>
|
|
</Dialog.Portal>
|