Every CompMD component in one place: params, live demos and the playground

With more packs comes a question: how do you find the component you need? The answer is live today: the Component Index, at compmd.dev/components.

The Components page: its title, its filter, and the first row of Layout cards: box, card, columns and event

Figure 1. The Components page: each component a card, with a picture of its demo, grouped by what it is for.

Every component, with its demo

The index lists every component a document can name: the built-ins every document has, such as tabs, foldable, steps, grid and if, and every listed pack, ours and anyone's.

Each component has a card of its own, grouped by what it is for: layout, logic, data, diagrams and more. Type in the filter and it searches names, descriptions and keywords, so "bar" finds chart.

Open a card and you get everything you need to use the component:

  • its params;

  • a live demo;

  • how to use it;

  • examples;

  • and a Try it link, to change it in the playground.

What is behind it

The page reads the pack index, at index.compmd.dev. It is plain JSON files: an entry for every version of every listed pack, and lists of packs and names for tools to read. A job builds them every hour from the packs themselves, from their package.json, their components' signatures, their README, demo and picture, without running any pack's code.

flowchart LR
  npm[("npm<br/>the packs")]  -->|every hour| builder["The index's builder"]
  builder --> index[("index.compmd.dev<br/>JSON files")]
  index --> page["Components page"]
  index --> lsp["Language server"]
  index --> devtools["Developer Tools"]
  classDef store fill:#e8edfb,stroke:#3557c4,color:#1b2430
  classDef step fill:#3557c4,stroke:#3557c4,color:#ffffff
  classDef reader fill:#fbfcfd,stroke:#9aa6b5,color:#1b2430
  class npm,index store
  class builder step
  class page,lsp,devtools reader

There is no server and no account. Packs stay on npm, and the index only describes them. Being listed grants a pack no trust either: a host still runs its components in the sandbox, as it would any other pack's.

Any tool can read it, and CompMD's own already do. The language server suggests the pack that gives a component you used but didn't import, and the Developer Tools list the packs to browse.

List your own pack

The index is open to everyone's packs. If you made one, listing it takes one pull request:

  1. Publish your pack to npm. npm create @compmd/pack gets you started, and the Developer's Guide walks through a first pack.

  2. Open a pull request that adds its name to listing.json in comp-markdown/index.

  3. A workflow checks the pack, builds its entry and comments on your pull request with what the index will say.

Once it is merged, every version you publish shows up within the hour, with no need to come back.

Conclusion

Go and explore the Component Index: open a demo, change it in the playground, and see what fits your pages. If something you need is missing, tell me in the comments below, or in an issue on GitHub. Or better, make it a pack and list it: the next person looking for it will find it there.

Until next time...

Hakan Serce