feat: add name editing

This commit is contained in:
Xylight committed 2024-07-25 11:49:54 -07:00
1 parent 926af69ec5
commit 9c9e5dff76
4 files changed
+44 -6

No files matched your search

+2 -2
View File
@@ -61,14 +61,14 @@
gap-4 overflow-auto max-h-72"
>
{#each $themeData.themes as theme}
<ThemePreset {theme} />
<ThemePreset bind:theme />
{/each}
<button
on:click={() => {
const newTheme = {
id: Math.max(...$themeData.themes.map((t) => t.id)) + 1,
colors: getDefaultColors(),
name: `New Theme`,
name: $t('routes.theme.preset.new'),
}
$themeData.themes = [...$themeData.themes, newTheme]
+17 -3
View File
@@ -1,12 +1,12 @@
<script lang="ts">
import { t } from '$lib/translations'
import { calculateVars, themeData, type Theme } from '$lib/ui/colors'
import { action, Button, Material, modal } from 'mono-svelte'
import { action, Button, Material, modal, TextInput } from 'mono-svelte'
import { CheckCircle, Icon, Trash } from 'svelte-hero-icons'
export let theme: Theme
let editing
let editingName = false
</script>
<button class="h-full" on:click={() => ($themeData.currentTheme = theme.id)}>
@@ -40,11 +40,25 @@
/>
{/if}
<div class="px-4 py-2 flex items-center gap-1 justify-between">
<span class="font-medium text-lg font-display">{theme.name}</span>
{#if editingName}
<form on:submit|preventDefault={() => (editingName = false)}>
<TextInput bind:value={theme.name}></TextInput>
</form>
{:else}
<button
on:click={() => {
if (theme.id > 0) editingName = true
}}
class="text-left font-medium text-lg font-display"
>
{theme.name}
</button>
{/if}
{#if theme.id > 0}
<Button
color="ghost"
size="square-md"
class="flex-shrink-0"
on:click={() => {
modal({
actions: [