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,37 +3,41 @@
import Icon from '$lib/components/elements/icon.svelte';
import type { CropAspectRatio } from '$lib/stores/asset-editor.store';
export let size: {
icon: string;
name: CropAspectRatio;
viewBox: string;
rotate?: boolean;
};
export let selectedSize: CropAspectRatio;
export let rotateHorizontal: boolean;
export let selectType: (size: CropAspectRatio) => void;
interface Props {
size: {
icon: string;
name: CropAspectRatio;
viewBox: string;
rotate?: boolean;
};
selectedSize: CropAspectRatio;
rotateHorizontal: boolean;
selectType: (size: CropAspectRatio) => void;
}
$: isSelected = selectedSize === size.name;
$: buttonColor = (isSelected ? 'primary' : 'transparent-gray') as Color;
let { size, selectedSize, rotateHorizontal, selectType }: Props = $props();
$: rotatedTitle = (title: string, toRotate: boolean) => {
let isSelected = $derived(selectedSize === size.name);
let buttonColor = $derived((isSelected ? 'primary' : 'transparent-gray') as Color);
let rotatedTitle = $derived((title: string, toRotate: boolean) => {
let sides = title.split(':');
if (toRotate) {
sides.reverse();
}
return sides.join(':');
};
});
$: toRotate = (def: boolean | undefined) => {
let toRotate = $derived((def: boolean | undefined) => {
if (def === false) {
return false;
}
return (def && !rotateHorizontal) || (!def && rotateHorizontal);
};
});
</script>
<li>
<Button color={buttonColor} class="flex-col gap-1" size="sm" rounded="lg" on:click={() => selectType(size.name)}>
<Button color={buttonColor} class="flex-col gap-1" size="sm" rounded="lg" onclick={() => selectType(size.name)}>
<Icon size="1.75em" path={size.icon} viewBox={size.viewBox} class={toRotate(size.rotate) ? 'rotate-90' : ''} />
<span>{rotatedTitle(size.name, rotateHorizontal)}</span>
</Button>