Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 4 years ago

๐ŸงฎTip Calculator | HTML, CSS | Javascript | Anime.js | Webpack

buneeโ€ข2,020
@buneeIsSlo
A solution to the Tip calculator app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


๐Ÿ˜ฌYikes! did this challenge take me a long time to complete... Glad to be finally done with it.

Acknowledgment

First off, I'd like to thank @tediko for writing code that's clean and comprehensive. I spent a lot of time studying his Solution to the Calculator app by FEM. This solution forced me to learn a lot of new technologies and concepts that I found extremely helpful.

Secondly, I want thank @Syafiqjos. I found a very useful way to limit user input from his Solution.

Some not so necessary Features

  • Added a punny intro animation
  • Flipped some colours around and added a dark theme mode
  • A toggle button to switch between the two theme modes

Questions

  • What tag would be more appropriate for the intro element in my markup?
  • I'd like to know your thoughts on my javascript code, I found it a bit challenging to stick to the DRY principle.
  • I'm fairly new to webpack, so I'd appreciate it if you could give some tips on writing a better config file.

Click here to view the Live Site

Click here to view the Code

P.S. If you have any questions for me, Please feel free to message me on slack :)

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Raymart Pamplonaโ€ข16,040
    @pikapikamart
    Posted almost 4 years ago

    Hey, awesome work on this one. That animation is cool to be honest, haven't seen anything like that so great. The layout in desktop looks great as well and the mobile layout is great as well.

    • For the tag, it is fine to use header on this one since it contains the website's logo.
    • For javascript, I don't really dive into js when reviewing a site, unless there is a specific question about how they used js or a part.
    • I haven't use webpack:>

    Some other suggestions would be:

    • I would rather use img instead of object, if there are element that do a specific task that you want to do, use that element.
    • if that were an img, you need to use alt="splitter" , a website logo should be named as the website's name. I haven't use object to be honest, but using aria-label="logo" for the logo is not good. Avoid using words that relates to "graphic" such as "logo, icon, image.." when describing an image, since it is already one.
    • Theme toggle should be using button so that it will be more explicit instead of using div with tabindex.
    • If you are going to build a color theme, using input type="radio" are the ones that you should use. Since it is a selection, radio buttons are intended for those. Those radio button should be inside a fieldset along with a legend which can be hidden or not, depending on the design. Using this kind of structure, it is more accessible for all users. Have a look at my sample snippet about using radio buttons.
    • svg on the theme toggler should be hidden so use aria-hidden="true" on it, if you are using an svg and it is meaningful, use an title element inside the svg along with an sr-only class on it.
    • You don't need to use aria-label on the bill input since it already uses a label associated with it.
    • Using label that associates with a div will not work. So this element <label for="input--percentage" calss="input__label">Select Tip %</label> won't work since it points to a container div. label are for input.
    • No need for aria-label for each button since the text select tip 5 gives the overview of what the button will do. But to be honest, I won't use button for this, instead I will use input type="radio" inside of a fieldset since button alone is not accessible, unless you make like an aria-live element, that announces that the button has been selected or pressed.
    • Again, aria-label not needed for the next input which is the number of person.
    • Using ::after to hold the can't be zero is not accessible for NOT sighted users, since there will be no text-content that their assistive tech will read. It would be great to make use of a span for example. The span will contain the error-message and it will have an id attribute. The id will be referenced by the input element, if the input is wrong, that is where you add aria-describedBy attribute on the input and the value of that attribute, will be the id of the error-message. This way, users will know what kind of error they had made. Also, when the input is wrong, add an aria-invalid="true" attribute on it, so that users will know their input is wrong.
    • Avoid using multiple h1 on a single page. On the result section, you don't need h1 or heading tag to wrap the result of the calculator. The result will be better to just use p tag, since the Tip Amount is already a heading, giving overview on what the section will contain.
    • An addition as well, for the reset button, creating an aria-live element, that announces the calculator has reset. Since button does not inform that much, you kind of uses this kind of methods to inform users.

    Aside from those, great work again on this one.

    Marked as helpful
  • Ctrl+FJโ€ข810
    @FlorianJourde
    Posted over 3 years ago

    A piece of art !

  • Paras Sharmaโ€ข700
    @imparassharma
    Posted almost 4 years ago

    I was looking to your code and saw that you never use height. I mean how ...for the main container I have to define some height because without it then I cannot design my inner components accordingly. So can you tell me should I use vh in my body or main containers? Or how to proceed? https://imparassharma.github.io/Price-Component-Toggle-sections-/

    This was the last project I did on frontendmentor but took me a lot time to adjust heights for 1440px dimension. Can you help me!

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
ยฉ Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! ๐Ÿ˜ฌ

You need to be logged in before you can do that.

Log in with GitHub

Oops! ๐Ÿ˜ฌ

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up โ€œinvalidโ€ attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although theyโ€™re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! ๐Ÿ˜ฌ

You need to be logged in before you can do that.

Log in with GitHub

Oops! ๐Ÿ˜ฌ

You need to be logged in before you can do that.

Log in with GitHub

Oops! ๐Ÿ˜ฌ

You need to be logged in before you can do that.

Log in with GitHub