Basic components for the project and stitches theme

This commit is contained in:
Valtteri Karesto
2021-11-19 15:24:59 +02:00
parent 8f97a824f5
commit 00cf9abae7
18 changed files with 1260 additions and 284 deletions

View File

@@ -0,0 +1,37 @@
import { useState, useEffect } from "react";
import { useTheme } from "next-themes";
import { Sun, Moon } from "phosphor-react";
import Box from "./Box";
const ThemeChanger = () => {
const { theme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) return null;
return (
<Box
onClick={() => {
setTheme(theme && theme === "light" ? "dark" : "light");
}}
css={{
display: "flex",
marginLeft: "auto",
cursor: "pointer",
alignItems: "center",
justifyContent: "center",
color: "$muted",
}}
>
{theme === "dark" ? (
<Sun weight="bold" size="16px" />
) : (
<Moon weight="bold" size="16px" />
)}
</Box>
);
};
export default ThemeChanger;