Design comparison
Solution retrospective
I had so much fun doing this project I'll appreciate any suggestion to make my code better :)
Community feedback
- @coderdanniePosted over 1 year ago
Hi. Congrats on the completion of this project. An extra features you can add is to store the themes state using browser localstorage so that your site can maintain the theme state even if the page was reload. Right now if I switch to light mode and reload the web page its switching back to the default theme. Using browser storage to store the theme and accessing the themes based on user preference will prevent this from happening. https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Marked as helpful2 - @DXXDLYPosted over 1 year ago
Great work!
Here are some changes to your code
1.Because the trans() function is called on both light and dark mode, you can move it outside the change event to avoid code duplication.
2.Use more descriptive names: Variable and function names should reflect their purpose. For example, instead of trans(), you can use addTransitionClass()
3.Use const instead of let for constant variables: The checkbox variable does not change after initialization, so it can be declared with const
Hope you find this feedback helpful!
Marked as helpful0
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