From 6cf4bc450fedfce93425d10ea1663cc59ff4b20b Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Wed, 4 Dec 2024 09:44:11 +0100 Subject: [PATCH] add fallbacks for when theme is undefined --- src/routes/(editor).tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/routes/(editor).tsx b/src/routes/(editor).tsx index 05b6f5b..1f8e550 100644 --- a/src/routes/(editor).tsx +++ b/src/routes/(editor).tsx @@ -23,11 +23,8 @@ export default function Editor(props: ParentProps) { const themeMenuId = createUniqueId(); const [commandPalette, setCommandPalette] = createSignal(); - const lightness = createMemo(() => { - const scheme = theme.colorScheme === ColorScheme.Auto ? event?.request.headers.get('Sec-CH-Prefers-Color-Scheme') : theme.colorScheme; - - return scheme === ColorScheme.Light ? .9 : .2; - }); + const colorScheme = createMemo(() => theme.colorScheme === ColorScheme.Auto ? event?.request.headers.get('Sec-CH-Prefers-Color-Scheme') ?? 'light dark' : theme.colorScheme); + const lightness = createMemo(() => colorScheme() === ColorScheme.Light ? .9 : .2); const commands = [ createCommand('open command palette', () => { @@ -53,12 +50,12 @@ export default function Editor(props: ParentProps) { Calque - - + +