feat: add theme actions

This commit is contained in:
Xylight committed 2024-08-03 11:16:38 -07:00
1 parent bcd168df45
commit e31071aef3
5 files changed
+29 -7

No files matched your search

@@ -9,13 +9,19 @@
import { afterNavigate, goto } from '$app/navigation'
import { profile, profileData } from '$lib/auth'
import { getGroups, type Action, type Group } from './actions'
import { themeData } from '$lib/ui/colors'
export let open = false
$: if (open) search = ''
export let groups: Group[] = []
$: groups = getGroups($resumables, $profile, $profileData.profiles)
$: groups = getGroups(
$resumables,
$profile,
$profileData.profiles,
$themeData
)
let search = ''
let container: HTMLElement
@@ -8,7 +8,7 @@ import {
import { resumables, type ResumableItem } from '$lib/lemmy/item'
import { userSettings } from '$lib/settings'
import { t } from '$lib/translations'
import { colorScheme } from '$lib/ui/colors'
import { colorScheme, theme, themeData, type ThemeData } from '$lib/ui/colors'
import { fullCommunityName } from '$lib/util'
import {
ArrowRightOnRectangle,
@@ -42,6 +42,7 @@ import {
ArrowTrendingDown,
ChatBubbleOvalLeftEllipsis,
ChatBubbleLeftRight,
Swatch,
} from 'svelte-hero-icons'
import { get } from 'svelte/store'
@@ -64,7 +65,8 @@ export interface Action {
export function getGroups(
resumables: ResumableItem[],
profile: Profile,
profiles: Profile[]
profiles: Profile[],
td: ThemeData
) {
return [
{
@@ -373,6 +375,19 @@ export function getGroups(
},
],
},
{
name: t.get('nav.commands.setTheme'),
icon: Swatch,
subActions: td.themes.map((th) => ({
name: t.get('nav.commands.setThemeTo', { default: th.name }),
icon: Swatch,
handle: () =>
themeData.update((td) => ({
...td,
currentTheme: th.id,
})),
})),
},
],
},
{