The example list behind a component's Examples modal — curated out of the two sets a kit bundle ships, which are not the same thing and were never reconciled.
The two sets
extra.examples is the kit's own catalogue: one entry per option, generated from the component's
variants. It is exhaustive and it is dull — <.component variant="base">Base</.component> twelve
times over, with the content replaced by the name of the thing being demonstrated.
extra.demo_examples is every real usage on the kit's documentation site, with the surrounding
content intact: "Here is a gentle confirmation that your action was successful." rather than
"Base". There are 3,084 of them across the bundle and, until this module, nothing read them.
What curation means here
Three rules, in this order:
- Prefer composed. Where both sets demonstrate the same options, the documentation one wins: identical markup, real content. A preview whose body reads "Base" tells the author nothing about what the component looks like in a page.
- Dedup by what an example SAYS. Two entries setting the same attributes on the same component are one example however differently they are labelled — and the demo set repeats itself heavily, because a docs page shows the same alert under several headings.
- Keep the base first. The unmodified component is what someone opening the modal wants to see before any variant of it.
Every surviving example gets a stable id (so a selection survives a re-render), a title and a
description that says what it actually demonstrates — read off the attributes it sets rather
than copied from a label, because the labels upstream are frequently just the section name.
Summary
Functions
How many examples a component would offer — what the palette's badge counts.
The curated example list for one component row (or palette entry).
The curated examples of ONE component, read fresh from the database by name.
Types
Functions
@spec count(map()) :: non_neg_integer()
How many examples a component would offer — what the palette's badge counts.
The curated example list for one component row (or palette entry).
Returns [] when the component ships none, which is what the modal's empty state is for.
The curated examples of ONE component, read fresh from the database by name.
The palette deliberately carries no examples: curating all 183 components parses every example each one ships and cost 7.8 seconds at editor open, to fill a modal that is opened for a single component. Both readers of that modal — the panel and the preview iframe — come through here instead, and only when the modal is opened.