import type { FunctionalComponent } from 'preact'; import { h, Fragment } from 'preact'; import { useState, useEffect } from 'preact/hooks'; 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; ave/import.meta.resolve'>dave/import.meta.resolve Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/docs/project/profiling.md (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2023-08-31Make breakpoints faster in VSCode extensionGravatar Ashcon Partovi 1-241/+327
2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243
* use WTF to join registry strings * show dependency error messages, better join error We actually report errors when enqueuing dependencies now. I also made the join URLs error message read better. It'd be cleaner to handle it all in one place, but there's currently no way to propagate the data up. * starting on registry URL tests * added more registry URL tests * [install] prevent optional/peer deps from failing builds Couldn't get the peer dependency test to work, but the code is there. * ran prettier * changed error note to use realname, updated tests * ran prettier again...
2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45
* get file name from blob if not provided * add test * another test * format
2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0