DEV Community

Discussion on: Simple Dark-Light theme with VanillaJs

Collapse
 
casiimir profile image
casiimir • Edited

Nice done, I love it!
Can I suggest three more lines of javascript? :D

...
let isLight = true;
...

function modeSwitch() {
...
  isLight = !isLight;
  isLight ? toggle.innerText = "🌞" : toggle.innerText = "🌚";
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
vaishnavs profile image
Vaishnav

Hey. I updated pen according to your suggestions. Thanks 🤩.

Collapse
 
casiimir profile image
casiimir • Edited

Really? I'm honored! :D

Thread Thread
 
vaishnavs profile image
Vaishnav • Edited

Yep. I'm still learning and I love to share what learned hoping it would be helpful for someone.😄

Thread Thread
 
casiimir profile image
casiimir

Me too, same story!
Nice website, I like it. Do you like something about my repos? :D

Thread Thread
 
vaishnavs profile image
Vaishnav

I checked repos... You have awesome portfolio 🔥.

Thread Thread
 
casiimir profile image
casiimir

I really appreciate it! :D

Collapse
 
sshymko profile image
Sergii Shymko • Edited

The ternary expression can be simplified to the following:

toggle.innerText = isLight ? "🌞" : "🌚"
Enter fullscreen mode Exit fullscreen mode