Merge pull request #373 from Xyphyn/new-theme-handler

feat: remake theme handling
This commit is contained in:
Xylight authored and GitHub committed 2024-07-25 12:32:25 -07:00
commit e40d3c5b4a
13 files changed
+684 -281

No files matched your search

@@ -1,5 +1,4 @@
<script lang="ts">
import { Color } from '$lib/ui/colors'
import {
ArrowDownCircle,
ArrowUp,
+33 -16
View File
@@ -4,7 +4,7 @@
top: boolean | null
noGap: boolean | null
},
screenWidth: number,
screenWidth: number
): {
noGap: boolean
top: boolean
@@ -35,7 +35,7 @@
export const calculatePadding = (
panel: boolean,
top: boolean,
content: boolean,
content: boolean
): {
top: number
class: string
@@ -62,13 +62,13 @@
})
export let contentPadding: Readable<ReturnType<typeof calculatePadding>> =
derived(dockProps, ($dockProps, set) =>
set(calculatePadding($dockProps.noGap, $dockProps.top, true)),
set(calculatePadding($dockProps.noGap, $dockProps.top, true))
)
</script>
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { colors, colorsToVars } from '$lib/ui/colors'
import { themeVars } from '$lib/ui/colors'
import { routes } from '$lib/util.js'
import { derived, writable, type Readable, type Writable } from 'svelte/store'
@@ -84,8 +84,8 @@
<div
{...$$restProps}
class="shell {$$props.class}"
style={colorsToVars($colors)}
class="shell bg-slate-50 dark:bg-zinc-950 {$$props.class}"
style={$themeVars}
>
<slot />
<div
@@ -109,10 +109,10 @@
: 'border rounded-full'}
dark:bg-transparent transition-colors duration-500
pointer-events-auto {topPanel
? 'bg-slate-50 dark:bg-zinc-950 border-slate-100 dark:border-zinc-900'
: `border-slate-200 dark:border-zinc-800 shadow-2xl backdrop-blur-xl
dark:backdrop-brightness-[25%] bg-[#ffffff]/75`}"
pointer-events-auto backdrop-blur-xl {topPanel
? 'bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900'
: `border-slate-200 dark:border-zinc-800 shadow-2xl
bg-white/50 dark:bg-zinc-925/70`}"
{title}
style="transition: border-radius 250ms;"
/>
@@ -124,7 +124,7 @@
>
<slot
name="sidebar"
class="hidden md:flex sticky top-0 left-0 max-w-full h-max bg-slate-50 dark:bg-zinc-950
class="hidden md:flex sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950
z-40
{sidePadding.class}"
style="grid-area: sidebar; width: 100% !important;"
@@ -132,7 +132,7 @@
<slot
name="main"
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm z-0
{$contentPadding.class}"
{$contentPadding.class} main"
style="grid-area: main"
/>
<slot
@@ -163,6 +163,11 @@
grid-template-areas: 'main';
justify-items: start;
}
.content > * {
width: 100%; /* Full width for immediate children */
max-width: 100rem; /* Limit width */
padding: 0 1rem; /* Add some padding on smaller screens */
}
@media (min-width: 768px) {
.content {
@@ -174,13 +179,25 @@
@media (min-width: 1280px) {
.content {
grid-template-columns: 20% 1fr 20%;
grid-template-columns: 20% 60% 20%;
justify-items: end center start;
grid-template-areas: 'sidebar main suffix';
}
}
.limit-width {
max-width: 100rem;
.content:is(.limit-width) {
grid-template-columns: 1fr 2fr 1fr;
}
:global(.content:is(.limit-width) > *:first-child) {
max-width: 20rem;
justify-self: end;
width: 100%;
}
:global(.content:is(.limit-width) > *:last-child) {
max-width: 20rem;
justify-self: start;
width: 100%;
}
}
</style>
+5 -5
View File
@@ -31,7 +31,7 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { legacyTheme } from '$lib/ui/colors'
import { colorScheme } from '$lib/ui/colors'
import { userSettings } from '$lib/settings'
import { site } from '$lib/lemmy'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
@@ -127,11 +127,11 @@
</MenuButton>
<MenuButton class="!py-0">
<Icon
src={$legacyTheme == 'system'
src={$colorScheme == 'system'
? ComputerDesktop
: $legacyTheme == 'light'
: $colorScheme == 'light'
? Sun
: $legacyTheme == 'dark'
: $colorScheme == 'dark'
? Moon
: Moon}
mini
@@ -142,7 +142,7 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="contents" on:click|stopPropagation={() => {}}>
<Select bind:value={$legacyTheme} class="ml-auto my-auto w-24" size="sm">
<Select bind:value={$colorScheme} class="ml-auto my-auto w-24" size="sm">
<option value="system">{$t('nav.menu.colorscheme.system')}</option>
<option value="light">{$t('nav.menu.colorscheme.light')}</option>
<option value="dark">{$t('nav.menu.colorscheme.dark')}</option>
@@ -8,7 +8,7 @@ import {
import { resumables, type ResumableItem } from '$lib/lemmy/item'
import { userSettings } from '$lib/settings'
import { t } from '$lib/translations'
import { legacyTheme } from '$lib/ui/colors'
import { colorScheme } from '$lib/ui/colors'
import { fullCommunityName } from '$lib/util'
import {
ArrowRightOnRectangle,
@@ -354,21 +354,21 @@ export function getGroups(
name: t.get('nav.commands.setColorTo', {
default: t.get('nav.menu.colorscheme.system'),
}),
handle: () => legacyTheme.set('system'),
handle: () => colorScheme.set('system'),
icon: ComputerDesktop,
},
{
name: t.get('nav.commands.setColorTo', {
default: t.get('nav.menu.colorscheme.light'),
}),
handle: () => legacyTheme.set('light'),
handle: () => colorScheme.set('light'),
icon: Sun,
},
{
name: t.get('nav.commands.setColorTo', {
default: t.get('nav.menu.colorscheme.dark'),
}),
handle: () => legacyTheme.set('dark'),
handle: () => colorScheme.set('dark'),
icon: Moon,
},
],