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
@@ -25,10 +25,10 @@
|
||||
import { getDefaultColors } from '$lib/ui/presets'
|
||||
import ThemePreset from './ThemePreset.svelte'
|
||||
|
||||
let importing = false
|
||||
let importText = ''
|
||||
let importing = $state(false)
|
||||
let importText = $state('')
|
||||
|
||||
$: defaultColors = getDefaultColors()
|
||||
let defaultColors = $derived(getDefaultColors())
|
||||
</script>
|
||||
|
||||
{#if importing}
|
||||
@@ -74,7 +74,7 @@
|
||||
<ThemePreset bind:theme />
|
||||
{/each}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
const newTheme = {
|
||||
id: Math.max(...$themeData.themes.map((t) => t.id)) + 1,
|
||||
colors: getDefaultColors(),
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { createBubbler } from 'svelte/legacy';
|
||||
|
||||
const bubble = createBubbler();
|
||||
import { hexToRgb } from '$lib/ui/colors'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
export let value: string
|
||||
|
||||
const dispatch = createEventDispatcher<{ change: string }>()
|
||||
|
||||
let clazz: string = ''
|
||||
export { clazz as class }
|
||||
interface Props {
|
||||
value: string;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let { value = $bindable(), class: clazz = '' }: Props = $props();
|
||||
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -19,7 +26,7 @@
|
||||
class="rounded-md border cursor-pointer absolute top-0 left-0 w-full h-full opacity-0"
|
||||
type="color"
|
||||
bind:value
|
||||
on:change={() => dispatch('change', hexToRgb(value))}
|
||||
on:contextmenu
|
||||
onchange={() => dispatch('change', hexToRgb(value))}
|
||||
oncontextmenu={bubble('contextmenu')}
|
||||
/>
|
||||
</div>
|
||||
@@ -1,15 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { t } from '$lib/translations'
|
||||
import { calculateVars, themeData, type Theme } from '$lib/ui/colors'
|
||||
import { action, Button, Material, modal, TextInput } from 'mono-svelte'
|
||||
import { CheckCircle, Icon, Trash } from 'svelte-hero-icons'
|
||||
|
||||
export let theme: Theme
|
||||
interface Props {
|
||||
theme: Theme;
|
||||
}
|
||||
|
||||
let editingName = false
|
||||
let { theme = $bindable() }: Props = $props();
|
||||
|
||||
let editingName = $state(false)
|
||||
</script>
|
||||
|
||||
<button class="h-full" on:click={() => ($themeData.currentTheme = theme.id)}>
|
||||
<button class="h-full" onclick={() => ($themeData.currentTheme = theme.id)}>
|
||||
<Material
|
||||
padding="none"
|
||||
class="{theme.id == $themeData.currentTheme
|
||||
@@ -27,10 +33,10 @@
|
||||
</div>
|
||||
<div
|
||||
class="bg-white dark:bg-zinc-900 w-8 h-4 rounded-sm border border-slate-200 dark:border-zinc-800"
|
||||
/>
|
||||
></div>
|
||||
<div
|
||||
class="w-3 h-3 bg-primary-900 dark:bg-primary-100 rounded-full ml-auto"
|
||||
/>
|
||||
></div>
|
||||
</div>
|
||||
{#if theme.id == $themeData.currentTheme}
|
||||
<Icon
|
||||
@@ -42,12 +48,12 @@
|
||||
{/if}
|
||||
<div class="px-4 py-2 flex items-center gap-1 justify-between">
|
||||
{#if editingName}
|
||||
<form on:submit|preventDefault={() => (editingName = false)}>
|
||||
<form onsubmit={preventDefault(() => (editingName = false))}>
|
||||
<TextInput bind:value={theme.name}></TextInput>
|
||||
</form>
|
||||
{:else}
|
||||
<button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (theme.id > 0) editingName = true
|
||||
}}
|
||||
class="text-left font-medium text-lg font-display"
|
||||
@@ -90,7 +96,9 @@
|
||||
})
|
||||
}}
|
||||
>
|
||||
<Icon src={Trash} size="16" mini slot="prefix" />
|
||||
{#snippet prefix()}
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user