Skip to content

theme adding for background #11

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"axios": "^1.7.7",
"next": "15.0.1",
"next-themes": "^0.4.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
Expand Down
46 changes: 46 additions & 0 deletions src/app/components/lightDarkModes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use client'
import React, { useState, useEffect } from "react";
import { TiWeatherSunny } from "react-icons/ti";
import { useTheme } from "next-themes";


const lightDarkModes = () => {
// const[mode, setMode] = useState<boolean>(false)
const[options, setOptions] = useState<boolean>(false)
const {theme, setTheme} = useTheme()
const [mounted, setMounted] = useState(false);

useEffect(() => {
setMounted(true);
}, []);
if (!mounted) return null;
// console.log(setTheme);
console.log("Current Theme:", theme);


// switch btwn light and dark mode
const toggleModes = () => {
setOptions(!options)
}

return (
<>
<div className="relative">
<TiWeatherSunny
className=" absolute sm:top-[-30px] right-[55px] mt-5 h-[2.5rem] w-[2.5rem] rotate-0 scale-100 transition-all border rounded-[10px] cursor-pointer"
onClick={toggleModes}
/>
{options && (
<div className="border bg-white w-[100%] sm:w-[10%] h-[100px] pt-3 pb-2 text-center flex flex-col gap-y-1 absolute right-[5px] top-[100px] sm:top-[40px] rounded-[10px] shadow-md">
<p className="cursor-pointer" onClick={() => {setTheme('light'); setOptions(false)}}>light</p>
<p className="cursor-pointer" onClick={()=> {setTheme('dark'); setOptions(false)}}>dark</p>
<p className="cursor-pointer" onClick={() => {setTheme('system'); setOptions(false)}}>system</p>
</div>)}

</div>

</>
)
}

export default lightDarkModes
Loading