Add the Nook "Image" component to this project, exactly as Nook ships it.
An image in a frame that holds its shape, with loading, failure and a large view.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add image`. It writes `components/ui/image.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/image.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Image } from "@/components/ui/image";
const art = (from: string, to: string) =>
`data:image/svg+xml,${encodeURIComponent(``)}`;
export default function ImageDefault() {
return (
);
}
```
API
- `Image`: The frame, the picture and an optional caption.
- `alt` (`string`): What the image shows.
- `ratio` (`number`, default 16 / 9): Width divided by height.
- `fit` (`"cover" | "contain"`, default "cover"): Fill the frame (and crop), or show the whole image.
- `caption` (`ReactNode`): Text under the image.
- `zoomable` (`boolean`): Press the image to see it large.
- `fallback` (`ReactNode`): Shown if the file cannot load.
- `ImagePlaceholder`: A tile that stands in for a picture: a chart color with a flat drawing in the page colors.
- `label` (`string`): What the picture will show, for assistive tech.
- `src` (`string`): Optional picture over the drawing. The drawing stays visible when the picture is unavailable.
- `ratio` (`number`, default 1): Width divided by height.
- `tone` (`1 | 2 | 3 | 4 | 5`, default 1): Which chart color the tile uses.
- `scene` (`"hills" | "city" | "stripes" | "blocks" | "waves"`): The drawing on the tile. Picked from the label when left out.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: `alt` is required: pass an empty string only for decoration. The frame reserves its space so the page does not jump. A failed image shows its alt text. The large view is a dialog: Escape or a click anywhere closes it.
Done when the component renders like the example in light and dark mode and the project type-checks.