Skip to content

Commit

Permalink
Merge pull request #85 from meghanakn473/main
Browse files Browse the repository at this point in the history
dark mode feature (issue#13)
  • Loading branch information
GarimaSingh0109 authored Oct 2, 2024
2 parents cfdb173 + 436ed9c commit da240a0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

<link rel="stylesheet" href="style.css">
<style>
<label for="dark-mode-toggle">
<input type="checkbox" id="dark-mode-toggle" />
Toggle Dark Mode
</label>

/* Features Section */
.features {
Expand Down Expand Up @@ -398,4 +402,4 @@ <h3>Connect With Us</h3>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
</html>
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const toggleSwitch = document.getElementById('dark-mode-toggle');

// Check for saved user preference in local storage
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;

if (currentTheme) {
document.body.classList.toggle('dark-mode', currentTheme === 'dark');
toggleSwitch.checked = currentTheme === 'dark';
}

toggleSwitch.addEventListener('change', () => {
document.body.classList.toggle('dark-mode');
// Save preference to local storage
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('theme', 'dark');
} else {
localStorage.setItem('theme', 'light');
}
});
21 changes: 20 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ header .fa-bars{
border: .1rem solid rgba(0,0,0,0.3);
display: none;
}
/* Default light mode styles */
body {
background-color: #ffffff;
color: #000000;
}

/* Dark mode styles */
.dark-mode {
background-color: #121212;
color: #ffffff;
}

.dark-mode button {
background-color: #1e1e1e;
color: #ffffff;
}

/* Add more styles as needed for other elements */


.home{
display: flex;
Expand Down Expand Up @@ -229,4 +248,4 @@ header .fa-bars{
font-size: 3rem;
}

}
}

0 comments on commit da240a0

Please sign in to comment.