feat: add basic theming support

This commit is contained in:
Xylight committed 2024-03-04 17:48:09 -08:00
1 parent 2d991fc4a2
commit 81ac6accf4
7 files changed
+299 -72

No files matched your search

+5 -4
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { colors, colorsToVars } from '$lib/ui/colors'
import { routes } from '$lib/util.js'
export let route: { id: string | null } | undefined = undefined
@@ -11,7 +12,7 @@
<svelte:window bind:scrollY={scroll} />
<div class="shell {$$props.class}">
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
<slot />
<slot
name="navbar"
@@ -29,17 +30,17 @@
>
<slot
name="sidebar"
class="hidden md:flex sticky top-16 left-0 w-full max-w-full"
class="hidden md:flex sticky top-16 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950"
style="grid-area: sidebar; width: 100% !important;"
/>
<slot
name="main"
class="w-full bg-slate-25 dark:bg-zinc-925 dark:bg-transparent justify-self-center shadow-sm"
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm"
style="grid-area: main"
/>
<slot
name="suffix"
class="max-xl:hidden w-full sticky top-16 left-0 h-full max-h-[calc(100svh-4rem)]"
class="max-xl:hidden w-full sticky top-16 left-0 h-full max-h-[calc(100svh-4rem)] bg-slate-50 dark:bg-zinc-950"
style="grid-area: suffix;"
/>
</div>
+1 -27
View File
@@ -10,41 +10,15 @@
import Logo from '$lib/components/ui/Logo.svelte'
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
import { site } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import { theme } from '$lib/ui/colors.js'
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import {
Badge,
Button,
Menu,
MenuButton,
MenuDivider,
Select,
Spinner,
toast,
} from 'mono-svelte'
import {
Bars3,
Bookmark,
BugAnt,
CodeBracket,
CodeBracketSquare,
Cog6Tooth,
CommandLine,
ComputerDesktop,
GlobeAlt,
Heart,
Icon,
Inbox,
InformationCircle,
MagnifyingGlass,
Moon,
Newspaper,
PencilSquare,
Plus,
ServerStack,
Sun,
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { fly } from 'svelte/transition'
import Profile from './Profile.svelte'
+14 -11
View File
@@ -27,8 +27,9 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { theme } from '$lib/ui/colors'
import { legacyTheme } from '$lib/ui/colors'
import { userSettings } from '$lib/settings'
import { goto } from '$app/navigation'
</script>
<Menu {...$$restProps}>
@@ -97,26 +98,28 @@
<Icon src={Cog6Tooth} mini width={16} />
Settings
</MenuButton>
<MenuButton class="!py-0">
<MenuButton
class="!py-0"
on:click={() => {
goto('/theme')
}}
>
<Icon
src={$theme == 'system'
src={$legacyTheme == 'system'
? ComputerDesktop
: $theme == 'light'
: $legacyTheme == 'light'
? Sun
: $theme == 'dark'
: $legacyTheme == 'dark'
? Moon
: Moon}
mini
size="16"
/>
<span>Color Scheme</span>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="flex flex-row flex-wrap justify-between w-full items-center"
on:click|stopPropagation
>
<span>Theme</span>
<Select bind:value={$theme} class="ml-auto my-auto w-24" size="sm">
<div class="contents" on:click|stopPropagation={() => {}}>
<Select bind:value={$legacyTheme} class="ml-auto my-auto w-24" size="sm">
<option value="system">System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>