jfs-components 0.0.85 → 0.0.86
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 +7 -0
- package/lib/commonjs/components/AllocationComparisonChart/AllocationComparisonChart.js +299 -0
- package/lib/commonjs/components/FullscreenModal/FullscreenModal.js +52 -89
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/AllocationComparisonChart/AllocationComparisonChart.js +293 -0
- package/lib/module/components/FullscreenModal/FullscreenModal.js +53 -90
- package/lib/module/components/index.js +1 -0
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/AllocationComparisonChart/AllocationComparisonChart.d.ts +118 -0
- package/lib/typescript/src/components/FullscreenModal/FullscreenModal.d.ts +21 -25
- package/lib/typescript/src/components/index.d.ts +1 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AllocationComparisonChart/AllocationComparisonChart.tsx +450 -0
- package/src/components/FullscreenModal/FullscreenModal.tsx +61 -119
- package/src/components/index.ts +1 -0
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, Text } from 'react-native';
|
|
5
|
+
import Svg, { Line } from 'react-native-svg';
|
|
6
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
7
|
+
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
8
|
+
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
9
|
+
import MetricLegendItem from '../MetricLegendItem/MetricLegendItem';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One vertical pill in the {@link AllocationComparisonChartProps.data} array.
|
|
13
|
+
*
|
|
14
|
+
* Each segment renders a single bar whose **height encodes `value`** (the
|
|
15
|
+
* "current" reading) and, when supplied, a **`baseline`** overlay drawn from
|
|
16
|
+
* the bottom up with a dashed marker line (the "recommended" reading). Both
|
|
17
|
+
* are measured against the same shared scale so bars and baselines are
|
|
18
|
+
* directly comparable across segments.
|
|
19
|
+
*/
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
const DEFAULT_DATA = [{
|
|
22
|
+
label: 'Small & Mid',
|
|
23
|
+
value: 65,
|
|
24
|
+
baseline: 35
|
|
25
|
+
}, {
|
|
26
|
+
label: 'Large',
|
|
27
|
+
value: 25
|
|
28
|
+
}, {
|
|
29
|
+
label: 'Others',
|
|
30
|
+
value: 10
|
|
31
|
+
}];
|
|
32
|
+
const toNumber = (value, fallback) => {
|
|
33
|
+
if (typeof value === 'number') {
|
|
34
|
+
return Number.isFinite(value) ? value : fallback;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
const parsed = Number(value);
|
|
38
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
39
|
+
}
|
|
40
|
+
return fallback;
|
|
41
|
+
};
|
|
42
|
+
const toFontWeight = (value, fallback) => {
|
|
43
|
+
if (typeof value === 'number') {
|
|
44
|
+
return String(value);
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
return fallback;
|
|
50
|
+
};
|
|
51
|
+
const isShown = node => node !== undefined && node !== null && node !== false;
|
|
52
|
+
/**
|
|
53
|
+
* Internal: one vertical pill column (the Figma "Segment Indicator"). Not
|
|
54
|
+
* exported — the ergonomic public unit is the chart driven by `data`. The
|
|
55
|
+
* `segmentIndicator/*` token names are mirrored here so design ↔ code token
|
|
56
|
+
* alignment is preserved.
|
|
57
|
+
*/
|
|
58
|
+
function SegmentBar({
|
|
59
|
+
segment,
|
|
60
|
+
barHeightPx,
|
|
61
|
+
baselineHeightPx,
|
|
62
|
+
baselineLabel,
|
|
63
|
+
showMarker,
|
|
64
|
+
theme
|
|
65
|
+
}) {
|
|
66
|
+
const {
|
|
67
|
+
barWidth,
|
|
68
|
+
pillRadius,
|
|
69
|
+
gap,
|
|
70
|
+
currentColor,
|
|
71
|
+
baselineColor,
|
|
72
|
+
lineColor,
|
|
73
|
+
lineSize,
|
|
74
|
+
labelStyle
|
|
75
|
+
} = theme;
|
|
76
|
+
const fillColor = segment.color ?? currentColor;
|
|
77
|
+
const overlayColor = segment.baselineColor ?? baselineColor;
|
|
78
|
+
const showValueLabel = isShown(segment.valueLabel);
|
|
79
|
+
const hasBaseline = baselineHeightPx !== null && baselineHeightPx > 0;
|
|
80
|
+
const overlayHeight = hasBaseline ? Math.min(baselineHeightPx, barHeightPx) : 0;
|
|
81
|
+
const overlayRadius = Math.min(pillRadius, barWidth / 2, overlayHeight / 2);
|
|
82
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
83
|
+
style: {
|
|
84
|
+
flex: 1,
|
|
85
|
+
alignItems: 'center',
|
|
86
|
+
justifyContent: 'flex-end',
|
|
87
|
+
gap
|
|
88
|
+
},
|
|
89
|
+
accessibilityLabel: segment.accessibilityLabel,
|
|
90
|
+
children: [showValueLabel ? /*#__PURE__*/_jsx(Text, {
|
|
91
|
+
numberOfLines: 1,
|
|
92
|
+
style: labelStyle,
|
|
93
|
+
children: segment.valueLabel
|
|
94
|
+
}) : null, /*#__PURE__*/_jsx(View, {
|
|
95
|
+
style: {
|
|
96
|
+
width: barWidth,
|
|
97
|
+
height: Math.max(barHeightPx, 1),
|
|
98
|
+
borderRadius: pillRadius,
|
|
99
|
+
backgroundColor: fillColor,
|
|
100
|
+
position: 'relative'
|
|
101
|
+
},
|
|
102
|
+
children: hasBaseline ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
103
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
104
|
+
style: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
left: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
bottom: 0,
|
|
109
|
+
height: overlayHeight,
|
|
110
|
+
backgroundColor: overlayColor,
|
|
111
|
+
borderBottomLeftRadius: overlayRadius,
|
|
112
|
+
borderBottomRightRadius: overlayRadius
|
|
113
|
+
}
|
|
114
|
+
}), showMarker ? /*#__PURE__*/_jsxs(View, {
|
|
115
|
+
style: {
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
left: 0,
|
|
118
|
+
bottom: overlayHeight,
|
|
119
|
+
height: 0,
|
|
120
|
+
flexDirection: 'row',
|
|
121
|
+
alignItems: 'center'
|
|
122
|
+
},
|
|
123
|
+
pointerEvents: "none",
|
|
124
|
+
children: [/*#__PURE__*/_jsx(Svg, {
|
|
125
|
+
width: barWidth,
|
|
126
|
+
height: Math.max(lineSize, 1),
|
|
127
|
+
children: /*#__PURE__*/_jsx(Line, {
|
|
128
|
+
x1: 0,
|
|
129
|
+
y1: Math.max(lineSize, 1) / 2,
|
|
130
|
+
x2: barWidth,
|
|
131
|
+
y2: Math.max(lineSize, 1) / 2,
|
|
132
|
+
stroke: lineColor,
|
|
133
|
+
strokeWidth: lineSize,
|
|
134
|
+
strokeDasharray: "2 2"
|
|
135
|
+
})
|
|
136
|
+
}), isShown(baselineLabel) ? /*#__PURE__*/_jsx(Text, {
|
|
137
|
+
numberOfLines: 1,
|
|
138
|
+
style: [labelStyle, {
|
|
139
|
+
marginLeft: 6
|
|
140
|
+
}],
|
|
141
|
+
children: baselineLabel
|
|
142
|
+
}) : null]
|
|
143
|
+
}) : null]
|
|
144
|
+
}) : null
|
|
145
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
146
|
+
numberOfLines: 1,
|
|
147
|
+
style: labelStyle,
|
|
148
|
+
children: segment.label
|
|
149
|
+
})]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* `AllocationComparisonChart` plots a row of vertical pill bars that compare a
|
|
155
|
+
* **current** reading (each bar's height) against an optional **recommended**
|
|
156
|
+
* baseline (a filled overlay drawn from the bottom up, marked with a dashed
|
|
157
|
+
* line). Every bar and baseline shares a single scale, so heights are directly
|
|
158
|
+
* comparable across segments — no axes required.
|
|
159
|
+
*
|
|
160
|
+
* The chart is driven entirely by the `data` array: each entry pairs a
|
|
161
|
+
* `value`, an optional `baseline` and its `label`, so a bar can never drift
|
|
162
|
+
* out of sync with its caption or its baseline marker.
|
|
163
|
+
*
|
|
164
|
+
* Colors, fonts, spacing and the pill radius resolve from the Figma
|
|
165
|
+
* `segmentIndicator/*`, `metricLegendItem/*` and `allocationComparisonChart/*`
|
|
166
|
+
* tokens via the `modes` prop.
|
|
167
|
+
*
|
|
168
|
+
* @component
|
|
169
|
+
*/
|
|
170
|
+
function AllocationComparisonChart({
|
|
171
|
+
data = DEFAULT_DATA,
|
|
172
|
+
max,
|
|
173
|
+
height = 154,
|
|
174
|
+
barWidth,
|
|
175
|
+
showLegend = true,
|
|
176
|
+
valueLegendLabel = 'Current',
|
|
177
|
+
baselineLegendLabel = 'Recommended',
|
|
178
|
+
formatValue = value => `${value}%`,
|
|
179
|
+
modes: propModes = EMPTY_MODES,
|
|
180
|
+
style,
|
|
181
|
+
chartStyle,
|
|
182
|
+
legendStyle,
|
|
183
|
+
accessibilityLabel
|
|
184
|
+
}) {
|
|
185
|
+
const {
|
|
186
|
+
modes: globalModes
|
|
187
|
+
} = useTokens();
|
|
188
|
+
const modes = React.useMemo(() => ({
|
|
189
|
+
...globalModes,
|
|
190
|
+
...propModes
|
|
191
|
+
}), [globalModes, propModes]);
|
|
192
|
+
const trackWidth = toNumber(getVariableByName('segmentIndicator/track/width', modes), 28);
|
|
193
|
+
const resolvedBarWidth = barWidth ?? trackWidth;
|
|
194
|
+
const radiusToken = toNumber(getVariableByName('segmentIndicator/indicator/radius', modes), 99999);
|
|
195
|
+
const pillRadius = Math.min(radiusToken, resolvedBarWidth / 2);
|
|
196
|
+
const gap = toNumber(getVariableByName('segmentIndicator/gap', modes), 4);
|
|
197
|
+
const chartGap = toNumber(getVariableByName('allocationComparisonChart/gap', modes), 8);
|
|
198
|
+
const currentColor = getVariableByName('segmentIndicator/indicator/background', modes) ?? '#5d00b5';
|
|
199
|
+
const baselineColor = getVariableByName('segmentIndicator/indicator/foreground', modes) ?? '#b84fbd';
|
|
200
|
+
const lineColor = getVariableByName('segmentIndicator/indicator/line/color', modes) ?? '#ffffff';
|
|
201
|
+
const lineSize = toNumber(getVariableByName('segmentIndicator/indicator/line/size', modes), 1);
|
|
202
|
+
const foreground = getVariableByName('segmentIndicator/foreground', modes) ?? '#0c0d10';
|
|
203
|
+
const fontFamily = getVariableByName('segmentIndicator/fontFamily', modes) ?? 'JioType Var';
|
|
204
|
+
const fontSize = toNumber(getVariableByName('segmentIndicator/fontSize', modes), 12);
|
|
205
|
+
const lineHeight = toNumber(getVariableByName('segmentIndicator/lineHeight', modes), 12);
|
|
206
|
+
const fontWeight = toFontWeight(getVariableByName('segmentIndicator/fontWeight', modes), '400');
|
|
207
|
+
const labelStyle = {
|
|
208
|
+
color: foreground,
|
|
209
|
+
fontFamily,
|
|
210
|
+
fontSize,
|
|
211
|
+
lineHeight,
|
|
212
|
+
fontWeight,
|
|
213
|
+
textAlign: 'center'
|
|
214
|
+
};
|
|
215
|
+
const computedMax = max ?? data.reduce((acc, seg) => Math.max(acc, seg.value, seg.baseline ?? 0), 0);
|
|
216
|
+
const safeMax = computedMax > 0 ? computedMax : 1;
|
|
217
|
+
const firstBaselineIndex = data.findIndex(seg => typeof seg.baseline === 'number');
|
|
218
|
+
const hasAnyBaseline = firstBaselineIndex !== -1;
|
|
219
|
+
const theme = {
|
|
220
|
+
barWidth: resolvedBarWidth,
|
|
221
|
+
pillRadius,
|
|
222
|
+
gap,
|
|
223
|
+
currentColor,
|
|
224
|
+
baselineColor,
|
|
225
|
+
lineColor,
|
|
226
|
+
lineSize,
|
|
227
|
+
labelStyle
|
|
228
|
+
};
|
|
229
|
+
const defaultAccessibilityLabel = accessibilityLabel ?? `Allocation comparison of ${data.length} segment${data.length === 1 ? '' : 's'}: ` + data.map(seg => {
|
|
230
|
+
const label = typeof seg.label === 'string' ? seg.label : 'segment';
|
|
231
|
+
const base = typeof seg.baseline === 'number' ? `, recommended ${seg.baseline}` : '';
|
|
232
|
+
return `${label} ${seg.value}${base}`;
|
|
233
|
+
}).join('; ');
|
|
234
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
235
|
+
style: [{
|
|
236
|
+
width: '100%'
|
|
237
|
+
}, style],
|
|
238
|
+
accessibilityLabel: defaultAccessibilityLabel,
|
|
239
|
+
children: [showLegend ? /*#__PURE__*/_jsxs(View, {
|
|
240
|
+
style: [{
|
|
241
|
+
flexDirection: 'row',
|
|
242
|
+
alignItems: 'center',
|
|
243
|
+
gap: 8,
|
|
244
|
+
marginBottom: chartGap
|
|
245
|
+
}, legendStyle],
|
|
246
|
+
children: [/*#__PURE__*/_jsx(MetricLegendItem, {
|
|
247
|
+
label: valueLegendLabel,
|
|
248
|
+
indicatorColor: currentColor,
|
|
249
|
+
modes: modes,
|
|
250
|
+
style: {
|
|
251
|
+
flexGrow: 0,
|
|
252
|
+
flexShrink: 1
|
|
253
|
+
}
|
|
254
|
+
}), hasAnyBaseline ? /*#__PURE__*/_jsx(MetricLegendItem, {
|
|
255
|
+
label: baselineLegendLabel,
|
|
256
|
+
indicatorColor: baselineColor,
|
|
257
|
+
modes: modes,
|
|
258
|
+
style: {
|
|
259
|
+
flexGrow: 0,
|
|
260
|
+
flexShrink: 1
|
|
261
|
+
}
|
|
262
|
+
}) : null]
|
|
263
|
+
}) : null, /*#__PURE__*/_jsx(View, {
|
|
264
|
+
accessibilityRole: "image",
|
|
265
|
+
style: [{
|
|
266
|
+
flexDirection: 'row',
|
|
267
|
+
alignItems: 'flex-end',
|
|
268
|
+
gap: 8,
|
|
269
|
+
width: '100%'
|
|
270
|
+
}, chartStyle],
|
|
271
|
+
children: data.map((segment, index) => {
|
|
272
|
+
const ratio = Math.max(0, Math.min(1, segment.value / safeMax));
|
|
273
|
+
const barHeightPx = Math.max(0, height * ratio);
|
|
274
|
+
const baselineHeightPx = typeof segment.baseline === 'number' ? Math.max(0, Math.min(1, segment.baseline / safeMax)) * height : null;
|
|
275
|
+
const baselineLabel = segment.baselineLabel === undefined ? typeof segment.baseline === 'number' ? formatValue(segment.baseline) : undefined : segment.baselineLabel;
|
|
276
|
+
const resolvedSegment = {
|
|
277
|
+
...segment,
|
|
278
|
+
valueLabel: segment.valueLabel === undefined ? formatValue(segment.value) : segment.valueLabel
|
|
279
|
+
};
|
|
280
|
+
const showMarker = segment.showMarker ?? index === firstBaselineIndex;
|
|
281
|
+
return /*#__PURE__*/_jsx(SegmentBar, {
|
|
282
|
+
segment: resolvedSegment,
|
|
283
|
+
barHeightPx: barHeightPx,
|
|
284
|
+
baselineHeightPx: baselineHeightPx,
|
|
285
|
+
baselineLabel: baselineLabel,
|
|
286
|
+
showMarker: showMarker,
|
|
287
|
+
theme: theme
|
|
288
|
+
}, segment.key ?? `segment-${index}`);
|
|
289
|
+
})
|
|
290
|
+
})]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
export default AllocationComparisonChart;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
|
-
import { View, Text, ScrollView } from 'react-native';
|
|
5
|
-
import Animated, { Extrapolation, interpolate, useAnimatedScrollHandler, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { View, Text, ScrollView, StyleSheet } from 'react-native';
|
|
6
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
7
6
|
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
8
7
|
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
@@ -29,22 +28,11 @@ const FULLSCREEN_MODAL_FORCED_MODES = Object.freeze({
|
|
|
29
28
|
context5: 'Fullscreen Modal'
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
// Reanimated-driven ScrollView so the parallax handler runs on the UI thread.
|
|
33
|
-
// Module scope so the wrapped component identity is stable across renders.
|
|
34
|
-
const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
|
|
35
|
-
|
|
36
|
-
// Parallax tuning. The hero collapses by HEIGHT only as the user scrolls up —
|
|
37
|
-
// its full width is preserved and the media keeps a fixed aspect ratio (it is
|
|
38
|
-
// cropped, never scaled or squished, like a `cover` background). When no
|
|
39
|
-
// explicit `heroMinHeight` is given, the hero collapses to this fraction of
|
|
40
|
-
// its resting height.
|
|
41
|
-
const HERO_MIN_HEIGHT_RATIO = 0.45;
|
|
42
|
-
|
|
43
31
|
// ---------------------------------------------------------------------------
|
|
44
32
|
// Hero text — the eyebrow / headline / supporting / price block. Built inline
|
|
45
33
|
// (rather than reusing <PageHero>) so we can render BOTH a supporting
|
|
46
34
|
// paragraph AND a price line with the exact PageHero token gaps, and overlay
|
|
47
|
-
// it on the
|
|
35
|
+
// it on the hero media without PageHero's media/button scaffolding.
|
|
48
36
|
// ---------------------------------------------------------------------------
|
|
49
37
|
|
|
50
38
|
function HeroText({
|
|
@@ -129,8 +117,9 @@ function HeroText({
|
|
|
129
117
|
}
|
|
130
118
|
|
|
131
119
|
/**
|
|
132
|
-
* FullscreenModal — a full-screen takeover surface with a
|
|
133
|
-
* a scrollable body, a floating close button, and a sticky
|
|
120
|
+
* FullscreenModal — a full-screen takeover surface with a full-bleed media
|
|
121
|
+
* hero, a scrollable body, a floating close button, and a sticky
|
|
122
|
+
* `ActionFooter`.
|
|
134
123
|
*
|
|
135
124
|
* The component always themes itself with `context5: 'Fullscreen Modal'`
|
|
136
125
|
* (non-overridable) so every nested component (Section, ListItem, Button,
|
|
@@ -138,14 +127,12 @@ function HeroText({
|
|
|
138
127
|
* That mode is cascaded into `children`, the footer, and the hero text via
|
|
139
128
|
* `cloneChildrenWithModes` / the merged `modes` object.
|
|
140
129
|
*
|
|
141
|
-
* ###
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* scrolls, the media lags behind for the parallax depth cue. Disable with
|
|
148
|
-
* `parallax={false}`.
|
|
130
|
+
* ### Hero
|
|
131
|
+
* The `heroMedia` is rendered full modal width inside the scroll body and
|
|
132
|
+
* takes its height from its own aspect ratio. The hero text (eyebrow /
|
|
133
|
+
* headline / supporting / price) is overlaid on top, anchored to the bottom.
|
|
134
|
+
* The whole hero scrolls together with the rest of the content — there is no
|
|
135
|
+
* parallax effect.
|
|
149
136
|
*
|
|
150
137
|
* @component
|
|
151
138
|
* @example
|
|
@@ -155,7 +142,7 @@ function HeroText({
|
|
|
155
142
|
* headline="Get more from your money."
|
|
156
143
|
* supportingText="JioFinance+ is your upgraded financial experience…"
|
|
157
144
|
* priceText="₹999/year · ₹0 until 2027"
|
|
158
|
-
* heroMedia={<
|
|
145
|
+
* heroMedia={<Image imageSource={hero} ratio={3 / 4} />}
|
|
159
146
|
* primaryActionLabel="Upgrade for free"
|
|
160
147
|
* disclaimer="By upgrading, we'll check your eligibility with Experian."
|
|
161
148
|
* onPrimaryAction={() => upgrade()}
|
|
@@ -173,8 +160,6 @@ function FullscreenModal({
|
|
|
173
160
|
priceText = '₹999/year · ₹0 until 2027',
|
|
174
161
|
heroMedia,
|
|
175
162
|
heroHeight = 420,
|
|
176
|
-
heroMinHeight,
|
|
177
|
-
parallax = true,
|
|
178
163
|
showClose = true,
|
|
179
164
|
onClose,
|
|
180
165
|
closeAccessibilityLabel = 'Close',
|
|
@@ -201,49 +186,13 @@ function FullscreenModal({
|
|
|
201
186
|
...FULLSCREEN_MODAL_FORCED_MODES
|
|
202
187
|
}), [globalModes, propModes]);
|
|
203
188
|
const rootGap = Number(getVariableByName('fullScreenModal/gap', modes)) || 16;
|
|
204
|
-
const minHeight = heroMinHeight ?? Math.round(heroHeight * HERO_MIN_HEIGHT_RATIO);
|
|
205
|
-
const scrollY = useSharedValue(0);
|
|
206
|
-
const onScroll = useAnimatedScrollHandler(event => {
|
|
207
|
-
scrollY.value = event.contentOffset.y;
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Collapse the hero by HEIGHT only as the user scrolls up. The clip's width
|
|
211
|
-
// never changes and the media inside is pinned full-size at the top, so the
|
|
212
|
-
// art is cropped (cover) rather than scaled or narrowed — it keeps a perfect
|
|
213
|
-
// aspect ratio the whole time. Pull-down (negative offset) is clamped, so the
|
|
214
|
-
// hero never grows past its resting height.
|
|
215
|
-
const heroAnimatedStyle = useAnimatedStyle(() => {
|
|
216
|
-
const height = interpolate(scrollY.value, [0, heroHeight], [heroHeight, minHeight], Extrapolation.CLAMP);
|
|
217
|
-
return {
|
|
218
|
-
height
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
189
|
const processedHeroMedia = useMemo(() => heroMedia ? cloneChildrenWithModes(heroMedia, modes, FULLSCREEN_MODAL_FORCED_MODES) : null, [heroMedia, modes]);
|
|
222
190
|
const processedChildren = useMemo(() => children ? cloneChildrenWithModes(children, modes, FULLSCREEN_MODAL_FORCED_MODES) : null, [children, modes]);
|
|
223
191
|
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
top: 0,
|
|
229
|
-
left: 0,
|
|
230
|
-
right: 0,
|
|
231
|
-
overflow: 'hidden'
|
|
232
|
-
}), []);
|
|
233
|
-
|
|
234
|
-
// The media sits at a fixed full-size box pinned to the top of the clip, so
|
|
235
|
-
// the collapsing clip crops it from the bottom (cover) instead of resizing
|
|
236
|
-
// it. Full width, fixed height — a perfect, constant aspect ratio.
|
|
237
|
-
const heroMediaWrapStyle = useMemo(() => ({
|
|
238
|
-
position: 'absolute',
|
|
239
|
-
top: 0,
|
|
240
|
-
left: 0,
|
|
241
|
-
right: 0,
|
|
242
|
-
height: heroHeight,
|
|
243
|
-
alignItems: 'stretch'
|
|
244
|
-
}), [heroHeight]);
|
|
245
|
-
const heroTextRegionStyle = useMemo(() => ({
|
|
246
|
-
height: heroHeight,
|
|
192
|
+
// No-media fallback: without hero media the text region needs an explicit
|
|
193
|
+
// resting height (driven by `heroHeight`) so the hero still has presence.
|
|
194
|
+
const heroTextFallbackStyle = useMemo(() => ({
|
|
195
|
+
minHeight: heroHeight,
|
|
247
196
|
justifyContent: 'flex-end',
|
|
248
197
|
paddingHorizontal: 16,
|
|
249
198
|
paddingBottom: 16
|
|
@@ -254,15 +203,28 @@ function FullscreenModal({
|
|
|
254
203
|
paddingTop: rootGap,
|
|
255
204
|
paddingBottom: 24
|
|
256
205
|
}, contentContainerStyle], [backgroundColor, rootGap, contentContainerStyle]);
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
206
|
+
const heroTextNode = /*#__PURE__*/_jsx(HeroText, {
|
|
207
|
+
eyebrow: eyebrow,
|
|
208
|
+
headline: headline,
|
|
209
|
+
supportingText: supportingText,
|
|
210
|
+
priceText: priceText,
|
|
211
|
+
modes: modes
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// The hero scrolls inline with the body (no parallax). When media is present
|
|
215
|
+
// it is laid out full modal width and takes its height from its own aspect
|
|
216
|
+
// ratio; the hero text is overlaid on top, anchored to the bottom. Without
|
|
217
|
+
// media the text simply renders in flow at the fallback height.
|
|
218
|
+
const hero = processedHeroMedia ? /*#__PURE__*/_jsxs(View, {
|
|
219
|
+
style: heroMediaContainerStyle,
|
|
220
|
+
children: [processedHeroMedia, /*#__PURE__*/_jsx(View, {
|
|
221
|
+
style: heroTextOverlayStyle,
|
|
222
|
+
pointerEvents: "box-none",
|
|
223
|
+
children: heroTextNode
|
|
224
|
+
})]
|
|
225
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
226
|
+
style: heroTextFallbackStyle,
|
|
227
|
+
children: heroTextNode
|
|
266
228
|
});
|
|
267
229
|
|
|
268
230
|
// Footer: a fully custom node, or the default Button + Disclaimer column.
|
|
@@ -291,26 +253,15 @@ function FullscreenModal({
|
|
|
291
253
|
backgroundColor
|
|
292
254
|
}, style],
|
|
293
255
|
testID: testID,
|
|
294
|
-
children: [
|
|
256
|
+
children: [/*#__PURE__*/_jsxs(ScrollView, {
|
|
295
257
|
style: scrollViewStyle,
|
|
296
258
|
contentContainerStyle: scrollContentStyle,
|
|
297
|
-
showsVerticalScrollIndicator: false
|
|
298
|
-
onScroll: onScroll,
|
|
299
|
-
scrollEventThrottle: 16
|
|
259
|
+
showsVerticalScrollIndicator: false
|
|
300
260
|
// Tap an input in the body and it focuses on the FIRST tap, even when
|
|
301
261
|
// the keyboard is already open (default 'never' eats that tap).
|
|
302
262
|
,
|
|
303
263
|
keyboardShouldPersistTaps: "handled",
|
|
304
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
305
|
-
style: heroTextRegionStyle,
|
|
306
|
-
children: /*#__PURE__*/_jsx(HeroText, {
|
|
307
|
-
eyebrow: eyebrow,
|
|
308
|
-
headline: headline,
|
|
309
|
-
supportingText: supportingText,
|
|
310
|
-
priceText: priceText,
|
|
311
|
-
modes: modes
|
|
312
|
-
})
|
|
313
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
264
|
+
children: [hero, /*#__PURE__*/_jsx(View, {
|
|
314
265
|
style: bodyStyle,
|
|
315
266
|
children: processedChildren
|
|
316
267
|
})]
|
|
@@ -349,4 +300,16 @@ const closeButtonStyle = {
|
|
|
349
300
|
top: 12,
|
|
350
301
|
right: 12
|
|
351
302
|
};
|
|
303
|
+
// Full-width hero wrapper; height comes from the media's own aspect ratio.
|
|
304
|
+
const heroMediaContainerStyle = {
|
|
305
|
+
width: '100%',
|
|
306
|
+
position: 'relative'
|
|
307
|
+
};
|
|
308
|
+
// Hero text overlaid on the media, anchored to the bottom edge.
|
|
309
|
+
const heroTextOverlayStyle = {
|
|
310
|
+
...StyleSheet.absoluteFillObject,
|
|
311
|
+
justifyContent: 'flex-end',
|
|
312
|
+
paddingHorizontal: 16,
|
|
313
|
+
paddingBottom: 16
|
|
314
|
+
};
|
|
352
315
|
export default FullscreenModal;
|
|
@@ -39,6 +39,7 @@ export { default as CircularProgressBarDoted } from './CircularProgressBarDoted/
|
|
|
39
39
|
export { default as CircularRating } from './CircularRating/CircularRating';
|
|
40
40
|
export { default as CoverageRing } from './CoverageRing/CoverageRing';
|
|
41
41
|
export { default as CoverageBarComparison } from './CoverageBarComparison/CoverageBarComparison';
|
|
42
|
+
export { default as AllocationComparisonChart } from './AllocationComparisonChart/AllocationComparisonChart';
|
|
42
43
|
export { default as MonthlyStatusGrid, CalendarGlyph } from './MonthlyStatusGrid/MonthlyStatusGrid';
|
|
43
44
|
export { default as Gauge } from './Gauge/Gauge';
|
|
44
45
|
export { default as HoldingsCard } from './HoldingsCard/HoldingsCard';
|