Skip to content

SymonMuchemi/age-calculator-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Age calculator app solution

This is a solution to the Age calculator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View an age in years, months, and days after submitting a valid date through the form
  • Receive validation errors if:
    • Any field is empty when the form is submitted
    • The day number is not between 1-31
    • The month number is not between 1-12
    • The year is in the future
    • The date is invalid e.g. 31/04/1991 (there are 30 days in April)
  • View the optimal layout for the interface depending on their device's screen size
  • See hover and focus states for all interactive elements on the page

Screenshot

Desktop Preview

Valid inputs

Error state (empty inputs)

Error state (invalid input)

Mobile

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • CSS Grid
  • Mobile-first workflow

What I learned

I learned about gaps; they are used to add spaces between elements. I also learnt how to remove the scroll bar on an input type number HTML element.

  1. css gaps
 <div class="inputs">
  <div class="day-input">
    <label>
      <p class="label-text" id="day-label">Day</p>
      <input type="number" id="day" placeholder="DD">
    </label>
    <p class="error" id="day-error" style="display: none">This field is required</p>
  </div>
  <div class="month-input">
    <label>
      <p class="label-text" id="month-label">Month</p>
      <input type="number" id="month" placeholder="MM">
    </label>
    <p class="error" id="month-error" style="display: none"><small>This field is required</small></p>
  </div>
  <div class="year-input">
    <label>
      <p class="label-text" id="year-label">Year </p>
      <input type="number" id="year" placeholder="YY">
    </label>
    <p class="error" id="year-error" style="display: none">This field is required</p>
  </div>
</div>
<style>
.inputs{
  display: flex;
  flex-direction: row;
  font-size: 15px;
  gap: 20px;
}
</style>
  1. Removing scroll bar on html input type number element
<style>
  .inputs input{
    -moz-appearance: textfield;
  } /*For chrome browser*/
  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }/*for firefox browser*/
</style>

If you want more help with writing markdown, we'd recommend checking out The Markdown Guide to learn more.

Continued development

Use this section to outline areas that you want to continue focusing on in future projects. These could be concepts you're still not completely comfortable with or techniques you found useful that you want to refine and perfect.

Useful resources

  • openAI - This helped me in removing the HTML input type number scroll bar
  • w3schools - This site acted as a refresher to me. I'd recommend it to anyone still learning this concept.

Author

Acknowledgments

I would like to thank the frontend mentor community for the task. It has been fun coding and learning how to solve it.