# StoryViewer

> A full-screen story player: each person's stories are a group of timed segments under a row of progress bars, groups sit side by side on a horizontal snap track, and tap zones that are links step through them, so the viewer reads and moves without script and its island adds timing, hold to pause and swipe down to close.

```ts
import { StoryViewer } from "@sdxc/ui/video";
```

Renders the viewer: a full-screen dark stage with the close and pause buttons, and the track
of groups; the group marked `active` is the one the track starts at. A page shows it inside
a box by setting `--ui-story-viewer-position: absolute` and `--ui-story-viewer-height`.

## Examples

```tsx
<StoryViewer label="Stories" closeHref="/" labels={{ close: "Close", pause: "Pause" }}>
	<StoryViewer.Group label="Mara's story" durations={[5, 5]} current={0} active
		previousHref="/" nextHref="/stories/mara/2" labels={{ previous: "Previous", next: "Next" }}>
		<StoryViewer.Segment href="/stories/mara/1" current><Art /></StoryViewer.Segment>
	</StoryViewer.Group>
</StoryViewer>
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `label` | `string` | The viewer's accessible name, such as "Stories". |
| `closeHref` | `string` | Where closing leaves to: the page the viewer opened from. |
| `labels` | `{ close: string; /** The pause button's name; it is pressed while the story is paused. */ pause: string; }` |  |
| `children` | `RemixNode` | StoryViewer.Group elements, one per person, in viewing order. |

Also accepts everything in `TagProps<"section">`.


### StoryViewer.Group

One person's stories: a screen-wide snap point holding a card that fills a phone and stands 9:16 with a margin on a wider screen, with the bars, the header, the segments, the two tap zones and an optional footer.

| Prop | Type | Description |
| --- | --- | --- |
| `label` | `string` | The group's accessible name, such as "Mara Quint's story". |
| `header?` | `RemixNode` | What sits under the progress bars: the person, how long ago, a menu. |
| `durations` | `number[]` | Each segment's length in seconds, in order, which times its progress bar. |
| `current` | `number` | The segment the group shows first. |
| `active?` | `boolean` | Whether the viewer opens on this group; exactly one group in a viewer sets it. |
| `previousHref` | `string` | The address of the segment before the current one, or the close address before the first. |
| `nextHref` | `string` | The address of the segment after the current one, or the close address after the last. |
| `labels` | `{ previous: string; next: string }` | The tap zones' names. |
| `footer?` | `RemixNode` | What sits at the foot of the card, such as a reply field. |
| `children` | `RemixNode` | StoryViewer.Segment elements in order. |

Also accepts everything in `Omit<TagProps<"article">, "children">`.


### StoryViewer.Segment

One segment: a full-card layer, shown only while it is its group's current one.

| Prop | Type | Description |
| --- | --- | --- |
| `href` | `string` | The segment's own address, which the address bar follows. |
| `current` | `boolean` | Whether this is the group's current segment. |

Also accepts everything in `TagProps<"div">`.

