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

Time Tracking Dashboard

Anderson Vianna•240
@andykallian
A solution to the Time tracking dashboard challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello there!

well, that one really was a good way to practice how to consuming an API. I decided to upload Json file in Amazon Web Server and use it with FECTH as we do with an API.

Besides that, i was able to use for first time grid layout in a project. Before that, all i knew about grid layout was theoretical. And I'm still learning it!

I guess the result are good. BUT, there are 2 things I would like some sugestions

first one: I sense that in "addEventListenner" i could have used some loop in it. The question is: how?

second one: In grid css, how can I set a fixed width in the squares (cause when renderizing new data, the square's width seems to adapt and i don't want it. I want a fixed width.

any suggestion?

in time, regards and I hope you all enjoy it!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • David•7,960
    @DavidMorgade
    Posted almost 3 years ago

    Hello anderson, congrats on finishing the challenge!

    Just a little suggestion, you don't need to upload your data to any service if you want to practice your fetch() function, you can fetch local json files just using the relative path of the file in your project folder, it will get the same results as uploading it on a server, and it will need the same syntax to get the data with fetch, the only thing that will change is the url path of the file.

    Marked as helpful
  • Elaine•11,360
    @elaineleung
    Posted almost 3 years ago

    Hi Anderson, I think this was very well done! Your component is responsive, and it looks close to the design; I probably would add a bit of margin/padding around it so that when the browser width shrinks, the sides won't be touching the browser. Also, the "previous" labels on cards probably should reflect that timeframe instead of having "Last Week" for all of them. Other than that, everything looks alright to me 😊

    About your question regarding the addEventListener, you can use a forEach method to iterate through the data. A few things I'd do differently to set this up:

    I would assign different variables, where instead of having the 2 separate "current" and "previous" stats, I'd just call their parent card, which means I'd add a class name or id to the card that's more easily recognizable (I'm using stats-card in this example). The code would look something like this:

    const cardsEls = document.querySelectorAll(".stats-card");
    const daily = document.querySelector("#daily")
    const weekly = document.querySelector("#weekly")
    const monthly = document.querySelector("#monthly")
    
    fetch({your url})
        .then((response) =>{
            return response.json()
        }).then((data) =>{
    
       daily.addEventListener("click", function(){
          cardsEls.forEach( (card, idx) => {
             const statsNow = card.querySelector(".stats-now");
             const statsPrev = card.querySelector(".stats-prev");
             statsNow.textContent = `${data[idx].timeframes.daily.current}hrs`
             statsPrev.textContent = `Yesterday - ${data[idx].timeframes.daily.previous}hrs`
           })
        })
    
       // rest of your code
    

    There's a way to also iterate through the 3 timeframe elements, but I think this is good enough for now, and if you want to check that out, you can have a look at my solution: https://www.frontendmentor.io/solutions/responsive-dashboard-using-scss-and-vanilla-javascipt-with-json--HVkNhdtJT

    Hope this helps you out!

    Marked as helpful
  • Rashwan-Mohamed•340
    @Rashwan-Mohamed
    Posted almost 3 years ago

    Hello Anderson , well done finishing the project, just continue to increase you skills since its the only way to do so, I've gone through your Js logic and I see although the approach is working isn't a good practice, I would urge you to go to the solutions and pick an expert solution and examine his js file, regarding the fixed grid column you wouldn't use a grid area in this case, if you want a fixed width for the column you would use something like this grid-templete-columns:40px 40px 40px, more important that this the js logic make sure it never has a lot of repeating lines, don't continue just search for a better approach, there is a YouTube channel with the name of code addict this man creates a lot of projects using js I would recommend it, best luck (:

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
Frontend Mentor logo

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