This is a solution to the Tip calculator app challenge on Frontend Mentor.
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
- Calculate the correct tip and total cost of the bill per person
- Solution URL: https://splitter-tipcalculator.netlify.app/
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
- React - JS library
- Sass - For styles
- Provider Pattern
This project give me the opportunity to keep learning about Sass. This technology let you nest and write responsive css in a really practical way.
.tip_section {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: baseline;
min-width: 100%;
&_options {
display: flex;
justify-content: space-between;
width: 100%;
&_label {
width: 30%;
padding: 4px 0px;
color: $white;
background-color: $veryDarkCyan;
border-radius: 5px;
margin: 5px 0px;
font-size: 18.5px;
letter-spacing: 1.5px;
cursor: pointer;
@include breakpoints(sm) {
font-size: 24px;
}
}
}
}
Handling forms has become easier thanks to ES6 syntax.
const handleBlur = (event) => {
event.target.value === null ||
event.target.value === "" ||
event.target.value < 1
? setErrors({
...errors,
[event.target.name]: "Can't be zero",
})
: setErrors({
...errors,
[event.target.name]: null,
});
};
const handleChange = (event) => {
setData({
...data,
[event.target.name]: event.target.value,
});
};
For my next project I would like to divide the logic in differents files and use Typescript.
- Function onChange and onBlur - This is an amazing article which let me reduce code. This funcion helped me listening to changes in all inputs instead of making a function for every one of them.
- Frontend Mentor - @ramirezandradesara
- Linkedin - Sara Ramírez