Design comparison
SolutionDesign
Solution retrospective
I'm done with the frontend design together with changing of themes but I'm still having a problem with JavaScript side. I hope I can go back to this problem and finish everything to make it all working :). Please comment on how I can improve my JS programming :D Thanks everyone
Community feedback
- @renrasPosted almost 3 years ago
Keep your code dry.
In your keypad component, these buttons can be mapped instead.
const clickHandler = () => { //put logic here //use if else to add logic depending on the type of button } //render {buttons.map(button => { return ( <Button onClick={clickHandler}></Button> ) )}
// classnames
<div className={ theme === 1 ? "flex justify-center w-full h-screen theme1-bg" : theme === 2 ? "flex justify-center w-full h-screen theme2-bg" : "flex justify-center w-full h-screen theme3-bg" }>
// you can refractor this into
<div className={ `flex justify-center w-full h-screen ${themebg} `
you can make a separate state for theme-bg depending on the current theme
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