jfs-components 0.0.66 → 0.0.67
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 +8 -0
- package/lib/commonjs/components/CardCTA/CardCTA.js +16 -4
- package/lib/commonjs/components/Image/Image.js +78 -0
- package/lib/commonjs/components/MediaCard/MediaCard.js +40 -27
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/CardCTA/CardCTA.js +16 -4
- package/lib/module/components/Image/Image.js +73 -0
- package/lib/module/components/MediaCard/MediaCard.js +39 -29
- package/lib/module/components/index.js +1 -0
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/Image/Image.d.ts +60 -0
- package/lib/typescript/src/components/MediaCard/MediaCard.d.ts +22 -4
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/CardCTA/CardCTA.tsx +15 -4
- package/src/components/Image/Image.tsx +125 -0
- package/src/components/MediaCard/MediaCard.tsx +110 -82
- package/src/components/index.ts +2 -1
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ImageSourcePropType, type ImageStyle, type StyleProp, type ViewStyle, type ImageResizeMode } from 'react-native';
|
|
3
|
+
export type ImageProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Image source. Accepts the same shapes as React Native's `<Image>` plus a
|
|
6
|
+
* raw URL string. Naming is intentionally aligned with `Avatar`,
|
|
7
|
+
* `ProductLabel`, `CardProviderInfo`, etc. so the library has a single,
|
|
8
|
+
* predictable image-source prop name.
|
|
9
|
+
*/
|
|
10
|
+
imageSource?: ImageSourcePropType | string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Width-to-height aspect ratio as a number, e.g. `16 / 9`, `1`, `4 / 3`.
|
|
13
|
+
* When set, the image lays out using `aspectRatio` so it scales naturally
|
|
14
|
+
* with whatever width it receives — no need to specify height.
|
|
15
|
+
*
|
|
16
|
+
* Equivalent CSS: `aspect-ratio: <ratio>`.
|
|
17
|
+
*/
|
|
18
|
+
ratio?: number | undefined;
|
|
19
|
+
/** How the image is fit inside its box. Defaults to `'cover'`. */
|
|
20
|
+
resizeMode?: ImageResizeMode | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Optional explicit width. If omitted and a `ratio` is set, the image
|
|
23
|
+
* defaults to `width: '100%'` so it fills its parent.
|
|
24
|
+
*/
|
|
25
|
+
width?: ViewStyle['width'] | undefined;
|
|
26
|
+
/** Optional explicit height. Usually you only need `ratio` instead. */
|
|
27
|
+
height?: ViewStyle['height'] | undefined;
|
|
28
|
+
/** Border radius applied to the image (clips the underlying raster). */
|
|
29
|
+
borderRadius?: number | undefined;
|
|
30
|
+
/** Style merged onto the underlying RN `<Image>`. */
|
|
31
|
+
style?: StyleProp<ImageStyle> | undefined;
|
|
32
|
+
/** Accessibility label forwarded to RN `<Image>`. */
|
|
33
|
+
accessibilityLabel?: string | undefined;
|
|
34
|
+
/** Hide from the a11y tree (e.g. when image is purely decorative). */
|
|
35
|
+
accessibilityElementsHidden?: boolean | undefined;
|
|
36
|
+
importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants' | undefined;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* `Image` — the library's standard raster image primitive.
|
|
40
|
+
*
|
|
41
|
+
* Why this exists:
|
|
42
|
+
* - Gives consumers a single component for "show an image at a given aspect
|
|
43
|
+
* ratio inside a flex container" without having to remember the
|
|
44
|
+
* `width:'100%' / height:'100%' / resizeMode:'cover'` boilerplate.
|
|
45
|
+
* - Centralizes URL-vs-`{uri}` normalization that several components were
|
|
46
|
+
* re-implementing.
|
|
47
|
+
* - Uses the same `imageSource` prop name as the rest of the library
|
|
48
|
+
* (`Avatar`, `ProductLabel`, `CardProviderInfo`, ...) for a unified API.
|
|
49
|
+
*
|
|
50
|
+
* Layout rules:
|
|
51
|
+
* - If `ratio` is provided, the image lays out with `aspectRatio: ratio`
|
|
52
|
+
* and (unless `width` is given) fills the parent's width.
|
|
53
|
+
* - If neither `ratio` nor explicit dimensions are given, the image fills
|
|
54
|
+
* its parent (`width: '100%'`, `height: '100%'`) — same default as the
|
|
55
|
+
* most common usage in this library (background media, hero images).
|
|
56
|
+
*/
|
|
57
|
+
declare function Image({ imageSource, ratio, resizeMode, width, height, borderRadius, style, accessibilityLabel, accessibilityElementsHidden, importantForAccessibility, }: ImageProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
declare const _default: React.MemoExoticComponent<typeof Image>;
|
|
59
|
+
export default _default;
|
|
60
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type ViewStyle, type TextStyle, type StyleProp } from 'react-native';
|
|
2
|
+
import { type ViewStyle, type TextStyle, type StyleProp, type ImageSourcePropType } from 'react-native';
|
|
3
3
|
export interface MediaCardProps {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Image source for the background media. Same shape as the rest of the
|
|
6
|
+
* library (`Avatar`, `ProductLabel`, etc.) — accepts a URL string or any
|
|
7
|
+
* RN `ImageSourcePropType`. The card renders this through the shared
|
|
8
|
+
* `<Image>` component, so all image-rendering details (normalization,
|
|
9
|
+
* resize behaviour, `aspectRatio`) live there, not here.
|
|
10
|
+
*/
|
|
11
|
+
imageSource?: ImageSourcePropType | string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Width-to-height aspect ratio for the background image when using
|
|
14
|
+
* `imageSource`, e.g. `16 / 9`. Forwarded to `<Image ratio>`.
|
|
15
|
+
*/
|
|
16
|
+
ratio?: number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Escape hatch: a fully custom background node (e.g. a gradient view, a
|
|
19
|
+
* video). Takes precedence over `imageSource`. Prefer `imageSource` for
|
|
20
|
+
* the common case of a single background image.
|
|
7
21
|
*/
|
|
8
22
|
media?: React.ReactNode;
|
|
9
23
|
/**
|
|
@@ -23,8 +37,12 @@ export interface MediaCardProps {
|
|
|
23
37
|
* MediaCard component implementation from Figma node 1241:4140.
|
|
24
38
|
*
|
|
25
39
|
* Features a background media slot, a large title, and a glass-morphism footer.
|
|
40
|
+
*
|
|
41
|
+
* The background can be supplied either as `imageSource` (preferred — uses
|
|
42
|
+
* the shared `<Image>` primitive under the hood) or as a custom `media` node
|
|
43
|
+
* for non-image backgrounds.
|
|
26
44
|
*/
|
|
27
|
-
export declare function MediaCard({ media, children, modes, style, }: MediaCardProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare function MediaCard({ imageSource, ratio, media, children, modes, style, }: MediaCardProps): import("react/jsx-runtime").JSX.Element;
|
|
28
46
|
export declare namespace MediaCard {
|
|
29
47
|
var Header: typeof import("./MediaCard").Header;
|
|
30
48
|
var Title: typeof import("./MediaCard").Title;
|
|
@@ -24,11 +24,12 @@ export { default as HoldingsCard, type HoldingsCardProps } from './HoldingsCard/
|
|
|
24
24
|
export { default as HStack, type HStackProps } from './HStack/HStack';
|
|
25
25
|
export { default as IconButton } from './IconButton/IconButton';
|
|
26
26
|
export { default as IconCapsule } from './IconCapsule/IconCapsule';
|
|
27
|
+
export { default as Image, type ImageProps } from './Image/Image';
|
|
27
28
|
export { default as LazyList } from './LazyList/LazyList';
|
|
28
29
|
export { default as LinearMeter, type LinearMeterProps } from './LinearMeter/LinearMeter';
|
|
29
30
|
export { default as ListGroup } from './ListGroup/ListGroup';
|
|
30
31
|
export { default as ListItem } from './ListItem/ListItem';
|
|
31
|
-
export { default as MediaCard } from './MediaCard/MediaCard';
|
|
32
|
+
export { default as MediaCard, type MediaCardProps } from './MediaCard/MediaCard';
|
|
32
33
|
export { default as MerchantProfile, type MerchantProfileProps } from './MerchantProfile/MerchantProfile';
|
|
33
34
|
export { default as MoneyValue } from './MoneyValue/MoneyValue';
|
|
34
35
|
export { default as NoteInput, type NoteInputProps } from './NoteInput/NoteInput';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Auto-generated from SVG files in src/icons/
|
|
5
5
|
* DO NOT EDIT MANUALLY - Run "npm run icons:generate" to regenerate
|
|
6
6
|
*
|
|
7
|
-
* Generated: 2026-04-
|
|
7
|
+
* Generated: 2026-04-22T11:47:15.563Z
|
|
8
8
|
*/
|
|
9
9
|
export declare const iconRegistry: Record<string, {
|
|
10
10
|
path: string;
|
package/package.json
CHANGED
|
@@ -95,11 +95,22 @@ function CardCTA({
|
|
|
95
95
|
justifyContent: 'center',
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// NOTE: rightWrap must NOT shrink on native. On Android (Yoga), the default
|
|
99
|
+
// `flex: 2` shorthand expands to `{ flexGrow: 2, flexShrink: 1, flexBasis: 0 }`,
|
|
100
|
+
// which — combined with `minWidth: 0` — lets Yoga shrink this wrapper below
|
|
101
|
+
// its own padding+IconCapsule width when leftWrap's text is long. Once that
|
|
102
|
+
// happens the horizontal padding collapses, `alignItems: 'flex-end'` pins
|
|
103
|
+
// the IconCapsule against the inner edge, and the icon ends up visually
|
|
104
|
+
// touching the body text (the wrapper "appears not to exist"). Web hides
|
|
105
|
+
// this because browsers honor `min-width: auto` on flex items. Use
|
|
106
|
+
// explicit `flexGrow`/`flexShrink: 0`/`flexBasis: 'auto'` so the wrapper
|
|
107
|
+
// is sized to its content as a floor and only grows for the design's
|
|
108
|
+
// 3:2 ratio when extra space is available. leftWrap already absorbs tight
|
|
109
|
+
// space via `flexShrink: 1` + `minWidth: 0`.
|
|
98
110
|
const rightWrapStyle: ViewStyle = {
|
|
99
|
-
|
|
100
|
-
flexShrink:
|
|
101
|
-
flexBasis:
|
|
102
|
-
minWidth: 0,
|
|
111
|
+
flexGrow: 2,
|
|
112
|
+
flexShrink: 0,
|
|
113
|
+
flexBasis: 'auto',
|
|
103
114
|
paddingHorizontal: rightPaddingH,
|
|
104
115
|
paddingVertical: rightPaddingV,
|
|
105
116
|
alignItems: 'flex-end',
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Image as RNImage,
|
|
4
|
+
View,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type ImageSourcePropType,
|
|
7
|
+
type ImageStyle,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type ViewStyle,
|
|
10
|
+
type ImageResizeMode,
|
|
11
|
+
} from 'react-native'
|
|
12
|
+
|
|
13
|
+
export type ImageProps = {
|
|
14
|
+
/**
|
|
15
|
+
* Image source. Accepts the same shapes as React Native's `<Image>` plus a
|
|
16
|
+
* raw URL string. Naming is intentionally aligned with `Avatar`,
|
|
17
|
+
* `ProductLabel`, `CardProviderInfo`, etc. so the library has a single,
|
|
18
|
+
* predictable image-source prop name.
|
|
19
|
+
*/
|
|
20
|
+
imageSource?: ImageSourcePropType | string | undefined
|
|
21
|
+
/**
|
|
22
|
+
* Width-to-height aspect ratio as a number, e.g. `16 / 9`, `1`, `4 / 3`.
|
|
23
|
+
* When set, the image lays out using `aspectRatio` so it scales naturally
|
|
24
|
+
* with whatever width it receives — no need to specify height.
|
|
25
|
+
*
|
|
26
|
+
* Equivalent CSS: `aspect-ratio: <ratio>`.
|
|
27
|
+
*/
|
|
28
|
+
ratio?: number | undefined
|
|
29
|
+
/** How the image is fit inside its box. Defaults to `'cover'`. */
|
|
30
|
+
resizeMode?: ImageResizeMode | undefined
|
|
31
|
+
/**
|
|
32
|
+
* Optional explicit width. If omitted and a `ratio` is set, the image
|
|
33
|
+
* defaults to `width: '100%'` so it fills its parent.
|
|
34
|
+
*/
|
|
35
|
+
width?: ViewStyle['width'] | undefined
|
|
36
|
+
/** Optional explicit height. Usually you only need `ratio` instead. */
|
|
37
|
+
height?: ViewStyle['height'] | undefined
|
|
38
|
+
/** Border radius applied to the image (clips the underlying raster). */
|
|
39
|
+
borderRadius?: number | undefined
|
|
40
|
+
/** Style merged onto the underlying RN `<Image>`. */
|
|
41
|
+
style?: StyleProp<ImageStyle> | undefined
|
|
42
|
+
/** Accessibility label forwarded to RN `<Image>`. */
|
|
43
|
+
accessibilityLabel?: string | undefined
|
|
44
|
+
/** Hide from the a11y tree (e.g. when image is purely decorative). */
|
|
45
|
+
accessibilityElementsHidden?: boolean | undefined
|
|
46
|
+
importantForAccessibility?:
|
|
47
|
+
| 'auto'
|
|
48
|
+
| 'yes'
|
|
49
|
+
| 'no'
|
|
50
|
+
| 'no-hide-descendants'
|
|
51
|
+
| undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function normalizeSource(
|
|
55
|
+
imageSource: ImageProps['imageSource']
|
|
56
|
+
): ImageSourcePropType | undefined {
|
|
57
|
+
if (imageSource == null) return undefined
|
|
58
|
+
if (typeof imageSource === 'string') return { uri: imageSource }
|
|
59
|
+
return imageSource
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `Image` — the library's standard raster image primitive.
|
|
64
|
+
*
|
|
65
|
+
* Why this exists:
|
|
66
|
+
* - Gives consumers a single component for "show an image at a given aspect
|
|
67
|
+
* ratio inside a flex container" without having to remember the
|
|
68
|
+
* `width:'100%' / height:'100%' / resizeMode:'cover'` boilerplate.
|
|
69
|
+
* - Centralizes URL-vs-`{uri}` normalization that several components were
|
|
70
|
+
* re-implementing.
|
|
71
|
+
* - Uses the same `imageSource` prop name as the rest of the library
|
|
72
|
+
* (`Avatar`, `ProductLabel`, `CardProviderInfo`, ...) for a unified API.
|
|
73
|
+
*
|
|
74
|
+
* Layout rules:
|
|
75
|
+
* - If `ratio` is provided, the image lays out with `aspectRatio: ratio`
|
|
76
|
+
* and (unless `width` is given) fills the parent's width.
|
|
77
|
+
* - If neither `ratio` nor explicit dimensions are given, the image fills
|
|
78
|
+
* its parent (`width: '100%'`, `height: '100%'`) — same default as the
|
|
79
|
+
* most common usage in this library (background media, hero images).
|
|
80
|
+
*/
|
|
81
|
+
function Image({
|
|
82
|
+
imageSource,
|
|
83
|
+
ratio,
|
|
84
|
+
resizeMode = 'cover',
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
borderRadius,
|
|
88
|
+
style,
|
|
89
|
+
accessibilityLabel,
|
|
90
|
+
accessibilityElementsHidden,
|
|
91
|
+
importantForAccessibility,
|
|
92
|
+
}: ImageProps) {
|
|
93
|
+
const source = useMemo(() => normalizeSource(imageSource), [imageSource])
|
|
94
|
+
|
|
95
|
+
const layoutStyle: ImageStyle = useMemo(() => {
|
|
96
|
+
const s: ImageStyle = {}
|
|
97
|
+
if (ratio != null) {
|
|
98
|
+
s.aspectRatio = ratio
|
|
99
|
+
s.width = width ?? '100%'
|
|
100
|
+
if (height != null) s.height = height
|
|
101
|
+
} else {
|
|
102
|
+
s.width = width ?? '100%'
|
|
103
|
+
s.height = height ?? '100%'
|
|
104
|
+
}
|
|
105
|
+
if (borderRadius != null) s.borderRadius = borderRadius
|
|
106
|
+
return s
|
|
107
|
+
}, [ratio, width, height, borderRadius])
|
|
108
|
+
|
|
109
|
+
if (!source) {
|
|
110
|
+
return <View style={[layoutStyle, style as StyleProp<ViewStyle>]} />
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<RNImage
|
|
115
|
+
source={source}
|
|
116
|
+
style={[layoutStyle, style]}
|
|
117
|
+
resizeMode={resizeMode}
|
|
118
|
+
accessibilityLabel={accessibilityLabel}
|
|
119
|
+
accessibilityElementsHidden={accessibilityElementsHidden}
|
|
120
|
+
importantForAccessibility={importantForAccessibility}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default React.memo(Image)
|
|
@@ -1,81 +1,99 @@
|
|
|
1
|
-
import React, { createContext, useContext
|
|
2
|
-
import { View, Text, StyleSheet, type ViewStyle, type TextStyle, type StyleProp,
|
|
3
|
-
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
1
|
+
import React, { createContext, useContext } from 'react'
|
|
2
|
+
import { View, Text, StyleSheet, type ViewStyle, type TextStyle, type StyleProp, type ImageSourcePropType, Platform } from 'react-native'
|
|
3
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
|
+
import Image from '../Image/Image'
|
|
5
|
+
import { EMPTY_MODES } from '../../utils/react-utils'
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
* Context to share 'modes' with child components.
|
|
10
|
-
*/
|
|
11
|
-
const MediaCardContext = createContext<{ modes?: Record<string, any> }>({});
|
|
7
|
+
const MediaCardContext = createContext<{ modes?: Record<string, any> }>({})
|
|
12
8
|
|
|
13
9
|
export interface MediaCardProps {
|
|
14
10
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Image source for the background media. Same shape as the rest of the
|
|
12
|
+
* library (`Avatar`, `ProductLabel`, etc.) — accepts a URL string or any
|
|
13
|
+
* RN `ImageSourcePropType`. The card renders this through the shared
|
|
14
|
+
* `<Image>` component, so all image-rendering details (normalization,
|
|
15
|
+
* resize behaviour, `aspectRatio`) live there, not here.
|
|
16
|
+
*/
|
|
17
|
+
imageSource?: ImageSourcePropType | string | undefined
|
|
18
|
+
/**
|
|
19
|
+
* Width-to-height aspect ratio for the background image when using
|
|
20
|
+
* `imageSource`, e.g. `16 / 9`. Forwarded to `<Image ratio>`.
|
|
17
21
|
*/
|
|
18
|
-
|
|
22
|
+
ratio?: number | undefined
|
|
23
|
+
/**
|
|
24
|
+
* Escape hatch: a fully custom background node (e.g. a gradient view, a
|
|
25
|
+
* video). Takes precedence over `imageSource`. Prefer `imageSource` for
|
|
26
|
+
* the common case of a single background image.
|
|
27
|
+
*/
|
|
28
|
+
media?: React.ReactNode
|
|
19
29
|
/**
|
|
20
30
|
* Content to render inside the card (e.g. MediaCard.Title, MediaCard.Footer).
|
|
21
31
|
*/
|
|
22
|
-
children?: React.ReactNode
|
|
32
|
+
children?: React.ReactNode
|
|
23
33
|
/**
|
|
24
34
|
* Modes object for token resolution.
|
|
25
35
|
*/
|
|
26
|
-
modes?: Record<string, any
|
|
36
|
+
modes?: Record<string, any>
|
|
27
37
|
/**
|
|
28
38
|
* Style overrides for the card container.
|
|
29
39
|
*/
|
|
30
|
-
style?: StyleProp<ViewStyle
|
|
40
|
+
style?: StyleProp<ViewStyle>
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
/**
|
|
34
44
|
* MediaCard component implementation from Figma node 1241:4140.
|
|
35
|
-
*
|
|
45
|
+
*
|
|
36
46
|
* Features a background media slot, a large title, and a glass-morphism footer.
|
|
47
|
+
*
|
|
48
|
+
* The background can be supplied either as `imageSource` (preferred — uses
|
|
49
|
+
* the shared `<Image>` primitive under the hood) or as a custom `media` node
|
|
50
|
+
* for non-image backgrounds.
|
|
37
51
|
*/
|
|
38
52
|
export function MediaCard({
|
|
53
|
+
imageSource,
|
|
54
|
+
ratio,
|
|
39
55
|
media,
|
|
40
56
|
children,
|
|
41
57
|
modes = EMPTY_MODES,
|
|
42
58
|
style,
|
|
43
59
|
}: MediaCardProps) {
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const gap = parseFloat(getVariableByName('cardMedia/gap', modes) || '0');
|
|
47
|
-
// Dimensions from Figma: w=369, h=308. We can make it flexible or default to these?
|
|
48
|
-
// Usually components should be flexible, but stories will constrain them.
|
|
49
|
-
// Figma context shows fixed/hug behavior. Let's start with flex container.
|
|
60
|
+
const radius = parseFloat(getVariableByName('cardMedia/radius', modes) || '24')
|
|
61
|
+
const gap = parseFloat(getVariableByName('cardMedia/gap', modes) || '0')
|
|
50
62
|
|
|
51
63
|
const containerStyle: ViewStyle = {
|
|
52
64
|
borderRadius: radius,
|
|
53
65
|
gap,
|
|
54
66
|
overflow: 'hidden',
|
|
55
67
|
position: 'relative',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
minHeight: 308,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// `media` wins for back-compat / custom nodes; otherwise we delegate to
|
|
72
|
+
// the shared <Image> for image-source backgrounds. All raster-rendering
|
|
73
|
+
// concerns (URL-vs-{uri}, resizeMode, aspect-ratio) live in <Image>.
|
|
74
|
+
const background = media ?? (
|
|
75
|
+
imageSource != null ? (
|
|
76
|
+
<Image
|
|
77
|
+
imageSource={imageSource}
|
|
78
|
+
ratio={ratio}
|
|
79
|
+
resizeMode="cover"
|
|
80
|
+
accessibilityElementsHidden
|
|
81
|
+
importantForAccessibility="no"
|
|
82
|
+
/>
|
|
83
|
+
) : null
|
|
84
|
+
)
|
|
65
85
|
|
|
66
86
|
return (
|
|
67
87
|
<MediaCardContext.Provider value={{ modes }}>
|
|
68
88
|
<View style={[containerStyle, style]}>
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</View>
|
|
89
|
+
{background ? (
|
|
90
|
+
<View style={StyleSheet.absoluteFill}>{background}</View>
|
|
91
|
+
) : null}
|
|
73
92
|
|
|
74
|
-
{/* Content Layer */}
|
|
75
93
|
{children}
|
|
76
94
|
</View>
|
|
77
95
|
</MediaCardContext.Provider>
|
|
78
|
-
)
|
|
96
|
+
)
|
|
79
97
|
}
|
|
80
98
|
|
|
81
99
|
// ----------------------------------------------------------------------------
|
|
@@ -88,11 +106,23 @@ export function MediaCard({
|
|
|
88
106
|
* Figma: "title wrap" p-[16px]
|
|
89
107
|
*/
|
|
90
108
|
export function Header({ children, style }: { children?: React.ReactNode; style?: StyleProp<ViewStyle> }) {
|
|
109
|
+
// NOTE: the previous `flex: 1` shorthand expanded on Yoga (Android) to
|
|
110
|
+
// `{ flexGrow: 1, flexShrink: 1, flexBasis: 0 }`. With `flexBasis: 0` the
|
|
111
|
+
// Header has *no intrinsic floor*, so when MediaCard is placed inside a
|
|
112
|
+
// height-unbounded parent — e.g. a Carousel slot whose contentContainer
|
|
113
|
+
// is `alignItems: 'flex-start'` — Yoga's first measurement pass sizes
|
|
114
|
+
// the Header at 0 and the card's overall height becomes non-deterministic.
|
|
115
|
+
// On native this manifests as the card "over-stretching" vertically (the
|
|
116
|
+
// same Yoga foot-gun we fixed in `CardCTA` rightWrap). Web hides it
|
|
117
|
+
// because browsers honor `min-height: auto` on flex items. Use explicit
|
|
118
|
+
// `flexGrow / flexShrink: 0 / flexBasis: 'auto'` so the Header is sized
|
|
119
|
+
// to its content as a floor and only grows to consume the extra space
|
|
120
|
+
// contributed by `MediaCard`'s `minHeight: 308`.
|
|
91
121
|
return (
|
|
92
|
-
<View style={[{ padding: 16,
|
|
122
|
+
<View style={[{ padding: 16, flexGrow: 1, flexShrink: 0, flexBasis: 'auto' }, style]}>
|
|
93
123
|
{children}
|
|
94
124
|
</View>
|
|
95
|
-
)
|
|
125
|
+
)
|
|
96
126
|
}
|
|
97
127
|
|
|
98
128
|
/**
|
|
@@ -100,14 +130,14 @@ export function Header({ children, style }: { children?: React.ReactNode; style?
|
|
|
100
130
|
* Tokens: cardMedia/title/*
|
|
101
131
|
*/
|
|
102
132
|
export function Title({ children, style, modes: propModes }: { children?: React.ReactNode; style?: StyleProp<TextStyle>; modes?: Record<string, any> }) {
|
|
103
|
-
const context = useContext(MediaCardContext)
|
|
104
|
-
const modes = propModes || context.modes || {}
|
|
133
|
+
const context = useContext(MediaCardContext)
|
|
134
|
+
const modes = propModes || context.modes || {}
|
|
105
135
|
|
|
106
|
-
const color = getVariableByName('cardMedia/title/color', modes) || '#ffffff'
|
|
107
|
-
const fontSize = parseFloat(getVariableByName('cardMedia/title/fontSize', modes) || '52')
|
|
108
|
-
const fontFamily = getVariableByName('cardMedia/title/fontFamily', modes) || 'JioType Var'
|
|
109
|
-
const lineHeight = parseFloat(getVariableByName('cardMedia/title/lineHeight', modes) || '68')
|
|
110
|
-
const fontWeight = getVariableByName('cardMedia/title/fontWeight', modes) || '900'
|
|
136
|
+
const color = getVariableByName('cardMedia/title/color', modes) || '#ffffff'
|
|
137
|
+
const fontSize = parseFloat(getVariableByName('cardMedia/title/fontSize', modes) || '52')
|
|
138
|
+
const fontFamily = getVariableByName('cardMedia/title/fontFamily', modes) || 'JioType Var'
|
|
139
|
+
const lineHeight = parseFloat(getVariableByName('cardMedia/title/lineHeight', modes) || '68')
|
|
140
|
+
const fontWeight = getVariableByName('cardMedia/title/fontWeight', modes) || '900'
|
|
111
141
|
|
|
112
142
|
const textStyle: TextStyle = {
|
|
113
143
|
color,
|
|
@@ -115,9 +145,9 @@ export function Title({ children, style, modes: propModes }: { children?: React.
|
|
|
115
145
|
fontFamily,
|
|
116
146
|
lineHeight,
|
|
117
147
|
fontWeight: fontWeight as TextStyle['fontWeight'],
|
|
118
|
-
}
|
|
148
|
+
}
|
|
119
149
|
|
|
120
|
-
return <Text style={[textStyle, style]}>{children}</Text
|
|
150
|
+
return <Text style={[textStyle, style]}>{children}</Text>
|
|
121
151
|
}
|
|
122
152
|
|
|
123
153
|
/**
|
|
@@ -125,20 +155,19 @@ export function Title({ children, style, modes: propModes }: { children?: React.
|
|
|
125
155
|
* Tokens: cardMedia/footer/*, glass/minimal, blur/minimal
|
|
126
156
|
*/
|
|
127
157
|
export function Footer({ children, style, modes: propModes }: { children?: React.ReactNode; style?: StyleProp<ViewStyle>; modes?: Record<string, any> }) {
|
|
128
|
-
const context = useContext(MediaCardContext)
|
|
129
|
-
const modes = propModes || context.modes || {}
|
|
158
|
+
const context = useContext(MediaCardContext)
|
|
159
|
+
const modes = propModes || context.modes || {}
|
|
130
160
|
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
const paddingVertical = parseFloat(getVariableByName('cardMedia/footer/padding/vertical', modes) || '12');
|
|
161
|
+
const gap = parseFloat(getVariableByName('cardMedia/footer/gap', modes) || '24')
|
|
162
|
+
const paddingHorizontal = parseFloat(getVariableByName('cardMedia/footer/padding/horizontal', modes) || '16')
|
|
163
|
+
const paddingVertical = parseFloat(getVariableByName('cardMedia/footer/padding/vertical', modes) || '12')
|
|
135
164
|
|
|
136
165
|
// Glass Effect
|
|
137
166
|
// Figma:
|
|
138
167
|
// blur/minimal/background: "#1414174a"
|
|
139
168
|
// blur/minimal: 29
|
|
140
|
-
const glassBgColor = getVariableByName('blur/minimal/background', modes) || '#1414174a'
|
|
141
|
-
const blurRadius = parseFloat(getVariableByName('blur/minimal', modes) || '29')
|
|
169
|
+
const glassBgColor = getVariableByName('blur/minimal/background', modes) || '#1414174a'
|
|
170
|
+
const blurRadius = parseFloat(getVariableByName('blur/minimal', modes) || '29')
|
|
142
171
|
|
|
143
172
|
const containerStyle: ViewStyle = {
|
|
144
173
|
flexDirection: 'row',
|
|
@@ -150,13 +179,13 @@ export function Footer({ children, style, modes: propModes }: { children?: React
|
|
|
150
179
|
// Web-specific backdrop filter for glass effect
|
|
151
180
|
// @ts-ignore
|
|
152
181
|
...(Platform.OS === 'web' ? { backdropFilter: `blur(${blurRadius}px)` } : {}),
|
|
153
|
-
}
|
|
182
|
+
}
|
|
154
183
|
|
|
155
184
|
return (
|
|
156
185
|
<View style={[containerStyle, style]}>
|
|
157
186
|
{children}
|
|
158
187
|
</View>
|
|
159
|
-
)
|
|
188
|
+
)
|
|
160
189
|
}
|
|
161
190
|
|
|
162
191
|
/**
|
|
@@ -164,20 +193,20 @@ export function Footer({ children, style, modes: propModes }: { children?: React
|
|
|
164
193
|
* Tokens: cardMedia/footer/title/*
|
|
165
194
|
*/
|
|
166
195
|
export function FooterTitle({ children, style, modes: propModes }: { children?: React.ReactNode; style?: StyleProp<TextStyle>; modes?: Record<string, any> }) {
|
|
167
|
-
const context = useContext(MediaCardContext)
|
|
168
|
-
const modes = propModes || context.modes || {}
|
|
196
|
+
const context = useContext(MediaCardContext)
|
|
197
|
+
const modes = propModes || context.modes || {}
|
|
169
198
|
|
|
170
|
-
const color = getVariableByName('cardMedia/footer/title/color', modes) || '#ffffff'
|
|
171
|
-
const fontSize = parseFloat(getVariableByName('cardMedia/footer/title/fontSize', modes) || '14')
|
|
172
|
-
const fontFamily = getVariableByName('cardMedia/footer/title/fontFamily', modes) || 'JioType Var'
|
|
173
|
-
const lineHeight = parseFloat(getVariableByName('cardMedia/footer/title/lineHeight', modes) || '16')
|
|
174
|
-
const fontWeight = getVariableByName('cardMedia/footer/title/fontWeight', modes) || '800'
|
|
199
|
+
const color = getVariableByName('cardMedia/footer/title/color', modes) || '#ffffff'
|
|
200
|
+
const fontSize = parseFloat(getVariableByName('cardMedia/footer/title/fontSize', modes) || '14')
|
|
201
|
+
const fontFamily = getVariableByName('cardMedia/footer/title/fontFamily', modes) || 'JioType Var'
|
|
202
|
+
const lineHeight = parseFloat(getVariableByName('cardMedia/footer/title/lineHeight', modes) || '16')
|
|
203
|
+
const fontWeight = getVariableByName('cardMedia/footer/title/fontWeight', modes) || '800'
|
|
175
204
|
|
|
176
205
|
return (
|
|
177
206
|
<Text style={[{ color, fontSize, fontFamily, lineHeight, fontWeight: fontWeight as any }, style]}>
|
|
178
207
|
{children}
|
|
179
208
|
</Text>
|
|
180
|
-
)
|
|
209
|
+
)
|
|
181
210
|
}
|
|
182
211
|
|
|
183
212
|
/**
|
|
@@ -185,27 +214,26 @@ export function FooterTitle({ children, style, modes: propModes }: { children?:
|
|
|
185
214
|
* Tokens: cardMedia/footer/subtitle/*
|
|
186
215
|
*/
|
|
187
216
|
export function FooterSubtitle({ children, style, modes: propModes }: { children?: React.ReactNode; style?: StyleProp<TextStyle>; modes?: Record<string, any> }) {
|
|
188
|
-
const context = useContext(MediaCardContext)
|
|
189
|
-
const modes = propModes || context.modes || {}
|
|
217
|
+
const context = useContext(MediaCardContext)
|
|
218
|
+
const modes = propModes || context.modes || {}
|
|
190
219
|
|
|
191
|
-
const color = getVariableByName('cardMedia/footer/subtitle/color', modes) || '#f5f7f7a1'
|
|
192
|
-
const fontSize = parseFloat(getVariableByName('cardMedia/footer/subtitle/fontSize', modes) || '12')
|
|
193
|
-
const fontFamily = getVariableByName('cardMedia/footer/subtitle/fontFamily', modes) || 'JioType Var'
|
|
194
|
-
const lineHeight = parseFloat(getVariableByName('cardMedia/footer/subtitle/lineHeight', modes) || '14')
|
|
195
|
-
const fontWeight = getVariableByName('cardMedia/footer/subtitle/fontWeight', modes) || '400'
|
|
220
|
+
const color = getVariableByName('cardMedia/footer/subtitle/color', modes) || '#f5f7f7a1'
|
|
221
|
+
const fontSize = parseFloat(getVariableByName('cardMedia/footer/subtitle/fontSize', modes) || '12')
|
|
222
|
+
const fontFamily = getVariableByName('cardMedia/footer/subtitle/fontFamily', modes) || 'JioType Var'
|
|
223
|
+
const lineHeight = parseFloat(getVariableByName('cardMedia/footer/subtitle/lineHeight', modes) || '14')
|
|
224
|
+
const fontWeight = getVariableByName('cardMedia/footer/subtitle/fontWeight', modes) || '400'
|
|
196
225
|
|
|
197
226
|
return (
|
|
198
227
|
<Text style={[{ color, fontSize, fontFamily, lineHeight, fontWeight: fontWeight as any }, style]}>
|
|
199
228
|
{children}
|
|
200
229
|
</Text>
|
|
201
|
-
)
|
|
230
|
+
)
|
|
202
231
|
}
|
|
203
232
|
|
|
204
|
-
|
|
205
|
-
MediaCard.
|
|
206
|
-
MediaCard.
|
|
207
|
-
MediaCard.
|
|
208
|
-
MediaCard.
|
|
209
|
-
MediaCard.FooterSubtitle = FooterSubtitle;
|
|
233
|
+
MediaCard.Header = Header
|
|
234
|
+
MediaCard.Title = Title
|
|
235
|
+
MediaCard.Footer = Footer
|
|
236
|
+
MediaCard.FooterTitle = FooterTitle
|
|
237
|
+
MediaCard.FooterSubtitle = FooterSubtitle
|
|
210
238
|
|
|
211
|
-
export default MediaCard
|
|
239
|
+
export default MediaCard
|
package/src/components/index.ts
CHANGED
|
@@ -24,11 +24,12 @@ export { default as HoldingsCard, type HoldingsCardProps } from './HoldingsCard/
|
|
|
24
24
|
export { default as HStack, type HStackProps } from './HStack/HStack';
|
|
25
25
|
export { default as IconButton } from './IconButton/IconButton';
|
|
26
26
|
export { default as IconCapsule } from './IconCapsule/IconCapsule';
|
|
27
|
+
export { default as Image, type ImageProps } from './Image/Image';
|
|
27
28
|
export { default as LazyList } from './LazyList/LazyList';
|
|
28
29
|
export { default as LinearMeter, type LinearMeterProps } from './LinearMeter/LinearMeter';
|
|
29
30
|
export { default as ListGroup } from './ListGroup/ListGroup';
|
|
30
31
|
export { default as ListItem } from './ListItem/ListItem';
|
|
31
|
-
export { default as MediaCard } from './MediaCard/MediaCard';
|
|
32
|
+
export { default as MediaCard, type MediaCardProps } from './MediaCard/MediaCard';
|
|
32
33
|
export { default as MerchantProfile, type MerchantProfileProps } from './MerchantProfile/MerchantProfile';
|
|
33
34
|
export { default as MoneyValue } from './MoneyValue/MoneyValue';
|
|
34
35
|
export { default as NoteInput, type NoteInputProps } from './NoteInput/NoteInput';
|
package/src/icons/registry.ts
CHANGED