# Media & components

The blocks that carry the hard parts of a page — optional depth, definitions, diagrams, images and video.

Source: https://bugstars-docs.pages.dev/media-and-components/

---

## Collapsible sections

Wrap optional depth in a disclosure. It uses the native `<details>` element, so it is keyboard accessible and prints expanded.

<Accordion label="Optional depth" items={[{ title: "Rotating an API key without downtime", contentSections: [{ _component: "building-blocks/core-elements/text", text: "Create the second key, deploy it to every client, confirm traffic on the new key in the dashboard, then revoke the first. Both keys stay valid until you revoke, so there is no cutover window." }] }, { title: "Full list of retry status codes", contentSections: [{ _component: "building-blocks/core-elements/text", text: "408, 429, and any 5xx are retried with exponential backoff. 4xx other than 408 and 429 are treated as permanent failures." }] }]}/>

<Alert variant="warning" title="Never hide the answer in one" text="Collapsed text is invisible to browser find (⌘F) and to some third-party crawlers. Use disclosures for optional depth and long output — never for the sentence the reader came for."/>

## Tabs with mixed content

When each choice needs more than one code sample, such as an explanation, a callout or a second command, use tabs whose panels hold any content, including other components.

<ContentSelector navigationPosition="top" variant="panel">

<ContentSelectorPanel title="npm">

Install the package, then add it to your project's config.

<CodeBlock language="bash" filename="terminal" showCopy={true}>

```
npm install @stratus/sdk
```

</CodeBlock>

</ContentSelectorPanel>

<ContentSelectorPanel title="Yarn">

Yarn Classic and Yarn Berry use the same command.

<CodeBlock language="bash" filename="terminal" showCopy={true}>

```
yarn add @stratus/sdk
```

</CodeBlock>

<Alert variant="tip" text="With Plug'n'Play enabled, run `yarn dlx @yarnpkg/sdks` once so your editor resolves the types."/>

</ContentSelectorPanel>

</ContentSelector>

<Alert variant="note" title="Sample content" text="The `@stratus/sdk` package and the Yarn tab are here to show the component. Stratus itself installs with npm only."/>

## Definition lists

For glossaries and field-by-field terminology, where a table would be three columns of nothing.

<DefinitionList items={[{ title: "Idempotency key", text: "A client-generated string that makes a retried request safe. Keys are remembered for 24 hours." }, { title: "Dead letter", text: "Where an event lands after its final delivery attempt fails. Replayable from the dashboard for 30 days." }, { title: "Soft descriptor", text: "The text your customer sees on their bank statement. Up to 22 characters." }]}/>

## Text-based diagrams

Diagrams are written as Mermaid text, so they diff in review and whoever inherits the page can edit them without opening a design tool.

<Diagram caption="A webhook delivery, from event to dead letter.">

```
flowchart LR
  A[Event] --> B{Retry?}
  B -- yes --> C[Queue]
  B -- no --> D[Dead letter]
```

</Diagram>

<Alert variant="note" title="Diagrams render in the browser" text="Mermaid needs a DOM to lay a diagram out, so the source ships in the page and the SVG replaces it once the library loads — only on pages that contain a diagram. With JavaScript off, and on paper, the reader gets the source instead of an empty box."/>

## Images

Alt text is required. Captions are optional, light and dark variants are a pair, and on desktop any image can be clicked to zoom.

<Figure source="/src/assets/images/placeholder.jpg" alt="The webhook log, filtered to failed deliveries" caption="The webhook log, filtered to failed deliveries." aspectRatio="widescreen"/>

<Alert variant="tip" title="Light and dark variants" text="Pass `alternateSource` and the template swaps it with the color mode — no flash, no duplicated Markdown. Screenshots of your own UI stop looking broken in dark mode."/>

## Video

Local files or a YouTube or Vimeo embed. Videos are lazy-loaded, never autoplay with sound, and want a caption track for anything instructional.

### From YouTube or Vimeo

An embed takes the video's ID, not its URL — the part after `v=` on YouTube, or the number on Vimeo.

<Video type="youtube" title="Build your editing experience locally with the CloudCannon dev server" videoId="fxWuYi5jPkA"/>

<CodeBlock language="mdx" filename="video.mdx" showCopy={true}>

```
<Video
  type="youtube"
  videoId="fxWuYi5jPkA"
  title="Build your editing experience locally with the CloudCannon dev server"
/>
```

</CodeBlock>

### From a file

Put the file under `public/videos/` and pass its path from `public/`. Upload a `.webm` with the same name beside the `.mp4` and both are offered to the browser, which plays the first it supports.

<Video type="local-source" title="Glass" source="/videos/glass.mp4"/>

<CodeBlock language="mdx" filename="video.mdx" showCopy={true}>

```
<Video
  type="local-source"
  source="/videos/glass.mp4"
  title="Glass"
/>
```

</CodeBlock>

## Status badges

A badge marks the maturity of the thing next to it — a feature, an endpoint, a whole page. Put it above the prose it qualifies, so a reader who skims the headings still sees it.

<Badge text="Beta" variant="info" iconName="beaker"/>

Badges also sit inside a sentence: the `/webhooks/retries` endpoint <Badge text="Beta" variant="info" size="sm"/> is the one place this matters. That is the only component that works inline — everything else in the library is a block.

Badges link, too: pass `link` and the badge becomes an anchor with a trailing arrow, which is how a deprecation notice points at its replacement.

<Badge text="Deprecated — use the v2 endpoint" variant="warning" size="sm" link="/config-api/"/>

<Alert variant="tip" title="Dot instead of an icon" text="`showDot` swaps the leading icon for a small status-colored dot. It reads as a state rather than a category, which suits Stable / Beta / Deprecated better than an icon does."/>

## Third-party embeds

`Embed` carries raw HTML — a sandbox, a map, a form from another service. Whatever you put inside it is scaled to the aspect ratio you pick, so the page reflows without a jump while the frame loads.

<Embed aspectRatio="widescreen">
  <iframe
    src="https://codepen.io/team/codepen/embed/PNaGbb?default-tab=result"
    title="An example CodePen, embedded"
    loading="lazy"
  ></iframe>
</Embed>

<Alert variant="note" title="An embed is somebody else's page" text="It loads in the reader's browser, so it carries that provider's cookies and can't be indexed by search. It also prints as an empty box — keep anything essential in the prose around it, not only inside the frame."/>
