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
- Bonus: See the age numbers animate to their final number when the form is submitted
- Solution URL: solution URL
- Live Site URL: live site URL
- Vue.js - JS Library
- Vite.js - JS Library for Front-end tooling
- CSS custom properties
- Flexbox
- Mobile-first workflow
This project allowed me to recap on how to pass properties between components in order to display by dealing with the Vue Composition API which is an API featured in Vue.js and is a set of APIs that allows us to author Vue components using imported functions instead of declaring options. By using the Composition API it allowed me to pass the properties and validate them before passing them. I also found that validating the dates of each month by using the array syntax was great as it allowed me to double check the input separately in a different method than checking if it's null or not by looping through the day properties.
var daysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
daysInMonths[1] = 29;
}
if(month < 1 || month > 12 || day < 1 || day > daysInMonths[month - 1]) {
return false;
}
- CSS Box Shadow - This helped me for the form as it made it more obvious instead of having a plain white background.
- JS Date Validation - This allowed me to validate any dates from the user through JavaScript and handle any Errors.
- GSAP Animation - This provided me with some guidance on how to install gsap in my vue project and set it up with the required animation.
- Website - Joshua Campbell
- Frontend Mentor - @jcampb98
- LinkedIn - Joshua Campbell
- GitHub - @jcampb98