Skip to content

JulioCinquina/fem-interactive-rating-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - Interactive rating component solution

This is a solution to the Interactive rating component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

This project features an interactive component made using CSS Grid and Flexbox, with state changes via JavaScript DOM manipulation, and nice transitions between states made with CSS animations.

Overview

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Select and submit a number rating
  • See the "Thank you" card state after submitting a rating

Links

Screenshots

Survey state Thank you state Demonstration
Survey state of the component Thank you state of the component GIF demonstrating the use of the component

My process

What I learned

In this project, I have practiced the following skills:

  • Using JavaScript for client-side form validation and DOM manipulation
  • Using modern JavaScript features, such as optional chaining (?.)
  • Accessibility: directing screen reader focus after a state change
  • Accessibility: using the aria-live attribute and the prefers-reduced-motion media query
  • Using Grid, Flexbox and media queries
  • Creating CSS animations
  • Working with CSS Masking
  • Using CSS relative units to ensure the page scales according to the user's font size settings
  • Using CSS custom properties to allow easy customization and reusability of components
  • Using Git and GitHub

DOM manipulation: changing content without leaving the page

The rating component has two states, both of which are <div>s inside the <main> element: survey, containing the survey form, and thank you, containing a thank you message and the selected value. When the form is submitted, JavaScript is used to perform form validation and DOM manipulation, changing the document to:

  • Show an error message if no value was selected
  • Play CSS animations
  • Hide the survey state
  • Set the confirmation message: You selected X out of 5
  • Display the thank you state

Accessibility: directing screen reader focus

Part of my process in every Frontend Mentor challenge is testing my solutions with screen readers. In this one, the state change presented an issue: after clicking "submit", screen readers would not start reading the newly displayed content of the thank you state. To fix that, the focus() method was used inside the displayThanks function to direct focus to the top element of the thank you state after displaying it: ratingEl.focus();.

Two other accessibility aspects that were implemented in this project are the following:

  • Using aria-live="polite" to ensure the error message is announced by screen readers when the form is submitted with no value selected.
  • Using the prefers-reduced-motion media query to disable all animations and transitions if the user prefers reduced motion.

Continued development

To further develop this project, I would like to learn how to send the collected data to a back end using JavaScript, without leaving the page, and also about creating the back end itself to receive, process and store the data. Besides that, I really enjoyed creating the CSS animations in this project, and I want to keep learning how to use them to create interesting interfaces and experiences.

Useful resources

Author

About

An interactive rating component from Frontend Mentor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published