system theme (#4010)

This commit is contained in:
Dax
2025-11-06 18:00:09 -05:00
committed by GitHub
parent a2ab019317
commit 3ba7e243d0
6 changed files with 843 additions and 531 deletions
@@ -1,26 +1,24 @@
import { DialogSelect, type DialogSelectRef } from "../ui/dialog-select"
import { THEMES, useTheme } from "../context/theme"
import { useTheme } from "../context/theme"
import { useDialog } from "../ui/dialog"
import { onCleanup, onMount } from "solid-js"
export function DialogThemeList() {
const theme = useTheme()
const options = Object.keys(THEMES).map((value) => ({
const options = Object.keys(theme.all()).map((value) => ({
title: value,
value: value as keyof typeof THEMES,
value: value,
}))
const dialog = useDialog()
let confirmed = false
let ref: DialogSelectRef<keyof typeof THEMES>
let ref: DialogSelectRef<string>
const initial = theme.selected
onMount(() => {
// highlight the first theme in the list when we open it for UX
theme.set(Object.keys(THEMES)[0] as keyof typeof THEMES)
theme.set(Object.keys(theme.all())[0])
})
onCleanup(() => {
// if we close the dialog without confirming, reset back to the initial theme
if (!confirmed) theme.set(initial)
})