Skip to content

Commit

Permalink
dark mode is missing Devmangrani#63 Devmangrani#70
Browse files Browse the repository at this point in the history
changes done
  • Loading branch information
its-Pratik-15 authored Oct 26, 2024
1 parent d19ac4f commit 8cd6f37
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export default function NavBar() {
router.reload();
};

const toggleNightMode = () => {
setNightMode((prevMode) => !prevMode);
};

const handleClickOutside = () => {
setIsOpen(false);
};
Expand All @@ -85,22 +89,15 @@ export default function NavBar() {

return (
<>
<style>
body {
<style>
{`
body {
transition: background-color 0.5s, color 0.5s;
background-color: white; /* Day mode */
color: black; /* Day mode */
}
.night-mode {
background-color: black; /* Night mode */
color: white; /* Night mode */
}
button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
}
</style>
background-color: ${isNightMode ? "black" : "white"};
color: ${isNightMode ? "white" : "black"};
}
`}
</style>

<div
className={`w-full ${
Expand Down Expand Up @@ -227,6 +224,9 @@ export default function NavBar() {
>
SIGN IN
</Link>
<button onClick={toggleNightMode} className="ml-4">
{nightMode ? "Switch to Day Mode" : "Switch to Night Mode"}
</button>
</div>
)}
</div>
Expand Down Expand Up @@ -343,17 +343,9 @@ export default function NavBar() {
>
SIGN IN
</Link>
<button id="toggleButton">Switch to Night Mode</button>

<script>
const toggleButton = document.getElementById('toggleButton');
const body = document.body;

toggleButton.addEventListener('click', () => {
body.classList.toggle('night-mode');
toggleButton.textContent = body.classList.contains('night-mode') ? 'Switch to Day Mode' : 'Switch to Night Mode';
});
</script>
<button onClick={toggleNightMode} className="ml-4 text-xs font-semibold">
{isNightMode ? "Switch to Day Mode" : "Switch to Night Mode"}
</button>

</>
)}
Expand Down

0 comments on commit 8cd6f37

Please sign in to comment.