woroodfathiassi / Light-Dark-Mode

This is a simple application to switch a page's theme between Light and Dark modes.
2 stars 0 forks source link

toggleClass calls redundant: refactor CSS to only require <body> tag class toggle #4

Open nasser-codes opened 1 month ago

nasser-codes commented 1 month ago

https://github.com/woroodfathiassi/Light-Dark-Mode/blob/f84c1846c5d49752e714432ee92f6200fc213381/main.js#L7

because each element is styled differently in dark mode, you are forced to call toggleClass for each individual element. Refactor CSS from patterns like:

header.dark-mode

to

.dark-mode header

and apply the style to only the <body> tag.

woroodfathiassi commented 1 month ago

Thank you for this observation.