~james/core

core/web/src/lib/components/settings/ThemePicker.svelte -rw-r--r-- 1.2 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script lang="ts">
	import Dropdown from "#lib/components/ui/Dropdown.svelte";
	import SettingsRow from "#lib/components/settings/SettingsRow.svelte";
	import ThemeChip from "#lib/components/settings/ThemeChip.svelte";
	import ThemeOption from "#lib/components/settings/ThemeOption.svelte";
	import ChevronDown from "$icon/chevron-down";
	import { PRESET_NAMES, themeLabel, type Theme } from "#lib/theme.ts";

	interface Props {
		value?: Theme;
	}

	let { value = $bindable("auto") }: Props = $props();

	const select = (theme: Theme) => (value = theme);
</script>

<SettingsRow title="Interface theme" description="Select a color scheme for the interface.">
	<Dropdown variant="button" align="right" label="Interface theme" menuClass="w-56">
		{#snippet trigger()}
			<ThemeChip theme={value} />
			<span>{themeLabel(value)}</span>
			<ChevronDown class="size-3.5 text-foreground-subtle" aria-hidden="true" />
		{/snippet}
		<ThemeOption theme="auto" selected={value === "auto"} onselect={select} />
		<hr class="border-border-default" />
		{#each PRESET_NAMES as theme (theme)}
			<ThemeOption {theme} selected={value === theme} onselect={select} />
		{/each}
	</Dropdown>
</SettingsRow>