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

Notifications Feed

easy—No data yet

Problem statement

A notifications feed that lives inside a single container on the page. At any given moment the feed is in exactly one of four states — loading, empty, error, or list — and each state is its own piece of markup. A router function and a set of state renderers must together decide which state to show, wipe out the previous one entirely, and wire the retry button to a supplied callback, using Vanilla TypeScript and standard DOM APIs.

Demo

The page, styles, mock data, container, and state-switch buttons are already scaffolded and wired. Only the renderFeed function in src/js/renderFeed.ts and the state renderers (renderLoading, renderEmpty, renderError, renderList, renderRow) in src/js/states.ts are missing — implement them so every test passes. Do not edit any other file.

What to implement

  • Show a loading placeholder made of three skeleton blocks while the feed is being prepared.
  • Show a clear "you're all caught up" message when there is nothing to show, instead of a blank box.
  • Show an error panel with the supplied message and a Retry button when something goes wrong.
  • Make the Retry button call the supplied callback once for every click — three clicks, three calls.
  • Show a list of notification rows when the feed has records — one row per record, in the order given, each with a title, a body line, and a timestamp.
  • Render exactly one state into the container at a time; switching to a new state must wipe the previous state's markup completely.
  • Leave the container with exactly one child after every render, no matter which state was showing before.
  • Leave the notifications you were given unchanged, and leave the container itself and the state-switch buttons as you found them.
  • Everything shown must come from the state 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 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 yeteasyRecipe List Page Implement pure helpers (parseFilters, applyFilters, formatCount) plus renderCard and renderResults. The filter form combines a title search, difficulty select, and max-time cap under AND semantics; submits re-render only the results panel while the form retains submitted values; no-match renders a single empty-state node; cards are built by cloning a <template>.0%0 of 1 solvedeasy

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.