Catalogue blocks

Catalogue components provide search, filters and paginated resource cards without requiring the host to implement these controls. Use the complete mosaicary-catalog when its layout fits the application. Use independent blocks when search belongs in a toolbar or filters must appear in a separate panel. Both compositions share the same state model.

Use the complete catalogue

mosaicary-catalog combines the Mosaicary banner, shelf selection, search, filters and cards. kinds accepts comma-separated skins, models and builds; it also controls their order, and a single kind shows no tabs. size="64" applies to skins rather than models or builds. Set selected to a resource id to indicate an existing selection, such as the skin currently worn by a player. accent sets the application’s accent colour; the other colours and the letters come from the page, and the catalogue leaves its own background unpainted so the page shows through.

<mosaicary-catalog
  catalogue="gallery"
  kinds="skins,models,builds"
  size="64"
  selected="RESOURCE_ID"
></mosaicary-catalog>

Compose blocks around shared state

Blocks with the same catalogue name use one Catalogue; standalone blocks default to main. The complete catalogue creates a unique name when none is supplied. The first supplied value for each of kinds, size and origin establishes that option, so configure consistent values before loading. groups selects filter sections and bare removes the filter heading and count. Cards request the next page as their end approaches the viewport; the host need not add a separate loading control.

<mosaicary-tabs
  catalogue="gallery"
  kinds="skins,models,builds"
></mosaicary-tabs>
<mosaicary-search catalogue="gallery"></mosaicary-search>
<mosaicary-filters
  catalogue="gallery"
  groups="arms,category,order,tags"
  bare
></mosaicary-filters>
<mosaicary-cards catalogue="gallery" size="64"></mosaicary-cards>
<mosaicary-found catalogue="gallery"></mosaicary-found>
<mosaicary-credit catalogue="gallery"></mosaicary-credit>

Handle typed, cancelable selection

mosaicary-pick bubbles across Shadow DOM and contains detail.kind, detail.item and, for a skin, detail.sheet when available. Its discriminated union narrows item after checking kind. A successful pick marks the card automatically. Call preventDefault() synchronously to keep the previous selection, for example while permission is checked. A standalone mosaicary-card emits the same event but does not own the selection state of a card list.

import 'mosaicary/catalog/define';
const cards = document.querySelector('mosaicary-cards')!;
cards.addEventListener('mosaicary-pick', (event) => {
  if (event.detail.kind === 'skins') {
    const skin = event.detail.item; // Skin
    // event.preventDefault(); // Keep the previous selection.
    console.log(skin.arms);
  }
});

Observe failures and offer recovery

A failed catalogue page produces a localized message and a retry button. mosaicary-error exposes message, status, code and retryAfter; network failures have null API fields. Automatic retries use backoff and respect the server interval. The button calls retry(), which asks again at once; when the service has answered 429 with Retry-After, it waits for that interval first. Use Custom interface when the application must own error presentation, scheduling or virtualized rendering.

cards.addEventListener('mosaicary-error', ({ detail }) => {
  console.log(detail.status, detail.code, detail.retryAfter);
});