feat: add name editing
This commit is contained in:
1 parent
926af69ec5
commit
9c9e5dff76
4 files changed
+44
-6
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { getDefaultTheme, presets } from './presets'
|
||||
import { browser } from '$app/environment'
|
||||
import { t } from '$lib/translations'
|
||||
|
||||
type ColorScheme = 'system' | 'light' | 'dark'
|
||||
|
||||
@@ -164,9 +165,11 @@ function loadColorScheme() {
|
||||
function loadTheme() {
|
||||
if (!browser) return
|
||||
const localTheme = localStorage.getItem('themeData')
|
||||
|
||||
if (localTheme) {
|
||||
return JSON.parse(localTheme)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -174,4 +177,21 @@ if (browser) {
|
||||
try {
|
||||
loadColorScheme()
|
||||
} catch (e) {}
|
||||
try {
|
||||
const oldColors = localStorage.getItem('colors')
|
||||
if (oldColors) {
|
||||
themeData.update((td) => ({
|
||||
...td,
|
||||
themes: [
|
||||
...td.themes,
|
||||
{
|
||||
id: Math.max(...td.themes.map((t) => t.id)) + 1,
|
||||
colors: JSON.parse(oldColors),
|
||||
name: t.get('routes.theme.preset.imported') ?? 'Your Theme',
|
||||
},
|
||||
],
|
||||
}))
|
||||
localStorage.removeItem('colors')
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
Reference in new issue
Block a user