Skip to content

Commit

Permalink
Apply dark mode by checking the body
Browse files Browse the repository at this point in the history
Instead of checking the local storage, check if the body has the dark-mode class
  • Loading branch information
helenclx committed Nov 2, 2023
1 parent 6e66f32 commit 306f387
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Food-Recipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async function fetchResponses(recipeName) {
function createRecipe(displayName, img_url, video_url, description, countryTag, rating, cookTime, yields, instructionsTag, nutrition, difficultyTag) {
const box = document.createElement("div");
box.classList.add("results__result");
if (isDarkMode === 'enabled') {
if (body.classList.contains('dark-mode')) {
box.classList.add('dark-mode');
}

Expand Down Expand Up @@ -271,7 +271,7 @@ function createModal() {
const modal = document.createElement('div');
modal.classList.add('modal');
modal.classList.add('modal-active');
if (isDarkMode === 'enabled') {
if (body.classList.contains('dark-mode')) {
modal.classList.add('dark-mode');
}
return modal;
Expand All @@ -281,7 +281,7 @@ function createCloseButton() {
const close = document.createElement('button');
close.classList.add('modal__close');
close.innerHTML = '✖';
if (isDarkMode === 'enabled') {
if (body.classList.contains('dark-mode')) {
close.classList.add('dark-mode');
}
return close;
Expand Down

0 comments on commit 306f387

Please sign in to comment.