Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use-theme #2

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/components/theme-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { FC, useState, useEffect } from "react";
import { VisuallyHidden } from "@react-aria/visually-hidden";
import { SwitchProps, useSwitch } from "@nextui-org/switch";
import clsx from "clsx";
import { useTheme } from "@nextui-org/use-theme";

import { useTheme } from "@/hooks/use-theme";
import { SunFilledIcon, MoonFilledIcon } from "@/components/icons";

export interface ThemeSwitchProps {
Expand All @@ -17,9 +17,7 @@ export const ThemeSwitch: FC<ThemeSwitchProps> = ({
}) => {
const [isMounted, setIsMounted] = useState(false);

const { theme, toggleTheme } = useTheme();

const onChange = toggleTheme;
const { theme, setTheme } = useTheme();

const {
Component,
Expand All @@ -30,7 +28,7 @@ export const ThemeSwitch: FC<ThemeSwitchProps> = ({
getWrapperProps,
} = useSwitch({
isSelected: theme === "light",
onChange,
onChange: () => setTheme(theme === "light" ? "dark" : "light"),
});

useEffect(() => {
Expand Down
50 changes: 0 additions & 50 deletions src/hooks/use-theme.ts

This file was deleted.