misc: specify desktop-only items
This commit is contained in:
1 parent
ae1a3bffc0
commit
5f34a102c3
6 files changed
+141
-49
No files matched your search
@@ -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.",
|
||||
|
||||
+17
-15
@@ -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<Colors>({
|
||||
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'
|
||||
|
||||
@@ -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)
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<meta
|
||||
name="theme-color"
|
||||
content={darklegacyTheme
|
||||
? $colors?.zinc?.[925] ?? defaultColors.zinc[925]
|
||||
: $colors?.slate?.[25] ?? defaultColors.slate[25]}
|
||||
/>
|
||||
<meta name="theme-color" content={themeColor} />
|
||||
{#if $site}
|
||||
<title>{$site.site_view.site.name}</title>
|
||||
{#if LINKED_INSTANCE_URL}
|
||||
|
||||
@@ -93,7 +93,9 @@
|
||||
bind:selected={$userSettings.dock.noGap}
|
||||
/>
|
||||
</Setting>
|
||||
<Setting>
|
||||
<Setting
|
||||
supportedPlatforms={{ desktop: true, tablet: true, mobile: false }}
|
||||
>
|
||||
<span slot="title">{$t('settings.navigation.pins.title')}</span>
|
||||
<span slot="description">
|
||||
{$t('settings.navigation.pins.description')}
|
||||
@@ -128,14 +130,6 @@
|
||||
</Section>
|
||||
|
||||
<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>
|
||||
<span slot="title" class="inline-flex items-center gap-2">
|
||||
{$t('settings.app.lang.title')}
|
||||
@@ -226,6 +220,7 @@
|
||||
description={$t('settings.app.displayName.description')}
|
||||
/>
|
||||
<ToggleSetting
|
||||
supportedPlatforms={{ desktop: true, tablet: false, mobile: false }}
|
||||
bind:checked={$userSettings.newWidth}
|
||||
title={$t('settings.app.limitLayoutWidth.title')}
|
||||
description={$t('settings.app.limitLayoutWidth.description')}
|
||||
@@ -259,7 +254,7 @@
|
||||
bind:selected={$userSettings.leftAlign}
|
||||
/>
|
||||
</Setting>
|
||||
<Setting vertical>
|
||||
<Setting itemsClass="flex-col !items-start">
|
||||
<span slot="title">{$t('settings.app.font.title')}</span>
|
||||
<span slot="description">{$t('settings.app.font.description')}</span>
|
||||
<MultiSelect
|
||||
@@ -268,6 +263,14 @@
|
||||
bind:selected={$userSettings.font}
|
||||
/>
|
||||
</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>
|
||||
<span slot="title">{$t('settings.app.translation.title')}</span>
|
||||
<span slot="description">
|
||||
|
||||
@@ -1,25 +1,62 @@
|
||||
<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 supportedPlatforms = {
|
||||
desktop: true,
|
||||
tablet: true,
|
||||
mobile: true,
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex {vertical
|
||||
? 'flex-col'
|
||||
: 'flex-row items-center'} w-full justify-between gap-4 max-w-full {$$props.mainClass}"
|
||||
class="flex flex-col w-full justify-between gap-2 max-w-full {$$props.mainClass}"
|
||||
>
|
||||
<div class="flex flex-col gap-0.5 flex-1 {$$props.class}">
|
||||
<h1 class="font-medium text-base"><slot name="title" /></h1>
|
||||
{#if $$slots.description}
|
||||
<p class="text-slate-800 dark:text-zinc-200 text-sm">
|
||||
<slot name="description" />
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if $$slots.default}
|
||||
<div
|
||||
class="w-full flex flex-col gap-2 flex-1 items-end max-w-full {$$props.optionClass}"
|
||||
>
|
||||
<slot />
|
||||
{#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}">
|
||||
<h1 class="font-medium text-base"><slot name="title" /></h1>
|
||||
{#if $$slots.description}
|
||||
<p class="text-slate-800 dark:text-zinc-200 text-sm">
|
||||
<slot name="description" />
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if $$slots.default}
|
||||
<div
|
||||
class="w-full flex flex-col gap-2 flex-1 items-end max-w-full {$$props.optionClass}"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,12 +1,47 @@
|
||||
<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 description: string | undefined = undefined
|
||||
export let checked: boolean = false
|
||||
|
||||
export let supportedPlatforms = {
|
||||
desktop: true,
|
||||
tablet: true,
|
||||
mobile: true,
|
||||
}
|
||||
</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
|
||||
bind:checked
|
||||
class="flex-row-reverse items-center w-full"
|
||||
|
||||
Reference in new issue
Block a user