cleanup: switch to $state for themes
This commit is contained in:
19 files changed
+169
-349
No files matched your search
@@ -10,14 +10,12 @@
|
||||
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
GlobeAlt,
|
||||
Home,
|
||||
Icon,
|
||||
MagnifyingGlass,
|
||||
Newspaper,
|
||||
PencilSquare,
|
||||
Plus,
|
||||
ServerStack,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons'
|
||||
import Profile from './Profile.svelte'
|
||||
import NavButton from './NavButton.svelte'
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
UserCircle,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import { colorScheme } from '$lib/ui/colors'
|
||||
import { theme } from '$lib/ui/colors.svelte'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { site } from '$lib/lemmy.svelte'
|
||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
||||
@@ -149,11 +149,11 @@
|
||||
<MenuButton class="!py-0">
|
||||
{#snippet prefix()}
|
||||
<Icon
|
||||
src={$colorScheme == 'system'
|
||||
src={theme.colorScheme == 'system'
|
||||
? ComputerDesktop
|
||||
: $colorScheme == 'light'
|
||||
: theme.colorScheme == 'light'
|
||||
? Sun
|
||||
: $colorScheme == 'dark'
|
||||
: theme.colorScheme == 'dark'
|
||||
? Moon
|
||||
: Moon}
|
||||
micro
|
||||
@@ -164,7 +164,11 @@
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="contents" onclick={stopPropagation(() => {})}>
|
||||
<Select bind:value={$colorScheme} class="ml-auto my-auto w-24" size="sm">
|
||||
<Select
|
||||
bind:value={theme.colorScheme}
|
||||
class="ml-auto my-auto w-24"
|
||||
size="sm"
|
||||
>
|
||||
<Option value="system" icon={ComputerDesktop}>
|
||||
{$t('nav.menu.colorscheme.system')}
|
||||
</Option>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import { afterNavigate, goto } from '$app/navigation'
|
||||
import { profile, profileData } from '$lib/auth.svelte'
|
||||
import { getGroups, type Action, type Group } from './actions.svelte'
|
||||
import { themeData } from '$lib/ui/colors'
|
||||
import { theme } from '$lib/ui/colors.svelte'
|
||||
import { page } from '$app/state'
|
||||
|
||||
interface Props {
|
||||
@@ -26,7 +26,7 @@
|
||||
$resumables,
|
||||
profile.data,
|
||||
profileData.profiles,
|
||||
$themeData,
|
||||
theme.data,
|
||||
page.data.contextual?.actions,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { resumables, type ResumableItem } from '$lib/lemmy/item'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors'
|
||||
import { theme, type ThemeData } from '$lib/ui/colors.svelte'
|
||||
import { fullCommunityName } from '$lib/util.svelte'
|
||||
import {
|
||||
ArrowRightOnRectangle,
|
||||
@@ -357,21 +357,21 @@ export function getGroups(
|
||||
name: t.get('nav.commands.setColorTo', {
|
||||
default: t.get('nav.menu.colorscheme.system'),
|
||||
}),
|
||||
handle: () => colorScheme.set('system'),
|
||||
handle: () => (theme.colorScheme = 'system'),
|
||||
icon: ComputerDesktop,
|
||||
},
|
||||
{
|
||||
name: t.get('nav.commands.setColorTo', {
|
||||
default: t.get('nav.menu.colorscheme.light'),
|
||||
}),
|
||||
handle: () => colorScheme.set('light'),
|
||||
handle: () => (theme.colorScheme = 'light'),
|
||||
icon: Sun,
|
||||
},
|
||||
{
|
||||
name: t.get('nav.commands.setColorTo', {
|
||||
default: t.get('nav.menu.colorscheme.dark'),
|
||||
}),
|
||||
handle: () => colorScheme.set('dark'),
|
||||
handle: () => (theme.colorScheme = 'dark'),
|
||||
icon: Moon,
|
||||
},
|
||||
],
|
||||
@@ -382,11 +382,7 @@ export function getGroups(
|
||||
subActions: td.themes.map((th) => ({
|
||||
name: t.get('nav.commands.setThemeTo', { default: th.name }),
|
||||
icon: Swatch,
|
||||
handle: () =>
|
||||
themeData.update((td) => ({
|
||||
...td,
|
||||
currentTheme: th.id,
|
||||
})),
|
||||
handle: () => (theme.data.currentTheme = th.id),
|
||||
})),
|
||||
},
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user