start adding a theme toggle

This commit is contained in:
Joshua 2022-10-17 22:22:05 +02:00
parent bb63d6b671
commit d22f7e4ab2
3 changed files with 38 additions and 0 deletions

View file

@ -1,11 +1,13 @@
import Title from "./Title";
import styles from "../styles/Navbar.module.sass";
import ThemeToggle from "./toggle/theme";
const Navbar = () => {
return (
<>
<div className={styles.center}>
<Title />
<ThemeToggle/>
</div>
</>
);

View file

@ -0,0 +1,26 @@
import styles from "styles/ThemeToggle.module.sass";
import { useTheme } from "next-themes";
import Icon from "components/Icon";
function the(t) {
switch (t) {
case "light":
return "dark";
case "dark":
return "light";
}
}
const ThemeToggle = () => {
const { resolvedTheme: theme, setTheme } = useTheme();
return (
<>
<button data-theme={theme} onClick={() => setTheme(the(theme))} className={styles.button}>
<Icon icon="asterisk" />
</button>
</>
);
};
export default ThemeToggle;

View file

@ -0,0 +1,10 @@
@import "./_variables"
.button
color: $text-dark-buttons
background: $background-dark-buttons
border: none
&[data-theme="light"]
background: $background-light-buttons
color: $text-light-buttons