Skip to content

Commit

Permalink
Added Theme Color Text
Browse files Browse the repository at this point in the history
  • Loading branch information
CohPhol committed Sep 27, 2024
1 parent 39a2738 commit a0c25a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions assets/js/color-mode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const themeSwitch = document.getElementById('theme-switch');
const themeText = document.getElementById('theme-color');
const body = document.body;

themeSwitch.addEventListener('change', function () {
if (themeSwitch.checked) {

body.classList.remove('light-mode');
body.classList.add('dark-mode');
themeText.textContent = 'Dark';
body.style.backgroundColor = '#333333';
cards.forEach(card => {
card.classList.remove('light-mode');
Expand All @@ -15,6 +17,7 @@ themeSwitch.addEventListener('change', function () {

body.classList.remove('dark-mode');
body.classList.add('light-mode');
themeText.textContent = 'Light';
body.style.backgroundColor = '#ffffff';
cards.forEach(card => {
card.classList.remove('dark-mode');
Expand Down
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ <h5 class="card-title">Card 6</h5>
</div>
</div>
<div class="card light-mode" draggable="true">
<div class="theme-toggle">
<input type="checkbox" id="theme-switch">
<label for="theme-switch" class="switch"></label>
<div class="card-body">
<h5 class="card-title" id="theme-color">Light</h5>
<div class="theme-toggle">
<input type="checkbox" id="theme-switch">
<label for="theme-switch" class="switch"></label>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit a0c25a4

Please sign in to comment.