From 5ed2a2f666707e579e18f2890ab89b7cc6f717c3 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 6 Jun 2023 11:21:19 -0500 Subject: chore: remove docs example (#7306) --- .../components/RightSidebar/ThemeToggleButton.tsx | 82 ---------------------- 1 file changed, 82 deletions(-) delete mode 100644 examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx (limited to 'examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx') diff --git a/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx b/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx deleted file mode 100644 index b9682aa00..000000000 --- a/examples/docs/src/components/RightSidebar/ThemeToggleButton.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import type { FunctionalComponent } 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; -- cgit v1.2.3