-
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.
Merge pull request #6 from arayavalencia96/feature/MEMO-6-change-theme
feature/MEMO-6-change-theme
- Loading branch information
Showing
12 changed files
with
131 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,16 @@ | ||
/** | ||
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful | ||
* for Docker builds. | ||
*/ | ||
await import("./src/env.mjs"); | ||
|
||
/** @type {import("next").NextConfig} */ | ||
|
||
const config = { | ||
reactStrictMode: true, | ||
|
||
/** | ||
* If you have `experimental: { appDir: true }` set, then you must comment the below `i18n` config | ||
* out. | ||
* | ||
* @see https://github.com/vercel/next.js/issues/41980 | ||
*/ | ||
i18n: { | ||
locales: ["en"], | ||
defaultLocale: "en", | ||
}, | ||
images: { | ||
domains: ["lh3.googleusercontent.com", "avatars.githubusercontent.com"], | ||
}, | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
import { useEffect, useState } from "react"; | ||
import { getThemeFromCookie, setThemeToCookie } from "../utils/cookie"; | ||
import { FaGlasses } from "react-icons/fa"; | ||
|
||
const SelectTheme = () => { | ||
const [selectedTheme, setSelectedTheme] = useState<string>( | ||
getThemeFromCookie() | ||
); | ||
const [dropdownOpen, setDropdownOpen] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
document.documentElement.setAttribute("data-theme", selectedTheme); | ||
setThemeToCookie(selectedTheme); | ||
}, [selectedTheme]); | ||
|
||
const handleChangeTheme = (theme: string) => { | ||
setSelectedTheme(theme); | ||
}; | ||
|
||
const toggleDropdown = () => { | ||
setDropdownOpen(!dropdownOpen); | ||
}; | ||
|
||
return ( | ||
<details className={`dropdown mr-3 ${dropdownOpen ? "open" : ""}`}> | ||
<summary | ||
className="btn" | ||
onClick={toggleDropdown} | ||
aria-label="Toggle Dropdown" | ||
> | ||
<FaGlasses /> | ||
</summary> | ||
<ul className="w-30 menu dropdown-content rounded-box right-0 z-[1] bg-base-100 p-2 shadow"> | ||
<li> | ||
<a onClick={() => handleChangeTheme("light")}>Light Theme</a> | ||
</li> | ||
<li> | ||
<a onClick={() => handleChangeTheme("dark")}>Dark Theme</a> | ||
</li> | ||
<li> | ||
<a onClick={() => handleChangeTheme("cupcake")}>Cupcake Theme</a> | ||
</li> | ||
<li> | ||
<a onClick={() => handleChangeTheme("retro")}>Retro Theme</a> | ||
</li> | ||
</ul> | ||
</details> | ||
); | ||
}; | ||
|
||
export default SelectTheme; |
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,9 @@ | ||
import Cookies from "js-cookie"; | ||
|
||
export const getThemeFromCookie = (): string => { | ||
return Cookies.get("theme") || "light"; | ||
}; | ||
|
||
export const setThemeToCookie = (theme: string): void => { | ||
Cookies.set("theme", theme, { expires: 365 }); | ||
}; |
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