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

+32 -14
View File
@@ -1,4 +1,7 @@
<script lang="ts">
import { createBubbler } from 'svelte/legacy';
const bubble = createBubbler();
type Elevation = keyof typeof elevationClass
type Padding = keyof typeof paddingClass
type Rounding = keyof typeof roundedClass
@@ -43,24 +46,39 @@
none: '',
}
export let elevation: Elevation = 'flat'
export let padding: Padding = 'md'
export let rounding: Rounding = 'lg'
export let color: Color = 'default'
export let element: string = 'div'
let clazz: string = ''
export { clazz as class }
interface Props {
elevation?: Elevation;
padding?: Padding;
rounding?: Rounding;
color?: Color;
element?: string;
class?: string;
children?: import('svelte').Snippet;
[key: string]: any
}
let {
elevation = 'flat',
padding = 'md',
rounding = 'lg',
color = 'default',
element = 'div',
class: clazz = '',
children,
...rest
}: Props = $props();
</script>
<svelte:element
this={element}
on:click
on:keypress
on:keydown
on:keyup
on:focus
{...$$restProps}
onclick={bubble('click')}
onkeypress={bubble('keypress')}
onkeydown={bubble('keydown')}
onkeyup={bubble('keyup')}
onfocus={bubble('focus')}
{...rest}
class="{elevationClass[elevation]}
{paddingClass[padding]}
{roundedClass[rounding]}
@@ -69,5 +87,5 @@
{clazz}
"
>
<slot />
{@render children?.()}
</svelte:element>