Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Expenses Chart Component with new JSON, Dynamically Animated JS data

sass/scss
Junier Bolívar 🕷•710
@Junbol
A solution to the Expenses chart component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I finally feel that all pieces are falling in place 🧩🎉🎊 ** HTML:

  • Remember to add the tabindex="0" attribute to use :focus on css .

** css:

  • You need to grid area you containers not the items inside your containers.
 &:hover .amount,
  &:focus-within .amount {//🚩this was the solution (-within) so the amount stay in focus after click
    opacity: 1; /* Show amount on bar hover or focus */
  }

    &:hover,
  &:focus {//🚩 There was a 🐞 here: The bar was not staying in focus: Solution: added tabindex="0" attribute in the html code.
    border-radius: 5px;
    background-color: color('cyan');
  }

** JAVASCRIPT: I took the liberty to modify the data.json file to end up with a more efficient app. All was done dynamically.

  const maxAmount = expenses.reduce((max, item) => item.amount > max ? item.amount : max, 0);//🚩When you omit the curly braces, the arrow function has an implicit return, meaning it automatically returns the result of the expression without needing the return keyword.
  //max = accumulator item= currentValue

const totalAmountSpent = expenses.reduce((accumulator, item) => accumulator + item.amount, 0); // 0 is the initial value

const barGrpElement = barElement.parentElement;//🚩the se of parentElement was the 🗝️ here
What challenges did you encounter, and how did you overcome them?

same as above

What specific areas of your project would you like help with?

none

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Junier Bolívar 🕷's solution.

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
  • Use cases

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