From 7c744961494ca80f82b3ad66c98ff0a1c0496db7 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Fri, 30 Jul 2021 22:39:15 -0700 Subject: Docs site cleanup (#948) * add language selector * docs site cleanup * review feedback * code review comments --- docs/src/components/ThemeToggle.tsx | 82 ------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 docs/src/components/ThemeToggle.tsx (limited to 'docs/src/components/ThemeToggle.tsx') diff --git a/docs/src/components/ThemeToggle.tsx b/docs/src/components/ThemeToggle.tsx deleted file mode 100644 index 37b028758..000000000 --- a/docs/src/components/ThemeToggle.tsx +++ /dev/null @@ -1,82 +0,0 @@ -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; -- cgit v1.2.3