Burn it all to the ground and start with bun and a reorg
This commit is contained in:
26
src/app/_components/theme-switcher.tsx
Normal file
26
src/app/_components/theme-switcher.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
"use client";
|
||||
|
||||
import { MoonIcon, SunIcon } from "@heroicons/react/24/outline";
|
||||
import type React from "react";
|
||||
|
||||
export default function ThemeSwitcher(): React.JSX.Element {
|
||||
const toggleTheme = (): void => {
|
||||
const currentTheme = document.documentElement.getAttribute('data-theme');
|
||||
if (currentTheme === 'light') {
|
||||
localStorage.theme = 'dark';
|
||||
document.documentElement.setAttribute('data-theme', 'dark');
|
||||
} else {
|
||||
localStorage.theme = 'light';
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<button type="button" className="m-1 h-8 w-8 rounded-full" onClick={toggleTheme}>
|
||||
<MoonIcon className="block dark:hidden" />
|
||||
<SunIcon className="hidden dark:block" />
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user