# `<redfish-layers>`: the standard collapsible layers panel (v0.1.0)

**Home:** Debbie's bead [`c4a8e2f1`](../../about.md) `/web-components/layers/`.
Stephen, 2026-10-23: *"and then we will need a standard collapsible layers panel on the left"*.
**Canonical URI:** https://redfish.acequia.io/guerin/.agents/c4a8e2f1-7b6d-4e93-a5c2-8f1d3b0e9a47/web-components/layers/redfish-layers.mjs

**First used by:** incident-workspace v0.3.0 (incident-viewer bead `42b5d5db`), at
https://simtable.acequia.io/apps/incident-workspace/?incident=CA-ORC-NORTE. The guide that documents it is at
https://simtable.acequia.io/apps/incident-workspace/guide.html.

## What it keeps (redfish-style section 4)

- **Rule 10, minimize-tab.** Closed, the panel is one slim tab: "Layers · N on ▸". The open/closed state and every
  layer's on/off and opacity are remembered under `storage-key` (two localStorage entries: `<key>:open`, `<key>:layers`).
- **Transitions (section 2c).** Opening and drilling in fade and slide over `--rf-t-base`; zeroed under
  `prefers-reduced-motion`.
- **The 3-to-7 decision budget.** Closed: 1 (the tab). Open: the tab plus at most five group rows (6). In a group:
  the tab, back, and at most four layer rows (6). The opacity slider shows only on the selected row (7). So the panel
  never adds more than seven decisions, and at rest it adds one. One group open at a time (the rooms rule the workspace
  drawer uses). Esc goes back from a group.
- **One accent.** A layer that is on shows "on" in `--rf-accent`; swatches are the layer's data colour (legend).
- **Not available here is shown, not hidden.** `disabled: true` rows read "n/a" with a hint (why, and where it is
  drawn instead), so a reader learns the layer exists.

## API

```html
<script type="module" src="https://redfish.acequia.io/guerin/.agents/c4a8e2f1-7b6d-4e93-a5c2-8f1d3b0e9a47/web-components/layers/redfish-layers.mjs?v=0.1.0"></script>
<redfish-layers id="layers" storage-key="iw-layers" heading="Layers"></redfish-layers>
```
```js
const L = document.getElementById('layers');
L.setLayers([
  { id: 'fire', name: 'Fire', swatch: '#be3a34', children: [
    { id: 'hull', name: 'hull', on: true, swatch: '#be3a34', opacity: 0.8 },
    { id: 'perims', name: 'perimeters', disabled: true, hint: 'not in this page yet' } ] },
]);
L.addEventListener('layerchange', e => { const { id, on, opacity, initial } = e.detail; /* apply */ });
L.set('hull', { on: false });      // keep the panel in step when a key toggles a layer (e.g. b for blend)
L.get('hull');                     // { on, opacity }
L.open = true;                     // or the attribute `open`
L.decisions();                     // the panel's visible decisions, for the host's count
```

- Groups beyond five and children beyond four are the host's design problem: the component keeps the first four
  children of a group (the budget), so split a crowded group.
- `setLayers` restores remembered states and fires `layerchange` with `initial: true` for each live layer, so the host
  applies the remembered state with the same handler.
- Click on a row toggles it. A layer with an `opacity` that is on: the first click selects it (its slider shows), the
  next toggles it off.
- Theming: the house tokens (`--rf-ground`, `--rf-ink`, `--rf-ink-quiet`, `--rf-rule`, `--rf-accent`, `--rf-radius`,
  `--rf-sans`) pierce the shadow root; a page that links `redfish-style.css` is themed light and dark with no extra CSS.
  `--layers-max-h` caps the open height (default 70vh). The tab is `::part(tab)`.

## Why not `<redfish-layer-panel>`

Its row carries a checkbox, an expander and two always-on action buttons (fly-to, timespan), so a five-layer tree is
about twenty visible controls, three times the budget. It stays the STAC/catalog tree (many layers, reordering,
per-layer time). `<redfish-layers>` is the scene's few layers. Open question for Stephen: converge them (the catalog
tree as a "more" room inside this panel), or keep both.

## History

- 0.1.0 (2026-10-23): first version, for incident-workspace v0.3.0.
