Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 11 days ago

Responsive React Mortgage Calculator

bootstrap, react, vite
Patricia Gracia•30
@Patriciagracia
A solution to the Mortgage repayment calculator challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm proud of how I handled dynamic styling using conditional className values to manage state-driven feedback. Next time, I’d like to approach the styling without relying on Bootstrap, and challenge myself to structure the layout fully with raw CSS (especially Grid and Flexbox).

What challenges did you encounter, and how did you overcome them?

One challenge was ensuring the radio button selector could be fully navigated via keyboard. Since the inputs were visually hidden for styling purposes, they initially couldn't receive focus. Another challenge was managing component-level CSS without a Figma or design spec. This pushed me to make layout and spacing decisions manually.

What specific areas of your project would you like help with?

I'm unsure about how I structured the project. Is there a better approach? For example, in a small project like this, would it be better to have a single CSS file instead of one per component?

Also, what's the best practice for handling thousands separators and decimal symbols in type="number" fields across different locales?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Andrey•4,300
    @dar-ju
    Posted 11 days ago

    Hi, Patricia!

    Great job, the design matches the layout, the calculator logic works correctly.

    About your questions:

    • you can use css here any way you like, I think that this is a single component of the page, so there should be one css file for it. At least it will make the code easier to maintain.
    • for input and result fields I used Intl.NumberFormat('en-US').format(value) - I hope this will help you

    I want to suggest you to fix something:

    • look how the fields jump when you hover over them. For class="input-group " blocks, you use 0.1px for the border, and 1px for the hover border. Change it to one of them
    • despite the fact that this is just a calculator, it is still a form with fields and a button, you need to use the <form> tag
    • for the body you added cursor: pointer; this is strange, because it is not an active element, it needs to be removed, but for radio buttons add
    • add restrictions on entering all values ​​in the fields except numbers, and also make restrictions on the minimum and maximum values. Now you can enter large values ​​and get "£NaN" as a result

    Otherwise everything is super, good luck with the development!

  • Harsh Kumar•3,310
    @thisisharsh7
    Posted 11 days ago

    Great work on your mortgage calculator! The dynamic styling with conditional className values for state-driven feedback is well-executed.

    Some suggestions:

    1. Project Structure: Using separate CSS files per component enhances modularity, which is great for larger projects. For a small project like this, a single CSS file could reduce complexity and improve maintainability. Consider consolidating styles into a single styles.css unless modularity is a priority.
    2. Locale Handling: For number formatting across locales, use Intl.NumberFormat in JavaScript. For example: new Intl.NumberFormat(navigator.language).format(number) ensures proper thousands separators and decimal symbols based on the user's locale. Apply this in your Results component for monthly and total displays.
    3. CSS Improvement: Moving away from Bootstrap is a good goal. Your use of custom properties (--clr-slate-900, etc.) is excellent. For raw CSS layouts, consider defining a display: grid container in calculator-wrapper to streamline the responsive layout without Bootstrap’s classes.
    4. Error Handling: The error validation logic is solid, but consider adding real-time validation (e.g., on blur) to improve UX.

    Overall, a strong implementation-Keep up the good work.

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub