forked from Ctoic/Lisbook
-
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.
added a toggler to all the pages to toggle between light and dark theme
- Loading branch information
Showing
5 changed files
with
366 additions
and
20 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 |
---|---|---|
|
@@ -5,8 +5,35 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <title>My Favorite Books Music App</title> | ||
<style> | ||
body.dark-theme { | ||
background-color: #333; | ||
color: #fff; | ||
} | ||
body.dark-theme .navbar { | ||
background-color: #222 !important; | ||
} | ||
body.dark-theme .btn-outline { | ||
color: #fff; | ||
border-color: #fff; | ||
} | ||
.theme-toggle { | ||
cursor: pointer; | ||
padding: 5px 10px; | ||
border-radius: 5px; | ||
transition: background-color 0.3s, color 0.3s; | ||
} | ||
.dark-theme .theme-toggle { | ||
background-color: #fff; | ||
color: #333; | ||
} | ||
.light-theme .theme-toggle { | ||
background-color: #333; | ||
color: #fff; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<body class="light-theme"> | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary"> | ||
<a class="navbar-brand" href="#">Lisbook</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
|
@@ -25,6 +52,11 @@ | |
<a class="nav-link" href="./index.html">Previous</a> | ||
</li> | ||
</ul> | ||
|
||
<button id="theme-toggle" class="btn btn-outline-light theme-toggle"> | ||
<span class="light-text">🌙</span> | ||
<span class="dark-text" style="display:none;">☀️</span> | ||
</button> | ||
</div> | ||
</nav> | ||
|
||
|
@@ -82,6 +114,26 @@ <h2>Share Your Thoughts</h2> | |
|
||
|
||
<script src="app.js"></script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const themeToggle = document.getElementById('theme-toggle'); | ||
const body = document.body; | ||
const lightText = themeToggle.querySelector('.light-text'); | ||
const darkText = themeToggle.querySelector('.dark-text'); | ||
|
||
themeToggle.addEventListener('click', function() { | ||
body.classList.toggle('dark-theme'); | ||
body.classList.toggle('light-theme'); | ||
if (body.classList.contains('dark-theme')) { | ||
lightText.style.display = 'none'; | ||
darkText.style.display = 'inline'; | ||
} else { | ||
lightText.style.display = 'inline'; | ||
darkText.style.display = 'none'; | ||
} | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
<!-- Footer --> | ||
<footer class="bg-body-tertiary text-center"> | ||
|
@@ -270,4 +322,5 @@ <h5 class="text-uppercase">Links</h5> | |
<!-- Copyright --> | ||
</footer> | ||
<!-- Footer --> | ||
</html> | ||
|
||
</html> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.