Design comparison
Solution retrospective
Hello!
Well, I've spent a few days in this one fixing js and logic, but this time I guess it is good!
I hope you enjoy it!
Regards!
Community feedback
- @correlucasPosted over 2 years ago
👾Fala Anderson, tudo bem? Parabéns pelo desafio!
Acabei de ver seu desafio e está funcionando perfeitamente. Uma coisa que eu vi e me chamou a atenção foi a sombra que está um pouco forte, você pode melhorar isso colocando menos
opacity
e maisblur
, aqui um valor bom pra essa sombra:box-shadow: 5px 5px 15px 5px rgb(0 0 0 / 5%);
Um jeito rápido de fazer o design das sombras e depois so copiar e colocar o código é usando alguns sites pra fazer a sombra sem tocar no código, eu gosto mto desse e pode ser util pra vc: https://www.cssmatic.com/box-shadow
👋 Espero ter ajudado e continue no foco!
Marked as helpful0@andykallianPosted over 2 years ago@correlucas muito obrigado pelas sugestões Lucas! Sucesso sempre!
1 - @ErayBarslanPosted over 2 years ago
Hey there and nice work! To achieve what you want you can use
addEventListener
to fire on input change withkeyup
(applies after pressing a key) and call your calculation function inside the listener like:document.querySelector("#custom").addEventListener("keyup", function(e) { let percentage = (billValue * Number(e.target.value)) // rest of function ... }
You can name e whatever you want and it basically selects the element
#custom
and target.value gets us the input value.Additional Suggestions:
- You can write one function with parameter instead several functions for each button like
fivePercent() , tenPercent(), ...
:
calculateTip(percent) { let percentage = (billValue * percent) ... rest of function }
As only percent value changes for each button, you can call the same function for different buttons and just change the parameter percent.
- It would be better to use .toFixed() method on amount. On certain outputs value overflows out of calculator on screen.
- You can use focus selector with CSS to apply when clicked the button, so user can visually see which calculation was done like:
button:focus {style}
Marked as helpful0@andykallianPosted over 2 years ago@ErayBarslan iM very gratefull for your comments! Thankyou!!
1 - You can write one function with parameter instead several functions for each button like
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