GithubHelp home page GithubHelp logo

ramirezandradesara / splitter-tip-calculator-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 838 KB

Challenge from frontendmentor.io

Home Page: https://splitter-tipcalculator.netlify.app/

HTML 4.84% JavaScript 53.75% SCSS 41.41%
provider-pattern react sass

splitter-tip-calculator-app's Introduction

Frontend Mentor - Tip calculator app solution

This is a solution to the Tip calculator app challenge on Frontend Mentor.

Table of contents

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
  • Calculate the correct tip and total cost of the bill per person

Screenshot

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow
  • React - JS library
  • Sass - For styles
  • Provider Pattern

What I learned

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,
  });
};

Continued development

For my next project I would like to divide the logic in differents files and use Typescript.

Useful resources

  • 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.

Author

splitter-tip-calculator-app's People

Contributors

ramirezandradesara avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.