2023-08-11 11:48:33 +00:00
|
|
|
"use client";
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
// next theme
|
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
|
2023-08-11 11:48:33 +00:00
|
|
|
// mobx react lite
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
|
|
|
|
export const NavbarTheme = observer(() => {
|
2023-09-01 11:12:30 +00:00
|
|
|
const { setTheme, theme } = useTheme();
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
const handleTheme = () => {
|
2023-09-01 11:12:30 +00:00
|
|
|
setTheme(theme === "light" ? "dark" : "light");
|
2023-08-11 11:48:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2023-09-01 11:12:30 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2023-08-11 11:48:33 +00:00
|
|
|
onClick={handleTheme}
|
2023-09-01 11:12:30 +00:00
|
|
|
className="relative w-7 h-7 grid place-items-center bg-custom-background-100 hover:bg-custom-background-80 text-custom-text-100 rounded"
|
2023-08-11 11:48:33 +00:00
|
|
|
>
|
2023-09-01 11:12:30 +00:00
|
|
|
<span className="material-symbols-rounded text-sm">{theme === "light" ? "dark_mode" : "light_mode"}</span>
|
|
|
|
</button>
|
2023-08-11 11:48:33 +00:00
|
|
|
);
|
|
|
|
});
|