import type { FunctionalComponent } from 'preact'; import { h, Fragment } from 'preact'; import { useState, useEffect } from 'preact/hooks'; import './ThemeToggleButton.css'; const themes = ['light', 'dark']; const icons = [ , , ]; const ThemeToggle: FunctionalComponent = () => { const [theme, setTheme] = useState(() => { if (import.meta.env.SSR) { return undefined; } if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) { return localStorage.getItem('theme'); } if (window.matchMedia('(prefers-color-scheme: dark)').matches) { return 'dark'; } return 'light'; }); useEffect(() => { const root = document.documentElement; if (theme === 'light') { root.classList.remove('theme-dark'); } else { root.classList.add('theme-dark'); } }, [theme]); return (
{themes.map((t, i) => { const icon = icons[i]; const checked = t === theme; return ( ); })}
); }; export default ThemeToggle; ion value='dave/es5-class-helper'>dave/es5-class-helper Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/modules/NodeStringDecoderModule.h (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-09-13fix destroy and re add native decompressionGravatar cirospaciari 6-5018/+5018
2023-09-13this test blocks the mergeGravatar dave caruso 1-0/+9
2023-09-13got testGravatar dave caruso 2-0/+44
2023-09-13make jsGravatar dave caruso 1-3/+3
2023-09-13alternate approachGravatar dave caruso 1-10/+42