Body Mass Index calculator

Solution retrospective
Proud of:
- Using semantic HTML and following accessibility best practices in structuring the pageindex.
- Implementing a clean, component-based architecture with AlpineJS Web Componentsmain, keeping the BMI Calculator modular and reusable bmi-calculator.
- Keeping the CSS efficient and organized using Sass and leveraging Vite with PurgeCSS for optimized performance
What I’d do differently:
- Add client-side validation with visual feedback for invalid inputs.
- Improve state management and reactivity by using Alpine’s $store API instead of manual reactivity handling.
-
Preventing the browser’s autofill styles from interfering with the input fields of the bmi calculator.
-
Handling unit conversions without causing extra re-renders.
-
Ensuring only used styles are included in production builds. For this I used Vite with PurgeCSS to remove unused CSS.
-
Improving input validation: Would love feedback on better ways to validate height and weight inputs (e.g., handling extreme values gracefully).
-
Optimizing the component structure: Open to suggestions on making the BMI calculator more reusable in other projects.
-
Adding unit tests: Since there's only one standalone web component, is there an efficient way to test it without a full JS framework?
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on cepoumian's solution.
Join 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