# Image album

The pictures of one message as one album, and one picture's tile, which opens the viewer and holds its menu.

Live variants: https://design.arcadia.is/components/image-album

```tsx
import { ImageAlbum, ImageTile } from "@arcadia/ui";
```

```tsx
import { useState, useRef } from "react";
import { ImageAlbum, ImageViewer } from "@arcadia/ui";

function Album() {
  const images = [DUSK, HARBOUR, FIELD];
  const [open, setOpen] = useState<{ index: number; from: HTMLElement } | null>(null);
  const album = useRef<HTMLDivElement>(null);
  return (
    <div {...sx("cmp-album-column", ImageAlbumStyles.column)}>
      <ImageAlbum
        ref={album} images={images} onOpen={(index, from) => setOpen({ index, from })}
        actions={() => [{ label: "Copy image", run: () => {} }, { label: "Download", run: () => {} }]}
      />
      {open && (
        <ImageViewer images={images} index={open.index} from={open.from} onClose={() => setOpen(null)}
          placeOf={(image) => album.current?.querySelector<HTMLElement>(`[data-image="${image.id}"]`) ?? null} />
      )}
    </div>
  );
}
```

## Accessibility

Each picture that opens is a button named by its `label` (its own name, else the product's words); one that does not is an image with that name. Its menu opens from a right click, the menu key and Shift+F10, and a long press, and names itself Image. `focusable={false}` keeps the pictures out of Tab where what holds them is one stop already. A placeholder and a skeleton are hidden from a reader.

A picture standing above its words shares their `MessageGroup`, so a reader meets them as one message: the author line, the picture's button with its menu, the words, the time.

## API reference

### ImageAlbum

- `images` (`readonly T[]`, required): The pictures shown together, in order: one stands alone at its own proportions, several make rows.
- `label` (`(image: T, index: number) => string`): Each picture's name for assistive technology. Default its own name, else "Image".
- `onOpen` (`(index: number, from: HTMLElement) => void`): Opens one (the product's viewer), from its tile. Without it the pictures do not open.
- `actions` (`(image: T, index: number) => readonly ImageAction[]`): What each picture's menu holds.
- `over` (`(image: T, index: number) => ReactNode`): What the product lays over a picture (an upload's ring).
- `mark` (`ReactNode`): The product's mark at its foot (a read mark), on a plate.
- `focusable` (`boolean`, default `true`): Its pictures are reached with Tab.
- `side` (`"start" | "end"`, default `"start"`): Which side of its column it stands on.
- `inBubble` (`boolean`, default `false`): At the top of a bubble, edge to edge: the bubble's corners above it, square under it, over the words.
- `flash` (`boolean`, default `false`): A jump just landed on it (a reply's source, a message of pictures alone): the held ring, as a bubble's. Inside a `MessageParts`, the message's `flash` sets it.
- `rootStyle` (`RootStyle<ImageAlbumKnobs>`): Typed StyleX override: layout and the `--image-album-*` knobs.

Rest props go to `<div>` props.

### ImageTile

- `image` (`MediaImage`, required): A picture as the kit's image parts show it: plain data, nothing of the product that holds it and nothing of a server. Its sides and where its original is; everything else is optional. With no preview the original serves everywhere, and with no placeholder the quiet skeleton stands in its place until it is drawn.
- `frame` (`number`): Its box's width over its height; a picture of another shape is cut to it, a tall one from its top. Default its own, held between 2:5 and 8:1.
- `label` (`string`): Its name for assistive technology. Default the image's name, else "Image".
- `onOpen` (`(from: HTMLElement) => void`): Opens it (the product's viewer), from the tile pressed. Without it the tile is the picture alone.
- `actions` (`readonly ImageAction[]`, default `[]`): What its menu holds (a right click, the menu key, a long press), on a tile that opens.
- `focusable` (`boolean`, default `true`): Reached with Tab.
- `over` (`ReactNode`): What the product lays over the picture (an upload's ring), above its press.
- `rootStyle` (`RootStyle`): Typed StyleX override: layout.

Rest props go to `<span>` props.
