@leitware/composables 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/rules/composables.md +1 -0
- package/skills/use-composables/references/public-api.md +2 -2
- package/src/index.ts +2 -0
- package/src/opinionated/image.tsx +69 -0
package/README.md
CHANGED
|
@@ -54,6 +54,24 @@ import { FormInput } from '@leitware/composables'
|
|
|
54
54
|
import { Card } from '@leitware/composables'
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Images
|
|
58
|
+
|
|
59
|
+
`Image` requires `src`, `alt`, and intrinsic pixel `width`/`height`, or explicit `fill` mode. Dimensions reserve space before loading; images shrink to fit their container. Use `alt=""` for decorative images.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { AspectRatio, Image } from '@leitware/composables'
|
|
63
|
+
|
|
64
|
+
<Image src="/mountains.jpg" alt="Snow on the mountain peaks" width={1200} height={800} />
|
|
65
|
+
|
|
66
|
+
<AspectRatio ratio={16 / 9}>
|
|
67
|
+
<Image src="/mountains.jpg" alt="Snow on the mountain peaks" fill />
|
|
68
|
+
</AspectRatio>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`fill` absolutely positions the image inside a positioned parent with a defined size. For a background, use a relatively positioned container, `alt=""`, and place foreground content above the image. `fit="cover"` crops by default; `fit="contain"` shows the entire image against the muted background. `position` controls the focal point. `className`, `style`, and the forwarded ref target the actual image.
|
|
72
|
+
|
|
73
|
+
Images default to `loading="lazy"` and `decoding="async"`. For an above-the-fold hero, use `loading="eager"` and optionally `fetchPriority="high"`. Native `srcSet`, `sizes`, events, and other image attributes pass through. Supply `sizes` to describe the rendered width when using width-descriptor `srcSet` sources. This is a native browser image component: it does not generate responsive sources or provide Next.js image optimization. Captions and credits can be composed using `figure` and `figcaption`.
|
|
74
|
+
|
|
57
75
|
### Override the theme
|
|
58
76
|
|
|
59
77
|
Override known semantic variables after the imports. Define both modes when a colour decision should change with the theme:
|