Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Job Listing using Svelte, TS, and Tailwind

Fred Campo 330

@fredcamp

Desktop design screenshot for the Job listings with filtering coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


How amazing and simple Svelte's Store is to use for state management. With the use of the dollar prefix $ for auto subscription and cleanup.

import { writable } from 'svelte/store'
import type { JobStore } from '../types/Job.type'

let store = createFilterStore([])

function createFilterStore(initial: string[]): JobStore {
  const { subscribe, set } = writable(initial)

  return {
    subscribe,
    set: (value: string[]) => {
      set(value)
    },
  }
}
export default store

Another challenge that I faced was on how to make sure that all the Filter Tags would return the exact Job Listing. There are lots of ways to use like with the ES6 Object Entries, but I just went with the Object Destructuring since it was more of a simple head-on approach and used Svelte's Reactivity to trigger when value changes.

//svelte reactivity, so whenever filterStore value changes, the function would execute
$: applyFilter(), $filterStore

function applyFilter(): void {
    if ($filterStore.length === 0) {
      jobs = [...data]
      return
    }

    jobs = data.filter((post) => {
      const { role, level, languages, tools } = post
      const keys = [role, level, ...languages, ...tools]

      const hasAllElements = $filterStore.every((item) => keys.includes(item))
      if (hasAllElements) return post
    })
  }

Community feedback

@0xabdulkhaliq

Posted

Hello there 👋. Congratulations on successfully completing the challenge! 🎉

  • I have other recommendations regarding your code that I believe will be of great interest to you.

HEADINGS ⚠️:

  • This solution has generated another accessibility error report due to skipping heading levels
  • We want to avoid skipping heading levels, make sure to start with <h1> and working your way down the heading levels (<h2>, <h3>, etc.) helps ensure that our document has a clear and consistent hierarchy. Read more 📚
  • Because skipping heading levels is a poor practice from the perspective of information design, whether we are talking about web pages, books, journal articles, or about anything else. You can not only confuse screen readers but all readers when you don't follow a consistent, logical pattern with your heading structure.

I hope you find this helpful 😄 Above all, the solution you submitted is great !

Happy coding!

0

Please log in to post a comment

Log in with GitHub
Discord logo

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