Skip to content

Commit

Permalink
Ensure dark mode toggle consistency of all results
Browse files Browse the repository at this point in the history
  • Loading branch information
helenclx committed Nov 8, 2023
1 parent a14dea3 commit dad09f3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Food-Recipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ if (isDarkMode === 'enabled') {
}

function toggleDarkMode() {
const result = document.querySelector('.results__result');
const modal = document.querySelector('.modal');
const modalClose = document.querySelector('.modal__close');
const results = document.querySelectorAll('.results__result');
const modal = document.querySelectorAll('.modal');
const modalClose = document.querySelectorAll('.modal__close');

body.classList.toggle('dark-mode');

Expand All @@ -31,14 +31,14 @@ function toggleDarkMode() {
localStorage.setItem('dark-mode', 'disabled');
}

if (result) {
result.classList.toggle('dark-mode');
if (results) {
results.forEach(i => i.classList.toggle('dark-mode'));
}
if (modal) {
modal.classList.toggle('dark-mode');
modal.forEach(i => i.classList.toggle('dark-mode'));
}
if (modalClose) {
modalClose.classList.toggle('dark-mode');
modalClose.forEach(i => i.classList.toggle('dark-mode'));
}
}

Expand Down

0 comments on commit dad09f3

Please sign in to comment.