-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
ea34546
commit 3c13ecb
Showing
16 changed files
with
178 additions
and
76 deletions.
There are no files selected for viewing
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 } from "next-themes" | ||
|
||
|
||
const Providers = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<ThemeProvider attribute="class" enableSystem defaultTheme="system" > | ||
{ children } | ||
</ThemeProvider> | ||
) | ||
} | ||
|
||
export default Providers |
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,46 @@ | ||
'use client' | ||
|
||
import { useTheme } from "next-themes" | ||
import { MouseEventHandler, ReactNode, useEffect, useState } from "react" | ||
import { BsMoonStars, BsSun } from "react-icons/bs" | ||
import { GiStripedSun } from "react-icons/gi" | ||
|
||
type Props = { | ||
onClick?: MouseEventHandler | ||
icon?: ReactNode | ||
} | ||
|
||
const ThemeSwitchBtn = () => { | ||
const [ mounted, setMounted ] = useState(false) | ||
const { setTheme, resolvedTheme } = useTheme() | ||
|
||
useEffect(() => setMounted(true), []) | ||
|
||
if(!mounted) | ||
return ( | ||
<Button icon={ <GiStripedSun /> } /> | ||
) | ||
|
||
if(resolvedTheme === 'dark') { | ||
return ( | ||
<Button onClick={() => setTheme('light')} icon={ <BsSun /> } /> | ||
) | ||
} | ||
|
||
if(resolvedTheme === 'light') { | ||
return ( | ||
<Button onClick={() => setTheme('dark')} icon={ <BsMoonStars /> } /> | ||
) | ||
} | ||
} | ||
|
||
const Button = (props: Props) => { | ||
return ( | ||
<button onClick={ props.onClick } className=" rounded-full bg-rich-black hover:bg-electric-pink p-2 text-xl " > | ||
{ props.icon } | ||
</button> | ||
) | ||
} | ||
|
||
|
||
export default ThemeSwitchBtn |
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
Oops, something went wrong.