migrate: convert most components to svelte 5

This commit is contained in:
Xylight committed 2024-10-25 19:33:27 -07:00
1 parent d670f39f0a
commit 10ef4123da
225 files changed
+5441 -3341

No files matched your search

+47 -18
View File
@@ -3,17 +3,38 @@
type ButtonAlignment,
type ButtonColor,
} from '../button/Button.svelte'
import { Icon, type IconSource} from 'svelte-hero-icons'
export let color: ButtonColor = 'tertiary'
export let alignment: ButtonAlignment = 'left'
export let href: string | undefined = undefined
export let disabled: boolean = false
let clazz: string = ''
export { clazz as class }
interface Props {
color?: ButtonColor;
alignment?: ButtonAlignment;
href?: string | undefined;
disabled?: boolean;
class?: string;
icon?: IconSource;
prefix?: import('svelte').Snippet;
children?: import('svelte').Snippet;
suffix?: import('svelte').Snippet;
[key: string]: any
}
let {
color = 'tertiary',
alignment = 'left',
href = undefined,
disabled = false,
class: clazz = '',
icon,
prefix,
children,
suffix,
...rest
}: Props = $props();
</script>
<Button
{...$$restProps}
{...rest}
on:click
{color}
rounding="none"
@@ -26,15 +47,23 @@
{href}
{disabled}
>
<span
class="contents {color == 'tertiary'
? 'text-slate-600 dark:text-zinc-400'
: ''}
flex-shrink-0"
slot="prefix"
>
<slot name="prefix" />
</span>
<slot />
<slot name="suffix" slot="suffix" />
{#snippet prefix()}
<span
class="contents {color == 'tertiary'
? 'text-slate-600 dark:text-zinc-400'
: ''}
flex-shrink-0"
>
{#if !icon}
<Icon src={icon} micro size="16" />
{:else}
{@render prefix?.()}
{/if}
</span>
{/snippet}
{@render children?.()}
{#snippet suffix()}
{@render suffix?.()}
{/snippet}
</Button>