diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 809a7b50..79a0c009 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -532,6 +532,9 @@ "settings": { "title": "Settings", "beta": "Beta", + "desktop": "Desktop", + "tablet": "Tablet", + "mobile": "Mobile", "navigation": { "title": "Navigation", "dockPos": { @@ -560,6 +563,10 @@ "description": "Customize Photon's colors.", "link": "Go to themes" }, + "colorscheme": { + "title": "Color Scheme", + "description": "The color scheme to use." + }, "lang": { "title": "Language", "description": "The language used for Photon's UI.", diff --git a/src/lib/ui/colors.ts b/src/lib/ui/colors.ts index 093fa469..28b861a7 100644 --- a/src/lib/ui/colors.ts +++ b/src/lib/ui/colors.ts @@ -30,7 +30,7 @@ interface Theme { export interface Colors { slate: { - 25?: string, + 25?: string 50?: string 100?: string 200?: string @@ -42,7 +42,7 @@ export interface Colors { 900?: string 925?: string 950?: string - }, + } zinc: { 100?: string 200?: string @@ -55,13 +55,13 @@ export interface Colors { 900?: string 925?: string 950?: string - }, + } primary: { - 100?: string, - 900?: string, - }, + 100?: string + 900?: string + } other: { - black?: string, + black?: string white?: string } } @@ -101,15 +101,15 @@ export const defaultColors = { }, other: { black: `#000`, - white: `var(--c-o-white,#fff)` - } + white: `var(--c-o-white,#fff)`, + }, } export let colors = writable({ slate: {}, zinc: {}, primary: {}, - other: {} + other: {}, }) export function colorsToVars(colors: Colors): string { @@ -118,15 +118,18 @@ export function colorsToVars(colors: Colors): string { for (let shade in colors[category as keyof Colors]) { if (category) // @ts-ignore - vars.push(`--c-${category.slice(0, 1)}-${shade}:${colors[category][shade]}`) + vars.push( + `--c-${category.slice(0, 1)}-${shade}:${colors[category][shade]}` + ) } } return vars.join(';') } -export const colorToVar = (category: keyof Colors, shade: keyof keyof Colors): string => - `--c-${category.slice(0,2)}-${shade.toString()}` - +export const colorToVar = ( + category: keyof Colors, + shade: keyof (keyof Colors) +): string => `--c-${category.slice(0, 2)}-${shade.toString()}` function loadColors() { const loaded = localStorage.getItem('colors') @@ -142,7 +145,6 @@ if (browser) { loadColors() } - const configuredLegacyTheme = env.PUBLIC_LEGACYTHEME ?? 'system' export const legacyTheme = writable<'system' | 'light' | 'dark'>( configuredLegacyTheme as 'system' | 'light' | 'dark' diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 2a67b464..d171e7d4 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -14,6 +14,7 @@ defaultColors, inDarkLegacyTheme, legacyTheme, + type Colors, } from '$lib/ui/colors.js' import { userSettings } from '$lib/settings.js' import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte' @@ -62,21 +63,28 @@ .matchMedia('(prefers-color-scheme: dark)') .addEventListener('change', (event) => { darklegacyTheme = inDarkLegacyTheme() + themeColor = getMetaColor($colors) }) document.body.querySelector('.loader')?.classList.add('hidden') } }) $: title = routes[($page.route.id as keyof typeof routes) ?? ''] $: browser ? document.body.setAttribute('style', colorsToVars($colors)) : '' + + // svelte reactivity goof + const getMetaColor = (colors: Colors): string | undefined => { + const regex = /var\([^,]+,\s*(#[0-9A-Fa-f]{6})\)/m + + return darklegacyTheme + ? colors.zinc?.[925] ?? defaultColors.zinc[925].match(regex)?.[1] + : colors.slate?.[25] ?? defaultColors.slate[25].match(regex)?.[1] + } + + $: themeColor = getMetaColor($colors) - + {#if $site} {$site.site_view.site.name} {#if LINKED_INSTANCE_URL} diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 2e578b6f..51aeef14 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -93,7 +93,9 @@ bind:selected={$userSettings.dock.noGap} /> - + {$t('settings.navigation.pins.title')} {$t('settings.navigation.pins.description')} @@ -128,14 +130,6 @@
- - {$t('settings.app.theming.title')} - {$t('settings.app.theming.description')} - - {$t('settings.app.lang.title')} @@ -226,6 +220,7 @@ description={$t('settings.app.displayName.description')} /> - + {$t('settings.app.font.title')} {$t('settings.app.font.description')} + + {$t('settings.app.theming.title')} + {$t('settings.app.theming.description')} + + {$t('settings.app.translation.title')} diff --git a/src/routes/settings/Setting.svelte b/src/routes/settings/Setting.svelte index e89f46c4..e4cf1c92 100644 --- a/src/routes/settings/Setting.svelte +++ b/src/routes/settings/Setting.svelte @@ -1,25 +1,62 @@
-
-

- {#if $$slots.description} -

- -

- {/if} -
- {#if $$slots.default} -
- + {#if Object.values(supportedPlatforms).some((v) => v == false)} +
+ {#if supportedPlatforms.desktop} + + + {$t('settings.desktop')} + + {/if} + {#if supportedPlatforms.tablet} + + + {$t('settings.tablet')} + + {/if} + {#if supportedPlatforms.mobile} + + + {$t('settings.mobile')} + + {/if}
{/if} +
+
+

+ {#if $$slots.description} +

+ +

+ {/if} +
+ {#if $$slots.default} +
+ +
+ {/if} +
diff --git a/src/routes/settings/ToggleSetting.svelte b/src/routes/settings/ToggleSetting.svelte index 6cb31ddf..013c39a9 100644 --- a/src/routes/settings/ToggleSetting.svelte +++ b/src/routes/settings/ToggleSetting.svelte @@ -1,12 +1,47 @@ -
+
+ {#if Object.values(supportedPlatforms).some((v) => v == false)} +
+ {#if supportedPlatforms.desktop} + + + {$t('settings.desktop')} + + {/if} + {#if supportedPlatforms.tablet} + + + {$t('settings.tablet')} + + {/if} + {#if supportedPlatforms.mobile} + + + {$t('settings.mobile')} + + {/if} +
+ {/if}