Skip to content

Jak-Ch-ll/FM_time-tracking-dashboard

Repository files navigation

Frontend Mentor - Time tracking dashboard solution

This is my solution for the Time tracking dashboard challenge on Frontend Mentor.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the site depending on their device's screen size
  • See hover states for all interactive elements on the page
  • Switch between viewing Daily, Weekly, and Monthly stats

Screenshot

Desktop version

Links

My process

Built with

What I learned

When looking at this challenge, I immediately knew that reusable components in some form would be helpful. At first, I thought about using a Frontend Framework like React or Svelte, but then I thought, why not learn something new. So I decided to look into Web Components.

It was an interesting experience and reminded me of the convenience of classic web frameworks. In many moments I thought about possible utility functions or classes around the API to improve the workflow for more complex projects. I got to understand why frameworks like Lit exist and was reminded of a quote by Fireship in his Video: I built the same app 10 times: "The last thing the world needs is another JavaScript framework".

One utility function I wrote is to import components into other components. Out of the box, a web component has to be defined once via its class and then is used via the tag name, which does not provide type safety or a traceable import tree. This is what I came up with:

export type CustomElementTagName = `${string}-${string}`

export function createNode(
  elementTagName: CustomElementTagName,
  elementClass: CustomElementConstructor
) {
  // define the custom element in the DOM so it can be used
  window.customElements.define(elementTagName, elementClass)

  // return a function to create an instance of the custom element
  return () => document.createElement(elementTagName)
}

Useful resources

Author

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published