feat: add theme deletion

This commit is contained in:
Xylight committed 2024-07-25 11:37:35 -07:00
1 parent 1f08f04a0c
commit 926af69ec5
3 files changed
+45 -38

No files matched your search

+5 -5
View File
@@ -27,18 +27,18 @@ export function getDefaultColors(): ThemeColors {
500: '107 114 128',
600: '75 85 99',
700: '55 65 81',
800: '31 41 55',
800: '22 31 45',
900: '17 24 39',
925: '8 12 25',
950: '3 7 18',
},
primary: {
100: 'var(--c-p-100,241 245 249)',
900: 'var(--c-p-900,15 23 42)',
100: '241 245 249',
900: '15 23 42',
},
other: {
black: `var(--c-o-black,0 0 0)`,
white: `var(--c-o-white,255 255 255)`,
black: `0 0 0`,
white: `255 255 255`,
},
}
}
+4 -1
View File
@@ -56,7 +56,10 @@
<div class="flex flex-col gap-4 h-full">
<Header>Theme</Header>
<div class="grid grid-cols-4 items-center gap-4 overflow-auto max-h-72">
<div
class="grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4
gap-4 overflow-auto max-h-72"
>
{#each $themeData.themes as theme}
<ThemePreset {theme} />
{/each}
+36 -32
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { t } from '$lib/translations'
import { calculateVars, themeData, type Theme } from '$lib/ui/colors'
import { Button, Material, modal } from 'mono-svelte'
import { action, Button, Material, modal } from 'mono-svelte'
import { CheckCircle, Icon, Trash } from 'svelte-hero-icons'
export let theme: Theme
@@ -41,39 +41,43 @@
{/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>
<Button
color="ghost"
size="square-md"
on:click={() => {
modal({
actions: [
{
close: true,
content: $t('common.cancel'),
type: 'secondary',
action: () => {},
},
{
close: true,
content: $t('routes.theme.preset.delete.confirm'),
type: 'danger',
action: () => {
const index = $themeData.themes
.map((t) => t.id)
.indexOf(theme.id)
{#if theme.id > 0}
<Button
color="ghost"
size="square-md"
on:click={() => {
modal({
actions: [
action({
close: true,
type: 'secondary',
content: $t('common.cancel'),
}),
{
close: true,
content: $t('routes.theme.preset.delete.confirm'),
type: 'danger',
action: () => {
const index = $themeData.themes
.map((t) => t.id)
.indexOf(theme.id)
$themeData.themes = $themeData.themes.toSpliced(index, 1)
$themeData.themes = $themeData.themes.toSpliced(index, 1)
if (theme.id == $themeData.currentTheme) {
$themeData.currentTheme = 0
}
},
},
},
],
type: 'error',
body: '',
title: $t('routes.theme.preset.delete.title'),
})
}}
>
<Icon src={Trash} size="16" mini slot="prefix" />
</Button>
],
type: 'error',
body: '',
title: $t('routes.theme.preset.delete.title'),
})
}}
>
<Icon src={Trash} size="16" mini slot="prefix" />
</Button>
{/if}
</div>
</Material>
</button>