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

Responsive time tracking dashboard made with CSS Grid and subgrid

bem, sass/scss
P
Alexander3717•310
@Alexander3717
A solution to the Time tracking dashboard challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


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

When styling the tracking cards I ran into a rendering issue (background color bleed in rounded corners) described and solved in this post. I used the linear-gradient method to fix it.

Another challenge was implementing the dashboard grid without changing the desired HTML structure. Here's the deal:

In the desktop design, all the cards — including the "Report for Jeremy Robson" card, are equally wide. To achieve that, it would be best if they followed the same grid.

However, for accessibility and semantics I made the "Report for Jeremy Robson" card be the <header> and placed the tracking cards inside <main>.

<body> <!-- body is the grid -->
  <header></header> <!-- header is the "Report for card" -->

  <main> <!-- tracking cards are inside main -->
    <div class="tracking-card1"></div> 
    ...
    <div class="tracking-card6"></div>
  </main>
</body>

The <header> and the children of <main> aren’t siblings, so I couldn’t easily control them with the same grid. To solve this, I used subgrid on <main>. This allowed <main>'s children (the tracking cards) to follow the column lines of the grid defined on <body>.

Now both <header> and children of <main> are following <body>'s grid structure and I can easily make them equally wide with grid-template-columns: repeat(4, 1fr).

body {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    // other properties here
}

header {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: stretch;
}

main {
    display: grid; // the subgrid needs to have display: grid as well

    // you set the subgrid keyword on grid-template-columns, grid-template-rows or both
    // in this case I needed it on grid-template-columns
    grid-template-columns: subgrid;

    grid-column: 2 / -1;
    // this says in which area of the parent grid should the subgrid lay out its children
    // it then lays them out in this area according to the parent's grid lines
}
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    RishabhSikka3•220
    @RishabhSikka3
    Posted about 2 months ago

    Quite complex approach you have taken to solve it. The fetched data is not getting rendered in UI. I encountered the same issue. Try using the relative path in the javascript file. Use path "data.json" instead of "/data.json".

    And I haven't worked using subgrids for now but it can get implement without subgrids.

    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

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