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,16 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { locale } from '$lib/translations'
|
||||
|
||||
export let number: number
|
||||
let localeToUse: string = $locale
|
||||
export let options: Intl.NumberFormatOptions = {
|
||||
notation: 'compact',
|
||||
|
||||
interface Props {
|
||||
number: number;
|
||||
locale?: string;
|
||||
options?: Intl.NumberFormatOptions;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
let {
|
||||
number,
|
||||
locale: localeToUse = $locale,
|
||||
options = {
|
||||
notation: 'compact',
|
||||
},
|
||||
class: clazz = ''
|
||||
}: Props = $props();
|
||||
|
||||
|
||||
export { localeToUse as locale }
|
||||
|
||||
</script>
|
||||
|
||||
<span class={clazz ?? ''}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang="ts" context="module">
|
||||
<script lang="ts" module>
|
||||
export function formatRelativeDate(
|
||||
date: Date,
|
||||
options: Intl.RelativeTimeFormatOptions,
|
||||
@@ -41,12 +41,6 @@
|
||||
<script lang="ts">
|
||||
import { locale } from '$lib/translations'
|
||||
|
||||
export let date: Date
|
||||
export let relativeTo: Date | undefined = undefined
|
||||
export let options: Intl.RelativeTimeFormatOptions = {
|
||||
numeric: 'always',
|
||||
style: 'narrow',
|
||||
}
|
||||
|
||||
const toLocaleDateString = (date: Date): string => {
|
||||
try {
|
||||
@@ -56,10 +50,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: dateTime = toLocaleDateString(date)
|
||||
export let style: string = ''
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
interface Props {
|
||||
date: Date;
|
||||
relativeTo?: Date | undefined;
|
||||
options?: Intl.RelativeTimeFormatOptions;
|
||||
style?: string;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
date,
|
||||
relativeTo = undefined,
|
||||
options = {
|
||||
numeric: 'always',
|
||||
style: 'narrow',
|
||||
},
|
||||
style = '',
|
||||
class: clazz = ''
|
||||
}: Props = $props();
|
||||
|
||||
let dateTime = $derived(toLocaleDateString(date))
|
||||
</script>
|
||||
|
||||
<time datetime={dateTime} title={dateTime} class={clazz} {style}>
|
||||
|
||||
@@ -2,11 +2,18 @@
|
||||
import DebugTree from '$lib/components/util/debug/DebugTree.svelte'
|
||||
import { Modal } from 'mono-svelte'
|
||||
|
||||
export let object: any
|
||||
export let open: boolean = false
|
||||
interface Props {
|
||||
object: any;
|
||||
open?: boolean;
|
||||
title?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let { object, open = $bindable(false), title }: Props = $props();
|
||||
</script>
|
||||
|
||||
<Modal bind:open>
|
||||
<span slot="title"><slot name="title">Debug</slot></span>
|
||||
{#snippet title()}
|
||||
<span >{#if title}{@render title()}{:else}Debug{/if}</span>
|
||||
{/snippet}
|
||||
<DebugTree {object} isParent={true} />
|
||||
</Modal>
|
||||
@@ -1,6 +1,11 @@
|
||||
<script lang="ts">
|
||||
export let object: any
|
||||
export let isParent: boolean = false
|
||||
import DebugTree from './DebugTree.svelte';
|
||||
interface Props {
|
||||
object: any;
|
||||
isParent?: boolean;
|
||||
}
|
||||
|
||||
let { object, isParent = false }: Props = $props();
|
||||
</script>
|
||||
|
||||
<ul class:ml-4={!isParent} class="leading-8">
|
||||
@@ -10,7 +15,7 @@
|
||||
<code>{key}</code>
|
||||
</summary>
|
||||
{#if typeof object[key] === 'object'}
|
||||
<svelte:self object={object[key]} isParent={false} />
|
||||
<DebugTree object={object[key]} isParent={false} />
|
||||
{:else}
|
||||
<pre class="break-words">{object[key]}</pre>
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user