chore(web): migration svelte 5 syntax (#13883)

This commit is contained in:
Alex
2024-11-14 08:43:25 -06:00
committed by GitHub
parent 9203a61709
commit 0b3742cf13
310 changed files with 6435 additions and 4176 deletions

View File

@@ -3,18 +3,37 @@
import Button from '../../elements/buttons/button.svelte';
import type { Color } from '$lib/components/elements/buttons/button.svelte';
import { t } from 'svelte-i18n';
import type { Snippet } from 'svelte';
export let title = $t('confirm');
export let prompt = $t('are_you_sure_to_do_this');
export let confirmText = $t('confirm');
export let confirmColor: Color = 'red';
export let cancelText = $t('cancel');
export let cancelColor: Color = 'secondary';
export let hideCancelButton = false;
export let disabled = false;
export let width: 'wide' | 'narrow' = 'narrow';
export let onCancel: () => void;
export let onConfirm: () => void;
interface Props {
title?: string;
prompt?: string;
confirmText?: string;
confirmColor?: Color;
cancelText?: string;
cancelColor?: Color;
hideCancelButton?: boolean;
disabled?: boolean;
width?: 'wide' | 'narrow';
onCancel: () => void;
onConfirm: () => void;
promptSnippet?: Snippet;
}
let {
title = $t('confirm'),
prompt = $t('are_you_sure_to_do_this'),
confirmText = $t('confirm'),
confirmColor = 'red',
cancelText = $t('cancel'),
cancelColor = 'secondary',
hideCancelButton = false,
disabled = false,
width = 'narrow',
onCancel,
onConfirm,
promptSnippet,
}: Props = $props();
const handleConfirm = () => {
onConfirm();
@@ -23,19 +42,19 @@
<FullScreenModal {title} onClose={onCancel} {width}>
<div class="text-md py-5 text-center">
<slot name="prompt">
{#if promptSnippet}{@render promptSnippet()}{:else}
<p>{prompt}</p>
</slot>
{/if}
</div>
<svelte:fragment slot="sticky-bottom">
{#snippet stickyBottom()}
{#if !hideCancelButton}
<Button color={cancelColor} fullwidth on:click={onCancel}>
<Button color={cancelColor} fullwidth onclick={onCancel}>
{cancelText}
</Button>
{/if}
<Button color={confirmColor} fullwidth on:click={handleConfirm} {disabled}>
<Button color={confirmColor} fullwidth onclick={handleConfirm} {disabled}>
{confirmText}
</Button>
</svelte:fragment>
{/snippet}
</FullScreenModal>