misc: specify desktop-only items

This commit is contained in:
Xylight committed 2024-06-28 15:00:28 -07:00
1 parent ae1a3bffc0
commit 5f34a102c3
6 files changed
+128 -36

No files matched your search

+7
View File
@@ -532,6 +532,9 @@
"settings": { "settings": {
"title": "Settings", "title": "Settings",
"beta": "Beta", "beta": "Beta",
"desktop": "Desktop",
"tablet": "Tablet",
"mobile": "Mobile",
"navigation": { "navigation": {
"title": "Navigation", "title": "Navigation",
"dockPos": { "dockPos": {
@@ -560,6 +563,10 @@
"description": "Customize Photon's colors.", "description": "Customize Photon's colors.",
"link": "Go to themes" "link": "Go to themes"
}, },
"colorscheme": {
"title": "Color Scheme",
"description": "The color scheme to use."
},
"lang": { "lang": {
"title": "Language", "title": "Language",
"description": "The language used for Photon's UI.", "description": "The language used for Photon's UI.",
+17 -15
View File
@@ -30,7 +30,7 @@ interface Theme {
export interface Colors { export interface Colors {
slate: { slate: {
25?: string, 25?: string
50?: string 50?: string
100?: string 100?: string
200?: string 200?: string
@@ -42,7 +42,7 @@ export interface Colors {
900?: string 900?: string
925?: string 925?: string
950?: string 950?: string
}, }
zinc: { zinc: {
100?: string 100?: string
200?: string 200?: string
@@ -55,13 +55,13 @@ export interface Colors {
900?: string 900?: string
925?: string 925?: string
950?: string 950?: string
}, }
primary: { primary: {
100?: string, 100?: string
900?: string, 900?: string
}, }
other: { other: {
black?: string, black?: string
white?: string white?: string
} }
} }
@@ -101,15 +101,15 @@ export const defaultColors = {
}, },
other: { other: {
black: `#000`, black: `#000`,
white: `var(--c-o-white,#fff)` white: `var(--c-o-white,#fff)`,
} },
} }
export let colors = writable<Colors>({ export let colors = writable<Colors>({
slate: {}, slate: {},
zinc: {}, zinc: {},
primary: {}, primary: {},
other: {} other: {},
}) })
export function colorsToVars(colors: Colors): string { 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]) { for (let shade in colors[category as keyof Colors]) {
if (category) if (category)
// @ts-ignore // @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(';') return vars.join(';')
} }
export const colorToVar = (category: keyof Colors, shade: keyof keyof Colors): string => export const colorToVar = (
`--c-${category.slice(0,2)}-${shade.toString()}` category: keyof Colors,
shade: keyof (keyof Colors)
): string => `--c-${category.slice(0, 2)}-${shade.toString()}`
function loadColors() { function loadColors() {
const loaded = localStorage.getItem('colors') const loaded = localStorage.getItem('colors')
@@ -142,7 +145,6 @@ if (browser) {
loadColors() loadColors()
} }
const configuredLegacyTheme = env.PUBLIC_LEGACYTHEME ?? 'system' const configuredLegacyTheme = env.PUBLIC_LEGACYTHEME ?? 'system'
export const legacyTheme = writable<'system' | 'light' | 'dark'>( export const legacyTheme = writable<'system' | 'light' | 'dark'>(
configuredLegacyTheme as 'system' | 'light' | 'dark' configuredLegacyTheme as 'system' | 'light' | 'dark'
+14 -6
View File
@@ -14,6 +14,7 @@
defaultColors, defaultColors,
inDarkLegacyTheme, inDarkLegacyTheme,
legacyTheme, legacyTheme,
type Colors,
} from '$lib/ui/colors.js' } from '$lib/ui/colors.js'
import { userSettings } from '$lib/settings.js' import { userSettings } from '$lib/settings.js'
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte' import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
@@ -62,21 +63,28 @@
.matchMedia('(prefers-color-scheme: dark)') .matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', (event) => { .addEventListener('change', (event) => {
darklegacyTheme = inDarkLegacyTheme() darklegacyTheme = inDarkLegacyTheme()
themeColor = getMetaColor($colors)
}) })
document.body.querySelector('.loader')?.classList.add('hidden') document.body.querySelector('.loader')?.classList.add('hidden')
} }
}) })
$: title = routes[($page.route.id as keyof typeof routes) ?? ''] $: title = routes[($page.route.id as keyof typeof routes) ?? '']
$: browser ? document.body.setAttribute('style', colorsToVars($colors)) : '' $: 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)
</script> </script>
<svelte:head> <svelte:head>
<meta <meta name="theme-color" content={themeColor} />
name="theme-color"
content={darklegacyTheme
? $colors?.zinc?.[925] ?? defaultColors.zinc[925]
: $colors?.slate?.[25] ?? defaultColors.slate[25]}
/>
{#if $site} {#if $site}
<title>{$site.site_view.site.name}</title> <title>{$site.site_view.site.name}</title>
{#if LINKED_INSTANCE_URL} {#if LINKED_INSTANCE_URL}
+13 -10
View File
@@ -93,7 +93,9 @@
bind:selected={$userSettings.dock.noGap} bind:selected={$userSettings.dock.noGap}
/> />
</Setting> </Setting>
<Setting> <Setting
supportedPlatforms={{ desktop: true, tablet: true, mobile: false }}
>
<span slot="title">{$t('settings.navigation.pins.title')}</span> <span slot="title">{$t('settings.navigation.pins.title')}</span>
<span slot="description"> <span slot="description">
{$t('settings.navigation.pins.description')} {$t('settings.navigation.pins.description')}
@@ -128,14 +130,6 @@
</Section> </Section>
<Section title={$t('settings.app.title')}> <Section title={$t('settings.app.title')}>
<Setting>
<span slot="title">{$t('settings.app.theming.title')}</span>
<span slot="description">{$t('settings.app.theming.description')}</span>
<Button href="/theme">
{$t('settings.app.theming.link')}
<Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
</Setting>
<Setting> <Setting>
<span slot="title" class="inline-flex items-center gap-2"> <span slot="title" class="inline-flex items-center gap-2">
{$t('settings.app.lang.title')} {$t('settings.app.lang.title')}
@@ -226,6 +220,7 @@
description={$t('settings.app.displayName.description')} description={$t('settings.app.displayName.description')}
/> />
<ToggleSetting <ToggleSetting
supportedPlatforms={{ desktop: true, tablet: false, mobile: false }}
bind:checked={$userSettings.newWidth} bind:checked={$userSettings.newWidth}
title={$t('settings.app.limitLayoutWidth.title')} title={$t('settings.app.limitLayoutWidth.title')}
description={$t('settings.app.limitLayoutWidth.description')} description={$t('settings.app.limitLayoutWidth.description')}
@@ -259,7 +254,7 @@
bind:selected={$userSettings.leftAlign} bind:selected={$userSettings.leftAlign}
/> />
</Setting> </Setting>
<Setting vertical> <Setting itemsClass="flex-col !items-start">
<span slot="title">{$t('settings.app.font.title')}</span> <span slot="title">{$t('settings.app.font.title')}</span>
<span slot="description">{$t('settings.app.font.description')}</span> <span slot="description">{$t('settings.app.font.description')}</span>
<MultiSelect <MultiSelect
@@ -268,6 +263,14 @@
bind:selected={$userSettings.font} bind:selected={$userSettings.font}
/> />
</Setting> </Setting>
<Setting>
<span slot="title">{$t('settings.app.theming.title')}</span>
<span slot="description">{$t('settings.app.theming.description')}</span>
<Button href="/theme">
{$t('settings.app.theming.link')}
<Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
</Setting>
<Setting> <Setting>
<span slot="title">{$t('settings.app.translation.title')}</span> <span slot="title">{$t('settings.app.translation.title')}</span>
<span slot="description"> <span slot="description">
+40 -3
View File
@@ -1,12 +1,48 @@
<script lang="ts"> <script lang="ts">
import { t } from '$lib/translations'
import { Badge } from 'mono-svelte'
import {
ComputerDesktop,
DevicePhoneMobile,
DeviceTablet,
Icon,
} from 'svelte-hero-icons'
export let vertical: boolean = false export let vertical: boolean = false
export let supportedPlatforms = {
desktop: true,
tablet: true,
mobile: true,
}
</script> </script>
<div <div
class="flex {vertical class="flex flex-col w-full justify-between gap-2 max-w-full {$$props.mainClass}"
? 'flex-col'
: 'flex-row items-center'} w-full justify-between gap-4 max-w-full {$$props.mainClass}"
> >
{#if Object.values(supportedPlatforms).some((v) => v == false)}
<div class="flex items-center gap-2 flex-wrap">
{#if supportedPlatforms.desktop}
<Badge>
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
{$t('settings.desktop')}
</Badge>
{/if}
{#if supportedPlatforms.tablet}
<Badge>
<Icon src={DeviceTablet} micro size="14" slot="icon" />
{$t('settings.tablet')}
</Badge>
{/if}
{#if supportedPlatforms.mobile}
<Badge>
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
{$t('settings.mobile')}
</Badge>
{/if}
</div>
{/if}
<div class="flex flex-row items-center gap-6 {$$props.itemsClass}">
<div class="flex flex-col gap-0.5 flex-1 {$$props.class}"> <div class="flex flex-col gap-0.5 flex-1 {$$props.class}">
<h1 class="font-medium text-base"><slot name="title" /></h1> <h1 class="font-medium text-base"><slot name="title" /></h1>
{#if $$slots.description} {#if $$slots.description}
@@ -22,4 +58,5 @@
<slot /> <slot />
</div> </div>
{/if} {/if}
</div>
</div> </div>
+37 -2
View File
@@ -1,12 +1,47 @@
<script lang="ts"> <script lang="ts">
import { Switch } from 'mono-svelte' import { t } from '$lib/translations'
import { Badge, Switch } from 'mono-svelte'
import {
ComputerDesktop,
DevicePhoneMobile,
DeviceTablet,
Icon,
} from 'svelte-hero-icons'
export let title: string export let title: string
export let description: string | undefined = undefined export let description: string | undefined = undefined
export let checked: boolean = false export let checked: boolean = false
export let supportedPlatforms = {
desktop: true,
tablet: true,
mobile: true,
}
</script> </script>
<div class="flex flex-row items-center w-full justify-between gap-4 max-w-full"> <div class="flex flex-col w-full justify-between gap-2 max-w-full">
{#if Object.values(supportedPlatforms).some((v) => v == false)}
<div class="flex items-center gap-2 flex-wrap">
{#if supportedPlatforms.desktop}
<Badge>
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
{$t('settings.desktop')}
</Badge>
{/if}
{#if supportedPlatforms.tablet}
<Badge>
<Icon src={DeviceTablet} micro size="14" slot="icon" />
{$t('settings.tablet')}
</Badge>
{/if}
{#if supportedPlatforms.mobile}
<Badge>
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
{$t('settings.mobile')}
</Badge>
{/if}
</div>
{/if}
<Switch <Switch
bind:checked bind:checked
class="flex-row-reverse items-center w-full" class="flex-row-reverse items-center w-full"