-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
74 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import Head from 'next/head' | ||
import { FaMoon, FaSun } from "react-icons/fa"; | ||
import colors from "../tailwind.config"; | ||
|
||
export default function ThemeWrapper({ children }) { | ||
const [theme, settheme] = useState<"sivert_dark" | "sivert_light">( | ||
"sivert_dark" | ||
); | ||
useEffect(() => { | ||
const localTheme = localStorage.getItem("theme"); | ||
if (theme) settheme(localTheme as typeof theme); | ||
}, []); | ||
|
||
useEffect(() => { | ||
localStorage.setItem("theme", theme); | ||
}, [theme]); | ||
return ( | ||
<> | ||
<Head> | ||
<meta | ||
name="theme-color" | ||
content={ | ||
theme === "sivert_dark" | ||
? colors.daisyui.themes[0].sivert_dark["base-100"] | ||
: colors.daisyui.themes[0].sivert_light["base-100"] | ||
} | ||
/> | ||
</Head> | ||
<div data-theme={theme} | ||
className="overflow-y-scroll h-screen scroll-smooth bg-base-200 text-base-content transition-none"> | ||
<button | ||
onClick={() => | ||
settheme(theme === "sivert_dark" ? "sivert_light" : "sivert_dark") | ||
} | ||
className="btn btn-circle btn-ghost fixed bottom-8 right-8" | ||
> | ||
{theme === "sivert_dark" ? <FaMoon /> : <FaSun />} | ||
</button> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
} |
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
2de5a4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sivert-blog – ./
sivert-blog-git-main-gryt.vercel.app
blog.sivert.io
sivert-blog-gryt.vercel.app
blog-neon-rho-79.vercel.app