updated theming and fixed warnings
This commit is contained in:
25
frontend/src/components/ThemeSwitcher.astro
Normal file
25
frontend/src/components/ThemeSwitcher.astro
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
const { defaultTheme } = Astro.props;
|
||||
---
|
||||
|
||||
<select id="user-theme-switcher" class="bg-surface0/50 text-text border border-surface1 rounded px-2 py-1 text-xs focus:outline-none focus:border-mauve transition-colors cursor-pointer">
|
||||
<option value="mocha">Mocha</option>
|
||||
<option value="macchiato">Macchiato</option>
|
||||
<option value="frappe">Frappe</option>
|
||||
<option value="latte">Latte</option>
|
||||
<option value="scaled-and-icy">Scaled and Icy</option>
|
||||
</select>
|
||||
|
||||
<script is:inline define:vars={{ defaultTheme }}>
|
||||
const switcher = document.getElementById('user-theme-switcher');
|
||||
if (switcher) {
|
||||
const savedTheme = localStorage.getItem('user-theme') || defaultTheme;
|
||||
switcher.value = savedTheme;
|
||||
|
||||
switcher.addEventListener('change', (e) => {
|
||||
const newTheme = e.target.value;
|
||||
localStorage.setItem('user-theme', newTheme);
|
||||
document.documentElement.className = newTheme;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user