StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Module 4 · Rendering & DOM Construction

Recipe List Page

easy0%0 of 1 solved

Problem statement

A recipe index that renders a set of recipe cards from an in-memory dataset and lets the user narrow the list down with a filter form — a title search, a difficulty picker, and a maximum cooking time. A small set of pure filtering helpers and two rendering functions must together read the form, narrow the recipes, and re-render a single results panel that owns the cards, the result count, and the empty state, using Vanilla TypeScript and standard DOM APIs.

Demo

The page, styles, filter form, card template, sample recipe data, and bootstrap wiring are already scaffolded and wired. Only the three modules in src/js/ — filters.ts, renderCard.ts, and renderResults.ts — are missing. Implement them so every test passes. Do not edit any other file.

What to implement

  • Show every recipe as a card with the name, cuisine, difficulty, cooking time, and ingredients.
  • Let the user narrow the list down using a title search, a difficulty picker, and a maximum cooking time.
  • When the user submits the form, only the recipes that match every filter should stay on the page, and the values the user just entered should still be sitting in the form.
  • Above the cards, show a small line that says how many recipes are on screen out of the total — for example "Showing 3 of 7".
  • When nothing matches, replace the cards with a single message that reads exactly "No recipes match your filters".
  • Let the user clear the form with a reset control to bring the full list back.
  • Leave the list of recipes you were given unchanged.
  • Everything shown must come from the recipes you were given — nothing should be hardcoded.

More in Rendering & DOM Construction

See the module
Job Listing Board Implement renderRow, renderList, renderPanel, and mount to turn a typed job array into an Open Positions panel. Renderers must be pure (no document queries, no side effects) and return fresh nodes; renderList([]) returns a documented empty-state node; mount replaces container contents so repeat calls leave exactly one child.—No data yeteasyNotifications Feed Implement renderFeed and the four state renderers. renderFeed dispatches on a discriminated FeedState union (loading | empty | error | list), swaps the container's single child, and wires an onRetry callback into the error state that fires exactly once per click. Switching between states must leave no residue from the previous state.—No data yeteasyCourse Review CommentsImplement renderComment + renderCommentList and the splitLines, truncate, isSafeUrl helpers. Review text is rendered via textContent only so a raw <script> never becomes an element; links are built from a separate url field and only when the scheme is http(s); long text truncates at 240 chars with an expand control that reveals the full body on click.—No data yeteasy

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.