diff --git a/frontend/src/lib/components/Navbar.svelte b/frontend/src/lib/components/Navbar.svelte index ae5eb72..7d64eb7 100644 --- a/frontend/src/lib/components/Navbar.svelte +++ b/frontend/src/lib/components/Navbar.svelte @@ -20,6 +20,8 @@ import { onMount } from 'svelte'; let inputElement: HTMLInputElement | null = null; + let theme = ''; + // Event listener for focusing input function handleKeydown(event: KeyboardEvent) { // Ignore any keypresses in an input/textarea field, so we don't interfere with typing. @@ -38,6 +40,8 @@ // Attach event listener on component mount document.addEventListener('keydown', handleKeydown); + theme = document.documentElement.getAttribute('data-theme'); + // Cleanup event listener on component destruction return () => { document.removeEventListener('keydown', handleKeydown); @@ -69,9 +73,14 @@ locale.set(newLocale); window.location.reload(); }; + const submitThemeChange = (event: Event) => { + const theme = event.target.value; + const themeForm = event.target.parentNode; + themeForm.action = `/?/setTheme&theme=${theme}`; + themeForm.submit(); + }; const submitUpdateTheme: SubmitFunction = ({ action }) => { const theme = action.searchParams.get('theme'); - console.log('theme', theme); if (theme) { document.documentElement.setAttribute('data-theme', theme); } @@ -303,13 +312,15 @@

{$t('navbar.theme_selection')}

- {#each themes as theme} -
  • - -
  • - {/each} +