migrate: convert most components to svelte 5
This commit is contained in:
1 parent
d670f39f0a
commit
10ef4123da
225 files changed
+5441
-3341
No files matched your search
@@ -1,25 +1,44 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
|
||||
export let href: string | undefined = undefined
|
||||
export let icon: IconSource | undefined = undefined
|
||||
export let selected = false
|
||||
$: {
|
||||
interface Props {
|
||||
href?: string | undefined
|
||||
icon?: IconSource | undefined
|
||||
selected?: boolean
|
||||
class?: string
|
||||
customIcon?: import('svelte').Snippet<[any]>
|
||||
children?: import('svelte').Snippet
|
||||
label?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
let {
|
||||
href = undefined,
|
||||
icon = undefined,
|
||||
selected = $bindable(false),
|
||||
class: clazz = '',
|
||||
customIcon,
|
||||
children,
|
||||
label,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
run(() => {
|
||||
if (href != undefined) {
|
||||
selected = $page.url.pathname == href
|
||||
}
|
||||
}
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
})
|
||||
</script>
|
||||
|
||||
<Button
|
||||
color={selected ? 'primary' : 'tertiary'}
|
||||
alignment="left"
|
||||
{...$$restProps}
|
||||
{...rest}
|
||||
{href}
|
||||
on:click
|
||||
on:contextmenu
|
||||
@@ -27,13 +46,13 @@
|
||||
? 'text-slate-600 dark:text-zinc-400'
|
||||
: ''} {clazz}"
|
||||
>
|
||||
<slot {selected} name="icon" slot="prefix">
|
||||
{#if icon}
|
||||
{#snippet prefix()}
|
||||
{#if customIcon}{@render customIcon({ selected })}{:else if icon}
|
||||
<Icon src={icon} solid={selected} size="20" />
|
||||
{/if}
|
||||
</slot>
|
||||
<slot />
|
||||
{/snippet}
|
||||
{@render children?.()}
|
||||
<div class="contents">
|
||||
<slot name="label" />
|
||||
{@render label?.()}
|
||||
</div>
|
||||
</Button>
|
||||
Reference in new issue
Block a user