Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 2 months ago

Responsive Time Tracking Dashboard with Data Fetching

P
Schindler Dumagat•340
@schindlerdumagat
A solution to the Time tracking dashboard 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?

By building this project, I was able to learn how to fetch data from an external source and display them in the page. I learned how to handle asynchronous task like fetching data. Additionally, I improved my HTML and CSS skills.

What challenges did you encounter, and how did you overcome them?

One of the challenges I encountered is how I can fetch the data from a file and then display it in the page. So, I read some articles and check their examples. Afterwards, I was able to come up with an idea on how to that and I implemented it in my code. Though it works, I am not certain that it was the best approach for this project. I believe their are more better solutions than mine.

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

Though I was able to finish the project, I still have doubts on my solution, here are my list of concerns:

  • What is the best way to render the data from the file?

In my case, I created all the elements of the report cards for each statistics data in my HTML file and just select all the elements that I want to fill some data in my JavaScript file.

My report card HTML looks like these:

<div class="report__card report__card--orange">
          <img class="report__card-logo" src="./images/icon-work.svg" alt="" />
          <div class="report__card-content">
            <div class="report__card-header">
              <h3 class="report__card-title">Work</h3>
              <button class="report__card-btn">
                <svg width="21" height="5" xmlns="http://www.w3.org/2000/svg">
                  <path
                    d="M2.5 0a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5Zm8 0a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5Zm8 0a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5Z"
                    fill-rule="evenodd"
                  />
                </svg>
              </button>
            </div>
            <div class="report__card-body">
              <time class="report__current" datetime=""></time>
              <p class="report__previous"></p>
            </div>
          </div>
        </div>

Here is my JavaScript for selecting the necessary elements for editing:

const reportCards = document.querySelectorAll(".report__card");
const editableElements = [...reportCards].map(reportCard => {
    const reportTitle = reportCard.querySelector(".report__card-title");
    const reportCurrent = reportCard.querySelector(".report__current");
    const reportPrevious = reportCard.querySelector(".report__previous");

    return {
        reportTitle: reportTitle, 
        reportCurrent: reportCurrent,
        reportPrevious: reportPrevious,
    }
})
  • Should I create the report card elements in my JavaScript file after fetching the data instead of directly creating placeholder elements in my HTML file and then just selecting them in my JavaScript file and editing their contents?

  • What are the accessibility issues you can see in my solution?

I am not in the accessibility learning path yet but I want to know your feedback on this.

Any feedbacks and recommendations are welcome too!

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Ethan John Paguntalan•260
    @dev-ethanjohn
    Posted 2 months ago

    Hi, nice job!

    It works but i have some few suggestions that you may try to look at and consider. (1). I notice you are hardcoding the HTML card list. Leverage JS to loop over and dynamically update components if major difference only is data and few styling. We do this so that it will be become easier for us to read and update if there comes a time we need to. Moreover, be wary about using too much divs in our structure. Utilize semantic elements like lists and nav for items in a group (choose what make sense.) (2). Due to reason 1, your JS is like an overkill for a simple JSON referencing and dynamic update. Inside, my recommendation is to lessen your global variables and functions as it may come at risk of namespace polution. Rather, encapsulate your logic and utilize functions like IIFE (immdiately invoked function expression). Further, you may practice to look up closest parent nodes of a group of items such as in this case buttons to delegate the listener instead of individually adding an event to each child for performance reasons (https://javascript.info/event-delegation). Lastly, do not forget to add some comments if you think will be helpful for you and other developers to understand the code better. (3). Regarding your style, 1 tip is to use em for media queries (https://zellwk.com/blog/media-query-units/). Leverage newer CSS syntax that supports custom variables.

    There are many more but hope some of these could help. Also while learning AI should not be the one who will write the code, but I highly suggest you ask guidance and feedback to your code without requiring it to send back code response unless you understand a topic. That will accelerate your understanding as human mentors can only provide some but not always time. Be sure though to check other sources and keep practicing and learning!

    Marked as helpful

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