2023-08-02 12:53:55 -05:00
|
|
|
import { useTheme } from "next-themes";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import { faSun, faMoon } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
|
2023-11-16 02:22:16 -06:00
|
|
|
type Props = {
|
|
|
|
className?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function ToggleDarkMode({ className }: Props) {
|
2023-08-02 12:53:55 -05:00
|
|
|
const { theme, setTheme } = useTheme();
|
|
|
|
|
|
|
|
const handleToggle = () => {
|
|
|
|
if (theme === "dark") {
|
|
|
|
setTheme("light");
|
|
|
|
} else {
|
|
|
|
setTheme("dark");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-11-16 02:22:16 -06:00
|
|
|
className={`cursor-pointer flex select-none border border-sky-600 items-center justify-center dark:bg-neutral-900 bg-white hover:border-sky-500 group duration-100 rounded-full text-white w-10 h-10 ${className}`}
|
2023-08-02 12:53:55 -05:00
|
|
|
onClick={handleToggle}
|
|
|
|
>
|
2023-11-16 02:22:16 -06:00
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={theme === "dark" ? faSun : faMoon}
|
|
|
|
className="w-1/2 h-1/2 text-sky-600 group-hover:text-sky-500"
|
|
|
|
/>
|
2023-08-02 12:53:55 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|