@B1N4R1
Posted
Hi Matheus, your solution looks great! Nice work!
One way to optimize your JS would be by handling 99% of the theme toggle with CSS instead of manually changing the value of each element with javascript. So you could do this:
- Define three name classes for the
body
such as theme-1, theme-2, theme-3. - Once that's done you could do something like this:
body.theme-1{ (theme-1 color variables here) } body.theme-2{ (same variable names but theme-2 color values) } body.theme-3{ (same variable names but theme-3 color values) }
- After this you could use a little JS trigger to change the body's classname to one of the three classnames defined before.
You can see my solution for a live example of this approach.
This is just optional and if you are happy with your approach then go on with it but I saw this and I wanted to let you know there is actually a very easy way to do it with CSS and lightweight JS script.
Anyway, nice solution and keep on the good work!!
Cheers!