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.
