Files
gpx.studio/website/src/lib/components/ButtonWithTooltip.svelte

39 lines
1.1 KiB
Svelte
Raw Normal View History

2024-09-30 12:56:58 +02:00
<script lang="ts">
import { Button } from '$lib/components/ui/button/index.js';
import * as Tooltip from '$lib/components/ui/tooltip/index.js';
2025-06-21 21:07:36 +02:00
import type { Snippet } from 'svelte';
2024-09-30 12:56:58 +02:00
2025-06-21 21:07:36 +02:00
const {
variant = 'default',
label,
side = 'top',
2025-10-05 19:34:05 +02:00
disabled = false,
2025-06-21 21:07:36 +02:00
class: className = '',
children,
onclick,
}: {
variant?: 'default' | 'secondary' | 'link' | 'destructive' | 'outline' | 'ghost';
label: string;
side?: 'top' | 'right' | 'bottom' | 'left';
2025-10-05 19:34:05 +02:00
disabled?: boolean;
2025-06-21 21:07:36 +02:00
class?: string;
children: Snippet;
onclick?: (event: MouseEvent) => void;
} = $props();
2024-09-30 12:56:58 +02:00
</script>
2025-06-21 21:07:36 +02:00
<Tooltip.Provider>
<Tooltip.Root>
<Tooltip.Trigger>
{#snippet child({ props })}
<Button {...props} {variant} class={className} {onclick}>
{@render children()}
</Button>
{/snippet}
</Tooltip.Trigger>
<Tooltip.Content {side}>
<span>{label}</span>
</Tooltip.Content>
</Tooltip.Root>
</Tooltip.Provider>