Design comparison
Solution retrospective
Hello, this is my submission for the tip calculator. This has been my toughest yet as it has to do with a lot of javascript. I have some issues with changing the button styles when they are selected, and also the styles for the reset button when its disabled. other than that, everything works. I would love to hear your input and would love to hear feedback on where i can improve.
Community feedback
- @ZukizukPosted 10 months ago
Hello @Senibo
Your solution looks great!
I have few suggestions on what you asked of that might be of help to you:
First of all concerning the button, you can use JS to add a class to the button that was last clicked for example
const buttons = document.querySelectorAll('.myButton'); buttons.forEach(button => { button.addEventListener('click', function() { buttons.forEach(btn => btn.classList.remove('clicked')); this.classList.add('clicked'); }); });
You can add the clicked class to the button which was clicked and remove it from the previously clicked button with the JS provided above. So all you have to do is to set your stylings for when the button is clicked and when it's not clicked
Also with the reset button you can consider using a psuedo-element like
::before and ::after
to cover the reset button fully and make it appear only when it's needed like with the button example above. You can use opacity to adjust the color to make it disabled like the one in the design just don't forget to make the psuedo element bg-color the bg-color of the reset button and make it kinda see through with opacityI hope it helps!
Other than that, great job!
Marked as helpful2
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