jfs-components 0.1.34 → 0.1.36
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 +14 -0
- package/D2C.md +82 -87
- package/lib/commonjs/components/LottiePlayer/LottiePlayer.js +5 -5
- package/lib/commonjs/components/LottiePlayer/LottiePlayer.web.js +2 -2
- package/lib/commonjs/components/PageHero/PageHero.js +73 -76
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +42204 -1
- package/lib/commonjs/design-tokens/figma-modes.generated.js +52 -37
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/LottiePlayer/LottiePlayer.js +5 -5
- package/lib/module/components/LottiePlayer/LottiePlayer.web.js +2 -2
- package/lib/module/components/PageHero/PageHero.js +73 -76
- package/lib/module/design-tokens/Coin Variables-variables-full.json +42204 -1
- package/lib/module/design-tokens/figma-modes.generated.js +52 -37
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/LottiePlayer/LottiePlayer.d.ts +6 -6
- package/lib/typescript/src/components/PageHero/PageHero.d.ts +33 -25
- package/lib/typescript/src/design-tokens/figma-modes.generated.d.ts +14 -1
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +3 -1
- package/scripts/extract-figma-modes.js +150 -121
- package/src/components/LottiePlayer/LottiePlayer.tsx +8 -8
- package/src/components/LottiePlayer/LottiePlayer.web.tsx +2 -2
- package/src/components/PageHero/PageHero.tsx +142 -106
- package/src/design-tokens/Coin Variables-variables-full.json +42204 -1
- package/src/design-tokens/figma-modes.generated.ts +52 -37
- package/src/icons/registry.ts +1 -1
|
@@ -12,15 +12,26 @@ import Button from '../Button/Button'
|
|
|
12
12
|
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils'
|
|
13
13
|
import type { Modes } from '../../design-tokens'
|
|
14
14
|
|
|
15
|
+
// Figma media frame is 117×117 ("Video / Output" L). Used when the token
|
|
16
|
+
// collection is missing from a consumer's variables JSON so the media slot
|
|
17
|
+
// never collapses to 0.
|
|
18
|
+
const MEDIA_FALLBACK = 117
|
|
19
|
+
|
|
15
20
|
export type PageHeroProps = {
|
|
16
21
|
/** Small eyebrow text shown above the headline. */
|
|
17
22
|
eyebrow?: string
|
|
23
|
+
/** Whether to render the eyebrow line. */
|
|
24
|
+
showEyebrow?: boolean
|
|
18
25
|
/** Main headline text. Centered and bold. */
|
|
19
26
|
headline?: string
|
|
20
|
-
/**
|
|
27
|
+
/** Supporting text shown directly below the headline (e.g. price). */
|
|
21
28
|
supportingText?: string
|
|
22
29
|
/** Whether to render the supporting text. */
|
|
23
30
|
showSupportingText?: boolean
|
|
31
|
+
/** Optional second supporting line shown below `supportingText`. */
|
|
32
|
+
body?: string
|
|
33
|
+
/** Whether to render the body line. */
|
|
34
|
+
showBody?: boolean
|
|
24
35
|
/** Label for the default action button. Ignored when `buttonSlot` is provided. */
|
|
25
36
|
buttonLabel?: string
|
|
26
37
|
/** Press handler for the default action button. Ignored when `buttonSlot` is provided. */
|
|
@@ -28,9 +39,10 @@ export type PageHeroProps = {
|
|
|
28
39
|
/** Whether to render the default action button. Ignored when `buttonSlot` is provided. */
|
|
29
40
|
showButton?: boolean
|
|
30
41
|
/**
|
|
31
|
-
* Optional slot to fully override the action button.
|
|
32
|
-
* When provided, `showButton`,
|
|
33
|
-
* `
|
|
42
|
+
* Optional slot to fully override the action button area (e.g. a
|
|
43
|
+
* `ButtonGroup` with several buttons). When provided, `showButton`,
|
|
44
|
+
* `buttonLabel`, and `onButtonPress` are ignored. `modes` are automatically
|
|
45
|
+
* cascaded into this slot.
|
|
34
46
|
*/
|
|
35
47
|
buttonSlot?: React.ReactNode
|
|
36
48
|
/**
|
|
@@ -38,16 +50,18 @@ export type PageHeroProps = {
|
|
|
38
50
|
*
|
|
39
51
|
* Intentionally typed as `React.ReactNode` so the consumer can bring any
|
|
40
52
|
* renderer they like — `<Image />`, `<IconCapsule />`, a Lottie player
|
|
41
|
-
* (`
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
53
|
+
* (`LottiePlayer` / `lottie-react-native`), an `<SvgXml />` from
|
|
54
|
+
* `react-native-svg`, a `<Video />` from `react-native-video`, a gradient
|
|
55
|
+
* view, or a custom illustration. The library deliberately does NOT wrap
|
|
56
|
+
* Lottie / video runtimes (they require native modules + pod autolinking on
|
|
57
|
+
* every consumer's app), so PageHero just allocates a token-sized container
|
|
58
|
+
* and lets the slot render whatever it wants.
|
|
47
59
|
*
|
|
48
|
-
* The slot is rendered inside a `width × height` box driven by
|
|
49
|
-
* `
|
|
50
|
-
*
|
|
60
|
+
* The slot is rendered inside a `width × height` box driven by the
|
|
61
|
+
* `video/width` and `video/height` tokens from the `Video / Output`
|
|
62
|
+
* collection (`L | M | S` → 117 / 70 / 20; default `L` = 117×117).
|
|
63
|
+
* `modes` are automatically cascaded into the slot via
|
|
64
|
+
* `cloneChildrenWithModes`.
|
|
51
65
|
*/
|
|
52
66
|
media?: React.ReactNode
|
|
53
67
|
/** Mode configuration for design-token theming. */
|
|
@@ -61,12 +75,16 @@ export type PageHeroProps = {
|
|
|
61
75
|
* PageHero displays a centered hero block typically used at the top of a page
|
|
62
76
|
* or feature screen. It contains an optional media slot (illustration / image
|
|
63
77
|
* / Lottie / SVG / video — consumer's choice), an eyebrow line, a large
|
|
64
|
-
* headline, an optional supporting line (e.g. price
|
|
65
|
-
* optional action button.
|
|
78
|
+
* headline, an optional supporting line (e.g. price), an optional body line
|
|
79
|
+
* (e.g. timeline), and an optional action button.
|
|
66
80
|
*
|
|
67
81
|
* All visual values are resolved from Figma design tokens via
|
|
68
|
-
* `getVariableByName
|
|
69
|
-
*
|
|
82
|
+
* `getVariableByName` (Figma node 4453:2348 — "Page Hero"). Text colors react
|
|
83
|
+
* to the `Page type` (`MainPage | SubPage | JioPlus`) and `Color Mode`
|
|
84
|
+
* (`Light | Dark`) collections; type scale reacts to `PageHero Size`
|
|
85
|
+
* (`M | S`); the media box reacts to `Video / Output` (`L | M | S`). Slots
|
|
86
|
+
* cascade the active `modes` to their children through
|
|
87
|
+
* `cloneChildrenWithModes`.
|
|
70
88
|
*
|
|
71
89
|
* @component
|
|
72
90
|
* @example
|
|
@@ -77,21 +95,19 @@ export type PageHeroProps = {
|
|
|
77
95
|
* supportingText="₹999/year · ₹0 until 2027"
|
|
78
96
|
* buttonLabel="Renew for free"
|
|
79
97
|
* onButtonPress={() => navigate('Upgrade')}
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* imageSource={require('./assets/upgrade.png')}
|
|
83
|
-
* width={117}
|
|
84
|
-
* height={117}
|
|
85
|
-
* />
|
|
86
|
-
* }
|
|
98
|
+
* modes={{ 'Page type': 'JioPlus' }}
|
|
99
|
+
* media={<LottiePlayer source={animation} />}
|
|
87
100
|
* />
|
|
88
101
|
* ```
|
|
89
102
|
*/
|
|
90
103
|
function PageHero({
|
|
91
104
|
eyebrow = 'Upgrade to JioFinance+',
|
|
105
|
+
showEyebrow = true,
|
|
92
106
|
headline = 'Resume earning cashback, extra points, and 1% gold',
|
|
93
107
|
supportingText = '₹999/year · ₹0 until 2027',
|
|
94
108
|
showSupportingText = true,
|
|
109
|
+
body,
|
|
110
|
+
showBody = true,
|
|
95
111
|
buttonLabel = 'Renew for free',
|
|
96
112
|
onButtonPress,
|
|
97
113
|
showButton = true,
|
|
@@ -108,51 +124,99 @@ function PageHero({
|
|
|
108
124
|
)
|
|
109
125
|
|
|
110
126
|
const gap = Number(getVariableByName('PageHero/gap', modes))
|
|
111
|
-
const
|
|
112
|
-
Number(getVariableByName('PageHero/padding/horizontal', modes))
|
|
127
|
+
const textWrapGap = Number(getVariableByName('PageHero/textWrap/gap', modes))
|
|
113
128
|
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
// Media slot box — Figma frame 4540:7845 ("Video"), sized by the
|
|
130
|
+
// `Video / Output` collection (L=117, M=70, S=20). Falls back to 117 when
|
|
131
|
+
// the collection is absent so the slot never collapses to 0×0.
|
|
132
|
+
const mediaWidth =
|
|
133
|
+
Number(getVariableByName('video/width', modes)) || MEDIA_FALLBACK
|
|
134
|
+
const mediaHeight =
|
|
135
|
+
Number(getVariableByName('video/height', modes)) || MEDIA_FALLBACK
|
|
116
136
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
const eyebrowStyle = useMemo<TextStyle>(
|
|
138
|
+
() => ({
|
|
139
|
+
color: getVariableByName('PageHero/eyebrow/color', modes) as string,
|
|
140
|
+
fontFamily: getVariableByName(
|
|
141
|
+
'PageHero/eyebrow/fontFamily',
|
|
142
|
+
modes
|
|
143
|
+
) as string,
|
|
144
|
+
fontSize: Number(getVariableByName('PageHero/eyebrow/fontSize', modes)),
|
|
145
|
+
fontWeight: String(
|
|
146
|
+
getVariableByName('PageHero/eyebrow/fontWeight', modes)
|
|
147
|
+
) as TextStyle['fontWeight'],
|
|
148
|
+
lineHeight: Number(
|
|
149
|
+
getVariableByName('PageHero/eyebrow/lineHeight', modes)
|
|
150
|
+
),
|
|
151
|
+
textAlign: 'center',
|
|
152
|
+
}),
|
|
153
|
+
[modes]
|
|
154
|
+
)
|
|
122
155
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
156
|
+
const headlineStyle = useMemo<TextStyle>(
|
|
157
|
+
() => ({
|
|
158
|
+
color: getVariableByName('PageHero/headline/color', modes) as string,
|
|
159
|
+
fontFamily: getVariableByName(
|
|
160
|
+
'PageHero/headline/fontFamily',
|
|
161
|
+
modes
|
|
162
|
+
) as string,
|
|
163
|
+
fontSize: Number(getVariableByName('PageHero/headline/fontSize', modes)),
|
|
164
|
+
fontWeight: String(
|
|
165
|
+
getVariableByName('PageHero/headline/fontWeight', modes)
|
|
166
|
+
) as TextStyle['fontWeight'],
|
|
167
|
+
lineHeight: Number(
|
|
168
|
+
getVariableByName('PageHero/headline/lineHeight', modes)
|
|
169
|
+
),
|
|
170
|
+
textAlign: 'center',
|
|
171
|
+
width: '100%',
|
|
172
|
+
}),
|
|
173
|
+
[modes]
|
|
174
|
+
)
|
|
133
175
|
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
const supportingTextStyle = useMemo<TextStyle>(
|
|
177
|
+
() => ({
|
|
178
|
+
color: getVariableByName(
|
|
179
|
+
'PageHero/supportingText/color',
|
|
180
|
+
modes
|
|
181
|
+
) as string,
|
|
182
|
+
fontFamily: getVariableByName(
|
|
183
|
+
'PageHero/supportingText/fontFamily',
|
|
184
|
+
modes
|
|
185
|
+
) as string,
|
|
186
|
+
fontSize: Number(
|
|
187
|
+
getVariableByName('PageHero/supportingText/fontSize', modes)
|
|
188
|
+
),
|
|
189
|
+
fontWeight: String(
|
|
190
|
+
getVariableByName('PageHero/supportingText/fontWeight', modes)
|
|
191
|
+
) as TextStyle['fontWeight'],
|
|
192
|
+
lineHeight: Number(
|
|
193
|
+
getVariableByName('PageHero/supportingText/lineHeight', modes)
|
|
194
|
+
),
|
|
195
|
+
textAlign: 'center',
|
|
196
|
+
}),
|
|
197
|
+
[modes]
|
|
198
|
+
)
|
|
144
199
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
200
|
+
const bodyStyle = useMemo<TextStyle>(
|
|
201
|
+
() => ({
|
|
202
|
+
color: getVariableByName('PageHero/body/color', modes) as string,
|
|
203
|
+
fontFamily: getVariableByName(
|
|
204
|
+
'PageHero/body/fontFamily',
|
|
205
|
+
modes
|
|
206
|
+
) as string,
|
|
207
|
+
fontSize: Number(getVariableByName('PageHero/body/fontSize', modes)),
|
|
208
|
+
fontWeight: String(
|
|
209
|
+
getVariableByName('PageHero/body/fontWeight', modes)
|
|
210
|
+
) as TextStyle['fontWeight'],
|
|
211
|
+
lineHeight: Number(getVariableByName('PageHero/body/lineHeight', modes)),
|
|
212
|
+
textAlign: 'center',
|
|
213
|
+
}),
|
|
214
|
+
[modes]
|
|
215
|
+
)
|
|
151
216
|
|
|
152
217
|
const containerStyle: ViewStyle = {
|
|
153
218
|
flexDirection: 'column',
|
|
154
219
|
alignItems: 'center',
|
|
155
|
-
paddingHorizontal,
|
|
156
220
|
gap,
|
|
157
221
|
width: '100%',
|
|
158
222
|
}
|
|
@@ -164,38 +228,6 @@ function PageHero({
|
|
|
164
228
|
width: '100%',
|
|
165
229
|
}
|
|
166
230
|
|
|
167
|
-
const eyebrowStyle: TextStyle = {
|
|
168
|
-
color: eyebrowColor as string,
|
|
169
|
-
fontFamily: eyebrowFontFamily as string,
|
|
170
|
-
fontSize: eyebrowFontSize,
|
|
171
|
-
fontWeight: String(eyebrowFontWeight) as TextStyle['fontWeight'],
|
|
172
|
-
lineHeight: eyebrowLineHeight,
|
|
173
|
-
textAlign: 'center',
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const headlineStyle: TextStyle = {
|
|
177
|
-
color: headlineColor as string,
|
|
178
|
-
fontFamily: headlineFontFamily as string,
|
|
179
|
-
fontSize: headlineFontSize,
|
|
180
|
-
fontWeight: String(headlineFontWeight) as TextStyle['fontWeight'],
|
|
181
|
-
lineHeight: headlineLineHeight,
|
|
182
|
-
textAlign: 'center',
|
|
183
|
-
width: '100%',
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const supportingTextStyle: TextStyle = {
|
|
187
|
-
color: '#ffffff',
|
|
188
|
-
fontFamily: 'System',
|
|
189
|
-
fontSize: 12,
|
|
190
|
-
fontWeight: '500',
|
|
191
|
-
lineHeight: supportingTextLineHeight,
|
|
192
|
-
textAlign: 'center',
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const buttonWrapStyle: ViewStyle = {
|
|
196
|
-
width: '100%',
|
|
197
|
-
}
|
|
198
|
-
|
|
199
231
|
const buttonContent = useMemo<React.ReactNode>(() => {
|
|
200
232
|
if (buttonSlot !== undefined && buttonSlot !== null) {
|
|
201
233
|
return cloneChildrenWithModes(buttonSlot, modes)
|
|
@@ -208,21 +240,17 @@ function PageHero({
|
|
|
208
240
|
label={buttonLabel}
|
|
209
241
|
onPress={onButtonPress}
|
|
210
242
|
modes={modes}
|
|
211
|
-
style={
|
|
243
|
+
style={FULL_WIDTH}
|
|
212
244
|
/>
|
|
213
245
|
)
|
|
214
|
-
// buttonWrapStyle is a literal object created above; it is intentionally
|
|
215
|
-
// omitted from deps because its identity changes on every render but its
|
|
216
|
-
// shape never does.
|
|
217
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
218
246
|
}, [buttonSlot, showButton, buttonLabel, onButtonPress, modes])
|
|
219
247
|
|
|
220
248
|
// Sized container for the media slot. Always rendered when `media` is
|
|
221
|
-
// provided, so the slot has a predictable box (
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
// `clipsContent` so a slightly oversized illustration doesn't break
|
|
225
|
-
//
|
|
249
|
+
// provided, so the slot has a predictable box (Figma frame 4540:7845 —
|
|
250
|
+
// 117×117 at `Video / Output = L`) even if the inner element omits its own
|
|
251
|
+
// width/height. `overflow: 'hidden'` mirrors the Figma frame's
|
|
252
|
+
// `clipsContent` so a slightly oversized illustration doesn't break the
|
|
253
|
+
// centered layout.
|
|
226
254
|
const mediaContent = useMemo<React.ReactNode>(() => {
|
|
227
255
|
if (media === undefined || media === null) return null
|
|
228
256
|
return (
|
|
@@ -240,19 +268,27 @@ function PageHero({
|
|
|
240
268
|
)
|
|
241
269
|
}, [media, mediaWidth, mediaHeight, modes])
|
|
242
270
|
|
|
271
|
+
const hasEyebrow = showEyebrow && !!eyebrow
|
|
272
|
+
const hasHeadline = !!headline
|
|
273
|
+
|
|
243
274
|
return (
|
|
244
275
|
<View style={[containerStyle, style]} testID={testID}>
|
|
245
276
|
{mediaContent}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
277
|
+
{hasEyebrow || hasHeadline ? (
|
|
278
|
+
<View style={textWrapStyle}>
|
|
279
|
+
{hasEyebrow ? <Text style={eyebrowStyle}>{eyebrow}</Text> : null}
|
|
280
|
+
{hasHeadline ? <Text style={headlineStyle}>{headline}</Text> : null}
|
|
281
|
+
</View>
|
|
282
|
+
) : null}
|
|
250
283
|
{showSupportingText && supportingText ? (
|
|
251
284
|
<Text style={supportingTextStyle}>{supportingText}</Text>
|
|
252
285
|
) : null}
|
|
286
|
+
{showBody && body ? <Text style={bodyStyle}>{body}</Text> : null}
|
|
253
287
|
{buttonContent}
|
|
254
288
|
</View>
|
|
255
289
|
)
|
|
256
290
|
}
|
|
257
291
|
|
|
292
|
+
const FULL_WIDTH: ViewStyle = { width: '100%' }
|
|
293
|
+
|
|
258
294
|
export default PageHero
|