Maded using pure css and javascript
Design comparison
Solution retrospective
Do you think I could optimize my javascrpt code? Let me notice.
Community feedback
- @B1N4R1Posted over 3 years ago
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!
0 - Define three name classes for the
- @palgrammingPosted over 3 years ago
well the first thing I see is you need to limit your use of the "." so it can only be entered once per complete number entry but it is a complicated project and you have a good start to it
1@matheus-rodrigues00Posted over 3 years ago@palgramming Thanks pal, note taken.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord