-
Notifications
You must be signed in to change notification settings - Fork 65
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 #57 from T-Rahul-prabhu-38/main
dark mode added✨
- Loading branch information
Showing
3 changed files
with
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const checkbox = document.getElementById('checkbox') | ||
const modeLabel = document.getElementById('mode-label') | ||
|
||
// Check if dark mode is already enabled | ||
if (localStorage.getItem('theme') === 'dark') { | ||
document.documentElement.setAttribute('data-theme', 'dark') | ||
checkbox.checked = true | ||
modeLabel.textContent = 'Dark Mode' | ||
} | ||
|
||
// Add event listener for toggle switch | ||
checkbox.addEventListener('change', () => { | ||
if (checkbox.checked) { | ||
document.documentElement.setAttribute('data-theme', 'dark') | ||
localStorage.setItem('theme', 'dark') | ||
modeLabel.textContent = 'Dark Mode' | ||
} else { | ||
document.documentElement.setAttribute('data-theme', 'light') | ||
localStorage.setItem('theme', 'light') | ||
modeLabel.textContent = 'Light Mode' | ||
} | ||
}) | ||
|
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 |
---|---|---|
|
@@ -95,6 +95,13 @@ | |
</li> | ||
</ul> | ||
</div> | ||
<div class="theme-switch-wrapper"> | ||
<label class="theme-switch" for="checkbox"> | ||
<input type="checkbox" id="checkbox"> | ||
<div class="slider"></div> | ||
</label> | ||
<span id="mode-label">Light Mode</span> | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
|
@@ -453,6 +460,7 @@ <h5 class="heading-secondary heading-secondary--semi-bold heading-secondary--whi | |
</script> | ||
<script src="js/external.js"></script> | ||
<script src="js/index.js"></script> | ||
<script src="darkMode.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script> | ||
<script> | ||
AOS.init(); | ||
|
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