Skip to content

Commit

Permalink
Update SwitchTheme.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi authored Oct 2, 2024
1 parent 7f295ff commit e7e9a3b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/nextjs/components/SwitchTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ export const SwitchTheme = ({ className }: { className?: string }) => {
const isDarkMode = resolvedTheme === "dark";

const handleToggle = () => {
if (isDarkMode) {
setTheme("light");
return;
}
setTheme("dark");
setTheme(isDarkMode ? "light" : "dark");
};

useEffect(() => {
Expand All @@ -26,10 +22,14 @@ export const SwitchTheme = ({ className }: { className?: string }) => {

return (
<div className={`flex space-x-2 h-8 items-center justify-center text-sm ${className}`}>
<label htmlFor="theme-toggle" className={`swap swap-rotate ${!isDarkMode ? "swap-active" : ""}`}>
<SunIcon className="swap-on h-5 w-5" />
<MoonIcon className="swap-off h-5 w-5" />
</label>
<button onClick={handleToggle} className="swap swap-rotate">
{isDarkMode ? (
<MoonIcon className="h-5 w-5" />
) : (
<SunIcon className="h-5 w-5" />
)}
</button>
</div>
);
};

0 comments on commit e7e9a3b

Please sign in to comment.