-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
190 additions
and
122 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use client" | ||
|
||
import { ThemeProvider as NextThemesProvider } from "next-themes" | ||
import * as React from "react" | ||
|
||
type ThemeProviderProps = Parameters<typeof NextThemesProvider>[0] | ||
|
||
/** | ||
* Your app's theme provider component. | ||
* 'use client' is essential for next-themes to work with app-dir. | ||
*/ | ||
export function ThemeProvider({ children, ...props }: ThemeProviderProps) { | ||
return <NextThemesProvider {...props}>{children}</NextThemesProvider> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use client" | ||
|
||
import { MoonIcon, SunIcon } from "@heroicons/react/24/outline" | ||
import { useTheme } from "next-themes" | ||
|
||
function ThemeToggle() { | ||
const { resolvedTheme, theme, setTheme } = useTheme() | ||
|
||
let isDark = resolvedTheme === "dark" | ||
|
||
const onChange = () => { | ||
console.log("clicked", { resolvedTheme, isDark }) | ||
setTheme(isDark ? "light" : "dark") | ||
isDark = theme === "dark" | ||
} | ||
|
||
return ( | ||
<> | ||
<label className="swap swap-rotate"> | ||
{/* this hidden checkbox controls the state */} | ||
<input | ||
type="checkbox" | ||
checked={isDark} | ||
onChange={onChange} | ||
className="theme-controller" | ||
value={resolvedTheme} | ||
/> | ||
|
||
<SunIcon className="swap-off w-4 h-4" /> | ||
|
||
<MoonIcon className="swap-on w-4 h-4" /> | ||
</label> | ||
</> | ||
) | ||
} | ||
|
||
export default ThemeToggle |
Oops, something went wrong.