jfs-components 0.0.67 → 0.0.68
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/CHANGELOG.md +12 -0
- package/lib/commonjs/components/Image/Image.js +17 -10
- package/lib/commonjs/components/MediaCard/MediaCard.js +14 -10
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/Image/Image.js +17 -10
- package/lib/module/components/MediaCard/MediaCard.js +14 -10
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/Image/Image.d.ts +6 -21
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Image/Image.tsx +18 -12
- package/src/components/MediaCard/MediaCard.tsx +13 -10
- package/src/icons/registry.ts +1 -1
|
@@ -30,9 +30,10 @@ function normalizeSource(imageSource) {
|
|
|
30
30
|
* its parent (`width: '100%'`, `height: '100%'`) — same default as the
|
|
31
31
|
* most common usage in this library (background media, hero images).
|
|
32
32
|
*/
|
|
33
|
+
const DEFAULT_RATIO = 16 / 9;
|
|
33
34
|
function Image({
|
|
34
35
|
imageSource,
|
|
35
|
-
ratio,
|
|
36
|
+
ratio = DEFAULT_RATIO,
|
|
36
37
|
resizeMode = 'cover',
|
|
37
38
|
width,
|
|
38
39
|
height,
|
|
@@ -44,15 +45,21 @@ function Image({
|
|
|
44
45
|
}) {
|
|
45
46
|
const source = useMemo(() => normalizeSource(imageSource), [imageSource]);
|
|
46
47
|
const layoutStyle = useMemo(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
// If the caller has fully specified width AND height, they're doing a
|
|
49
|
+
// non-aspect layout (e.g. "fill the parent") — respect that and skip
|
|
50
|
+
// `aspectRatio` so it doesn't conflict.
|
|
51
|
+
const isExplicitBox = width != null && height != null;
|
|
52
|
+
const s = {
|
|
53
|
+
width: width ?? '100%',
|
|
54
|
+
...(isExplicitBox ? {
|
|
55
|
+
height: height
|
|
56
|
+
} : {
|
|
57
|
+
aspectRatio: ratio,
|
|
58
|
+
...(height != null ? {
|
|
59
|
+
height
|
|
60
|
+
} : {})
|
|
61
|
+
})
|
|
62
|
+
};
|
|
56
63
|
if (borderRadius != null) s.borderRadius = borderRadius;
|
|
57
64
|
return s;
|
|
58
65
|
}, [ratio, width, height, borderRadius]);
|
|
@@ -25,18 +25,21 @@ export function MediaCard({
|
|
|
25
25
|
style
|
|
26
26
|
}) {
|
|
27
27
|
const radius = parseFloat(getVariableByName('cardMedia/radius', modes) || '24');
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// No magic minHeight, no aspectRatio on the container. The card simply
|
|
30
|
+
// hugs whatever the background renders at: the <Image> sits in normal
|
|
31
|
+
// flow with `aspectRatio: ratio`, so its rendered height becomes the
|
|
32
|
+
// card's height. Header and Footer are absolutely positioned overlays
|
|
33
|
+
// and don't contribute to layout.
|
|
29
34
|
const containerStyle = {
|
|
30
35
|
borderRadius: radius,
|
|
31
|
-
gap,
|
|
32
36
|
overflow: 'hidden',
|
|
33
|
-
position: 'relative'
|
|
34
|
-
minHeight: 308
|
|
37
|
+
position: 'relative'
|
|
35
38
|
};
|
|
36
39
|
|
|
37
|
-
// `media` wins
|
|
38
|
-
// the shared <Image> for image-source backgrounds.
|
|
39
|
-
//
|
|
40
|
+
// `media` wins as an escape hatch (gradient/video/etc.). Otherwise we
|
|
41
|
+
// delegate to the shared <Image> for image-source backgrounds. The
|
|
42
|
+
// background renders in normal flow so its height drives the card.
|
|
40
43
|
const background = media ?? (imageSource != null ? /*#__PURE__*/_jsx(Image, {
|
|
41
44
|
imageSource: imageSource,
|
|
42
45
|
ratio: ratio,
|
|
@@ -50,10 +53,11 @@ export function MediaCard({
|
|
|
50
53
|
},
|
|
51
54
|
children: /*#__PURE__*/_jsxs(View, {
|
|
52
55
|
style: [containerStyle, style],
|
|
53
|
-
children: [background ? /*#__PURE__*/_jsx(View, {
|
|
56
|
+
children: [background, children != null ? /*#__PURE__*/_jsx(View, {
|
|
54
57
|
style: StyleSheet.absoluteFill,
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
pointerEvents: "box-none",
|
|
59
|
+
children: children
|
|
60
|
+
}) : null]
|
|
57
61
|
})
|
|
58
62
|
});
|
|
59
63
|
}
|