#960
ratio and fit
One 4:3 gradient file rendered in three boxes: ratio 16/9 (cropped), ratio 1 (cropped) and ratio 1 with fit contain (letterboxed).
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "ratio and fit" pattern (@codeatlasdev/ui demo #960, display/image) in my app.
Call get_demo({ ids: ["#960"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Card covers, thumbnails and avatar grids where every picture must share one box whatever its own proportions.
Keep these library parts, with the props and tokens the demo uses:
- Image from "@codeatlasdev/ui"
Behaviour to keep:
- `<Image {src} alt="Wide cover" width={800} height={600} ratio={16 / 9} />`
- `<Image {src} alt="Square cover" width={800} height={600} ratio={1} />`
- `<Image {src} alt="Contained" width={800} height={600} ratio={1} fit="contain" />`
- `src` is an inlined 4:3 `data:image/svg+xml;utf8,` gradient with a circle
- Each image sits in a `<figure>` with a `<figcaption>` naming its ratio
Reduced motion: the demo handles it; keep that branch.
Keyboard: not an interactive control.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- Image
@codeatlasdev/ui
How it is built
- `<Image {src} alt="Wide cover" width={800} height={600} ratio={16 / 9} />`
- `<Image {src} alt="Square cover" width={800} height={600} ratio={1} />`
- `<Image {src} alt="Contained" width={800} height={600} ratio={1} fit="contain" />`
- `src` is an inlined 4:3 `data:image/svg+xml;utf8,` gradient with a circle
- Each image sits in a `<figure>` with a `<figcaption>` naming its ratio
Related
Loading source.