0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/examples/docs/public/theme.js
Fred K. Schott 6bca7c83a7
redesign create-astro (#301)
* redesign create astro

* add changeset

* Use npm start

* Update the astro version

* Adds the changeset

Co-authored-by: Fred Schott <fks@Freds-MBP.attlocal.net>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
2021-06-08 11:10:56 -04:00

8 lines
282 B
JavaScript

(() => {
const root = document.documentElement;
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
root.classList.add('theme-dark');
} else {
root.classList.remove('theme-dark');
}
})();