@mattstuddert
Posted
Hey Shubham, nice to see you post a new solution. Where have you been learning JS? Your code looks fine, but I'd say you've over-engineered the solution in this instance. You don't need so much JS code to switch between a light and a dark theme. You can simply use it to toggle a class or HTML attribute and then use CSS custom properties to take care of the color changes.
Here's a great article that runs through this approach: https://hankchizljaw.com/wrote/create-a-user-controlled-dark-or-light-mode/
I hope this helps!
@shubhamthedev
Posted
@mattstuddert Yeah i know it's a mess but i went through others solution afterwards and found some insights into how it should be done and thanks for the link i'll go through this.
@mattstuddert
Posted
@tomboynotes no problem!