Open will1858 opened 5 years ago
Hi @will1858, this project rocks! 🤘 Your code looks and works great.
I have one recommendation: would you mind replacing the last else if
on lines 20 and 31 to an else
? This will provide a general catch-all so that no matter what value is in localStorage
, you will always show either a day or night mode.
Comment back after that change and I'll take a quick look! 👏
done
Awesome, all your bases are covered! The button works, and when I load the page it shows the last theme saved and the page count. Nice work here! 🎸 :shipit:
Build a website that allows the user to switch between day and night color themes and remembers their choice
@egillespie Can you take a look at this? It's hosted here and meets the following criteria:
body
element is always up-to-date with the current theme (eitherday-theme
ornight-theme
) -- you can usedocument.body.setAttribute('class', 'some-class-name')
to set the class on thebody
1
the first time)localStorage
night-theme
, the background of the website is a very dark color, with a lighter color for the textday-theme
, the background of the website is light-colored, with a darker color for the text