# lightboxControls

> Script layer for a Lightbox `<dialog>`: Left/Right arrow keys step through the photos, a trigger opens the viewer as a modal at the photo it names, the step links scroll in place, and the photo in view is marked current and announced as the track scrolls.

```ts
import { lightboxControls } from "@sdxc/ui/mixins";
```

Attaches the viewer behavior to the `<dialog>` the host sits in, from insertion until
removal. A dialog the server rendered open at a photo is upgraded to a modal there.

## Signature

```ts
lightboxControls(): MixinDescriptor<HTMLElement>
```

## Examples

```tsx
<dialog id="photos">
	<span hidden mix={[lightboxControls()]} />
	<div data-lightbox-track>…</div>
</dialog>
```

## Used with it

The events, constants and types its module publishes, each imported from `@sdxc/ui/mixins` too.

### LIGHTBOX_TRACK_ATTRIBUTE

Attribute on the scroll-snap track holding every slide.

#### Signature

```ts
const LIGHTBOX_TRACK_ATTRIBUTE = "data-lightbox-track"
```

### LIGHTBOX_SLIDE_ATTRIBUTE

Attribute on each slide, in photo order.

#### Signature

```ts
const LIGHTBOX_SLIDE_ATTRIBUTE = "data-lightbox-slide"
```

### LIGHTBOX_INDEX_ATTRIBUTE

Attribute a trigger carries naming the zero-based photo it opens at.

#### Signature

```ts
const LIGHTBOX_INDEX_ATTRIBUTE = "data-lightbox-index"
```

### LIGHTBOX_STEP_ATTRIBUTE

Attribute a step link carries naming the zero-based photo it scrolls to.

#### Signature

```ts
const LIGHTBOX_STEP_ATTRIBUTE = "data-lightbox-to"
```

### LIGHTBOX_INITIAL_ATTRIBUTE

Attribute on the dialog naming the photo a server-opened viewer starts on.

#### Signature

```ts
const LIGHTBOX_INITIAL_ATTRIBUTE = "data-lightbox-initial"
```

### LIGHTBOX_STATUS_ATTRIBUTE

Attribute on the polite live region that names the photo in view.

#### Signature

```ts
const LIGHTBOX_STATUS_ATTRIBUTE = "data-lightbox-status"
```

### LIGHTBOX_ANNOUNCE_ATTRIBUTE

Attribute on each slide's counter and caption, read into the announcement.

#### Signature

```ts
const LIGHTBOX_ANNOUNCE_ATTRIBUTE = "data-lightbox-announce"
```
