jfs-components 0.1.2 → 0.1.12
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 +45 -0
- package/lib/commonjs/components/Accordion/Accordion.js +2 -1
- package/lib/commonjs/components/AccordionCheckbox/AccordionCheckbox.js +4 -3
- package/lib/commonjs/components/AccountCard/AccountCard.js +4 -3
- package/lib/commonjs/components/AllocationComparisonChart/AllocationComparisonChart.js +9 -6
- package/lib/commonjs/components/AmountInput/AmountInput.js +8 -5
- package/lib/commonjs/components/AreaLineChart/AreaLineChart.js +11 -7
- package/lib/commonjs/components/Badge/Badge.js +47 -8
- package/lib/commonjs/components/BenefitCard/BenefitCard.js +231 -0
- package/lib/commonjs/components/BrandChip/BrandChip.js +3 -3
- package/lib/commonjs/components/Button/Button.js +2 -1
- package/lib/commonjs/components/CardAdvisory/CardAdvisory.js +2 -1
- package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +3 -2
- package/lib/commonjs/components/CardCTA/CardCTA.js +197 -27
- package/lib/commonjs/components/CardInsight/CardInsight.js +5 -1
- package/lib/commonjs/components/CcCard/CcCard.js +470 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +4 -3
- package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +4 -3
- package/lib/commonjs/components/CircularProgressBar/CircularProgressBar.js +7 -3
- package/lib/commonjs/components/CircularProgressBarDoted/CircularProgressBarDoted.js +3 -2
- package/lib/commonjs/components/CircularRating/CircularRating.js +2 -1
- package/lib/commonjs/components/ClusterBubble/ClusterBubble.js +3 -2
- package/lib/commonjs/components/CompareTable/CompareTable.js +401 -0
- package/lib/commonjs/components/ComparisonBar/ComparisonBar.js +266 -0
- package/lib/commonjs/components/CoverageBarComparison/CoverageBarComparison.js +3 -2
- package/lib/commonjs/components/DonutChart/DonutChart.js +4 -3
- package/lib/commonjs/components/Dropdown/Dropdown.js +3 -2
- package/lib/commonjs/components/DropdownInput/DropdownInput.js +38 -5
- package/lib/commonjs/components/ExpandableCheckbox/ExpandableCheckbox.js +2 -1
- package/lib/commonjs/components/FormField/FormField.js +45 -4
- package/lib/commonjs/components/Gauge/Gauge.js +1 -1
- package/lib/commonjs/components/HoldingsCard/HoldingsCard.js +3 -2
- package/lib/commonjs/components/InputSearch/InputSearch.js +6 -4
- package/lib/commonjs/components/InstitutionBadge/InstitutionBadge.js +2 -1
- package/lib/commonjs/components/ListGroup/ListGroup.js +2 -1
- package/lib/commonjs/components/ListItem/ListItem.js +3 -2
- package/lib/commonjs/components/MediaCard/MediaCard.js +4 -2
- package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +3 -2
- package/lib/commonjs/components/MonthlyStatusGrid/MonthlyStatusGrid.js +6 -3
- package/lib/commonjs/components/NoteInput/NoteInput.js +6 -5
- package/lib/commonjs/components/PdpCcCard/PdpCcCard.js +273 -0
- package/lib/commonjs/components/PoweredByLabel/PoweredByLabel.js +3 -2
- package/lib/commonjs/components/ProductMerchandisingCard/ProductMerchandisingCard.js +427 -0
- package/lib/commonjs/components/ProductOverview/ProductOverview.js +4 -3
- package/lib/commonjs/components/ProgressBadge/ProgressBadge.js +2 -2
- package/lib/commonjs/components/ProjectionMarker/ProjectionMarker.js +162 -0
- package/lib/commonjs/components/Radio/Radio.js +5 -5
- package/lib/commonjs/components/Section/Section.js +3 -2
- package/lib/commonjs/components/Slider/Slider.js +474 -0
- package/lib/commonjs/components/Stack/Stack.js +86 -0
- package/lib/commonjs/components/SuggestiveSearch/SuggestiveSearch.js +10 -1
- package/lib/commonjs/components/SummaryTile/SummaryTile.js +3 -2
- package/lib/commonjs/components/Table/Table.js +324 -0
- package/lib/commonjs/components/Text/Text.js +2 -1
- package/lib/commonjs/components/TextInput/TextInput.js +22 -9
- package/lib/commonjs/components/TextSegment/TextSegment.js +119 -0
- package/lib/commonjs/components/ThreadHero/ThreadHero.js +4 -5
- package/lib/commonjs/components/Title/Title.js +2 -1
- package/lib/commonjs/components/Toast/Toast.js +3 -2
- package/lib/commonjs/components/TransactionBubble/TransactionBubble.js +2 -1
- package/lib/commonjs/components/TransactionStatus/TransactionStatus.js +3 -2
- package/lib/commonjs/components/UpiHandle/UpiHandle.js +2 -2
- package/lib/commonjs/components/index.js +107 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/design-tokens/figma-modes.generated.js +39 -9
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/GlassFill/GlassFill.js +271 -0
- package/lib/commonjs/utils/GlassFill/GlassFill.web.js +120 -0
- package/lib/commonjs/utils/react-utils.js +78 -0
- package/lib/commonjs/utils/web-platform-utils.js +59 -0
- package/lib/module/components/Accordion/Accordion.js +3 -2
- package/lib/module/components/AccordionCheckbox/AccordionCheckbox.js +5 -4
- package/lib/module/components/AccountCard/AccountCard.js +5 -4
- package/lib/module/components/AllocationComparisonChart/AllocationComparisonChart.js +10 -7
- package/lib/module/components/AmountInput/AmountInput.js +6 -4
- package/lib/module/components/AreaLineChart/AreaLineChart.js +12 -8
- package/lib/module/components/Badge/Badge.js +49 -10
- package/lib/module/components/BenefitCard/BenefitCard.js +225 -0
- package/lib/module/components/BrandChip/BrandChip.js +4 -4
- package/lib/module/components/Button/Button.js +3 -2
- package/lib/module/components/CardAdvisory/CardAdvisory.js +3 -2
- package/lib/module/components/CardBankAccount/CardBankAccount.js +4 -3
- package/lib/module/components/CardCTA/CardCTA.js +198 -28
- package/lib/module/components/CardInsight/CardInsight.js +5 -1
- package/lib/module/components/CcCard/CcCard.js +464 -0
- package/lib/module/components/Checkbox/Checkbox.js +5 -4
- package/lib/module/components/CheckboxItem/CheckboxItem.js +5 -4
- package/lib/module/components/CircularProgressBar/CircularProgressBar.js +8 -4
- package/lib/module/components/CircularProgressBarDoted/CircularProgressBarDoted.js +4 -3
- package/lib/module/components/CircularRating/CircularRating.js +3 -2
- package/lib/module/components/ClusterBubble/ClusterBubble.js +4 -3
- package/lib/module/components/CompareTable/CompareTable.js +396 -0
- package/lib/module/components/ComparisonBar/ComparisonBar.js +260 -0
- package/lib/module/components/CoverageBarComparison/CoverageBarComparison.js +4 -3
- package/lib/module/components/DonutChart/DonutChart.js +5 -4
- package/lib/module/components/Dropdown/Dropdown.js +4 -3
- package/lib/module/components/DropdownInput/DropdownInput.js +40 -7
- package/lib/module/components/ExpandableCheckbox/ExpandableCheckbox.js +2 -1
- package/lib/module/components/FormField/FormField.js +48 -7
- package/lib/module/components/Gauge/Gauge.js +1 -1
- package/lib/module/components/HoldingsCard/HoldingsCard.js +4 -3
- package/lib/module/components/InputSearch/InputSearch.js +6 -4
- package/lib/module/components/InstitutionBadge/InstitutionBadge.js +3 -2
- package/lib/module/components/ListGroup/ListGroup.js +3 -2
- package/lib/module/components/ListItem/ListItem.js +4 -3
- package/lib/module/components/MediaCard/MediaCard.js +4 -2
- package/lib/module/components/MetricLegendItem/MetricLegendItem.js +4 -3
- package/lib/module/components/MonthlyStatusGrid/MonthlyStatusGrid.js +7 -4
- package/lib/module/components/NoteInput/NoteInput.js +7 -6
- package/lib/module/components/PdpCcCard/PdpCcCard.js +267 -0
- package/lib/module/components/PoweredByLabel/PoweredByLabel.js +4 -3
- package/lib/module/components/ProductMerchandisingCard/ProductMerchandisingCard.js +421 -0
- package/lib/module/components/ProductOverview/ProductOverview.js +5 -4
- package/lib/module/components/ProgressBadge/ProgressBadge.js +3 -3
- package/lib/module/components/ProjectionMarker/ProjectionMarker.js +157 -0
- package/lib/module/components/Radio/Radio.js +5 -4
- package/lib/module/components/Section/Section.js +4 -3
- package/lib/module/components/Slider/Slider.js +469 -0
- package/lib/module/components/Stack/Stack.js +81 -0
- package/lib/module/components/SuggestiveSearch/SuggestiveSearch.js +10 -1
- package/lib/module/components/SummaryTile/SummaryTile.js +4 -3
- package/lib/module/components/Table/Table.js +315 -0
- package/lib/module/components/Text/Text.js +3 -2
- package/lib/module/components/TextInput/TextInput.js +24 -11
- package/lib/module/components/TextSegment/TextSegment.js +114 -0
- package/lib/module/components/ThreadHero/ThreadHero.js +5 -6
- package/lib/module/components/Title/Title.js +3 -2
- package/lib/module/components/Toast/Toast.js +4 -3
- package/lib/module/components/TransactionBubble/TransactionBubble.js +3 -2
- package/lib/module/components/TransactionStatus/TransactionStatus.js +4 -3
- package/lib/module/components/UpiHandle/UpiHandle.js +3 -3
- package/lib/module/components/index.js +11 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/design-tokens/figma-modes.generated.js +39 -9
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/GlassFill/GlassFill.js +265 -0
- package/lib/module/utils/GlassFill/GlassFill.web.js +115 -0
- package/lib/module/utils/react-utils.js +75 -0
- package/lib/module/utils/web-platform-utils.js +58 -0
- package/lib/typescript/src/components/Accordion/Accordion.d.ts +7 -1
- package/lib/typescript/src/components/AccordionCheckbox/AccordionCheckbox.d.ts +7 -1
- package/lib/typescript/src/components/AccountCard/AccountCard.d.ts +7 -1
- package/lib/typescript/src/components/AllocationComparisonChart/AllocationComparisonChart.d.ts +7 -1
- package/lib/typescript/src/components/AmountInput/AmountInput.d.ts +3 -2
- package/lib/typescript/src/components/AreaLineChart/AreaLineChart.d.ts +8 -1
- package/lib/typescript/src/components/Badge/Badge.d.ts +32 -2
- package/lib/typescript/src/components/BenefitCard/BenefitCard.d.ts +93 -0
- package/lib/typescript/src/components/BrandChip/BrandChip.d.ts +7 -1
- package/lib/typescript/src/components/Button/Button.d.ts +7 -1
- package/lib/typescript/src/components/CardAdvisory/CardAdvisory.d.ts +7 -1
- package/lib/typescript/src/components/CardBankAccount/CardBankAccount.d.ts +7 -1
- package/lib/typescript/src/components/CardCTA/CardCTA.d.ts +27 -5
- package/lib/typescript/src/components/CcCard/CcCard.d.ts +137 -0
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +2 -2
- package/lib/typescript/src/components/CircularProgressBar/CircularProgressBar.d.ts +7 -1
- package/lib/typescript/src/components/CircularProgressBarDoted/CircularProgressBarDoted.d.ts +7 -1
- package/lib/typescript/src/components/CircularRating/CircularRating.d.ts +7 -1
- package/lib/typescript/src/components/ClusterBubble/ClusterBubble.d.ts +7 -1
- package/lib/typescript/src/components/CompareTable/CompareTable.d.ts +94 -0
- package/lib/typescript/src/components/ComparisonBar/ComparisonBar.d.ts +118 -0
- package/lib/typescript/src/components/CoverageBarComparison/CoverageBarComparison.d.ts +7 -1
- package/lib/typescript/src/components/DonutChart/DonutChart.d.ts +7 -1
- package/lib/typescript/src/components/Dropdown/Dropdown.d.ts +7 -1
- package/lib/typescript/src/components/DropdownInput/DropdownInput.d.ts +26 -1
- package/lib/typescript/src/components/ExpandableCheckbox/ExpandableCheckbox.d.ts +7 -1
- package/lib/typescript/src/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/src/components/HoldingsCard/HoldingsCard.d.ts +7 -1
- package/lib/typescript/src/components/InputSearch/InputSearch.d.ts +23 -2
- package/lib/typescript/src/components/InstitutionBadge/InstitutionBadge.d.ts +7 -1
- package/lib/typescript/src/components/ListGroup/ListGroup.d.ts +7 -1
- package/lib/typescript/src/components/ListItem/ListItem.d.ts +7 -1
- package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +7 -1
- package/lib/typescript/src/components/MonthlyStatusGrid/MonthlyStatusGrid.d.ts +14 -2
- package/lib/typescript/src/components/NoteInput/NoteInput.d.ts +19 -2
- package/lib/typescript/src/components/PdpCcCard/PdpCcCard.d.ts +84 -0
- package/lib/typescript/src/components/PoweredByLabel/PoweredByLabel.d.ts +7 -1
- package/lib/typescript/src/components/ProductMerchandisingCard/ProductMerchandisingCard.d.ts +87 -0
- package/lib/typescript/src/components/ProductOverview/ProductOverview.d.ts +7 -1
- package/lib/typescript/src/components/ProgressBadge/ProgressBadge.d.ts +7 -1
- package/lib/typescript/src/components/ProjectionMarker/ProjectionMarker.d.ts +88 -0
- package/lib/typescript/src/components/Radio/Radio.d.ts +3 -2
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/typescript/src/components/Section/Section.d.ts +7 -1
- package/lib/typescript/src/components/Slider/Slider.d.ts +105 -0
- package/lib/typescript/src/components/Stack/Stack.d.ts +81 -0
- package/lib/typescript/src/components/SummaryTile/SummaryTile.d.ts +7 -1
- package/lib/typescript/src/components/Table/Table.d.ts +139 -0
- package/lib/typescript/src/components/Text/Text.d.ts +7 -1
- package/lib/typescript/src/components/TextInput/TextInput.d.ts +9 -29
- package/lib/typescript/src/components/TextSegment/TextSegment.d.ts +106 -0
- package/lib/typescript/src/components/ThreadHero/ThreadHero.d.ts +7 -1
- package/lib/typescript/src/components/Title/Title.d.ts +7 -1
- package/lib/typescript/src/components/Toast/Toast.d.ts +7 -1
- package/lib/typescript/src/components/TransactionBubble/TransactionBubble.d.ts +7 -1
- package/lib/typescript/src/components/TransactionStatus/TransactionStatus.d.ts +7 -1
- package/lib/typescript/src/components/UpiHandle/UpiHandle.d.ts +7 -1
- package/lib/typescript/src/components/index.d.ts +14 -3
- package/lib/typescript/src/design-tokens/figma-modes.generated.d.ts +22 -2
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/lib/typescript/src/utils/GlassFill/GlassFill.d.ts +84 -0
- package/lib/typescript/src/utils/GlassFill/GlassFill.web.d.ts +43 -0
- package/lib/typescript/src/utils/react-utils.d.ts +47 -0
- package/lib/typescript/src/utils/web-platform-utils.d.ts +36 -0
- package/package.json +2 -1
- package/src/components/Accordion/Accordion.tsx +9 -2
- package/src/components/AccordionCheckbox/AccordionCheckbox.tsx +10 -3
- package/src/components/AccountCard/AccountCard.tsx +10 -3
- package/src/components/AllocationComparisonChart/AllocationComparisonChart.tsx +14 -4
- package/src/components/AmountInput/AmountInput.tsx +7 -5
- package/src/components/AreaLineChart/AreaLineChart.tsx +15 -5
- package/src/components/Badge/Badge.tsx +78 -8
- package/src/components/BenefitCard/BenefitCard.tsx +309 -0
- package/src/components/BrandChip/BrandChip.tsx +9 -3
- package/src/components/Button/Button.tsx +9 -2
- package/src/components/CardAdvisory/CardAdvisory.tsx +9 -2
- package/src/components/CardBankAccount/CardBankAccount.tsx +9 -2
- package/src/components/CardCTA/CardCTA.tsx +214 -41
- package/src/components/CardInsight/CardInsight.tsx +7 -1
- package/src/components/CcCard/CcCard.tsx +598 -0
- package/src/components/Checkbox/Checkbox.tsx +5 -4
- package/src/components/CheckboxItem/CheckboxItem.tsx +5 -4
- package/src/components/CircularProgressBar/CircularProgressBar.tsx +14 -4
- package/src/components/CircularProgressBarDoted/CircularProgressBarDoted.tsx +10 -3
- package/src/components/CircularRating/CircularRating.tsx +9 -2
- package/src/components/ClusterBubble/ClusterBubble.tsx +9 -2
- package/src/components/CompareTable/CompareTable.tsx +525 -0
- package/src/components/ComparisonBar/ComparisonBar.tsx +356 -0
- package/src/components/CoverageBarComparison/CoverageBarComparison.tsx +9 -2
- package/src/components/DonutChart/DonutChart.tsx +10 -3
- package/src/components/Dropdown/Dropdown.tsx +9 -2
- package/src/components/DropdownInput/DropdownInput.tsx +64 -5
- package/src/components/ExpandableCheckbox/ExpandableCheckbox.tsx +8 -1
- package/src/components/FormField/FormField.tsx +52 -6
- package/src/components/Gauge/Gauge.tsx +1 -1
- package/src/components/HoldingsCard/HoldingsCard.tsx +9 -2
- package/src/components/InputSearch/InputSearch.tsx +8 -5
- package/src/components/InstitutionBadge/InstitutionBadge.tsx +9 -2
- package/src/components/ListGroup/ListGroup.tsx +9 -2
- package/src/components/ListItem/ListItem.tsx +10 -3
- package/src/components/MediaCard/MediaCard.tsx +2 -2
- package/src/components/MetricLegendItem/MetricLegendItem.tsx +9 -2
- package/src/components/MonthlyStatusGrid/MonthlyStatusGrid.tsx +17 -2
- package/src/components/NoteInput/NoteInput.tsx +8 -6
- package/src/components/PdpCcCard/PdpCcCard.tsx +356 -0
- package/src/components/PoweredByLabel/PoweredByLabel.tsx +9 -2
- package/src/components/ProductMerchandisingCard/ProductMerchandisingCard.tsx +490 -0
- package/src/components/ProductOverview/ProductOverview.tsx +10 -3
- package/src/components/ProgressBadge/ProgressBadge.tsx +9 -3
- package/src/components/ProjectionMarker/ProjectionMarker.tsx +284 -0
- package/src/components/Radio/Radio.tsx +5 -4
- package/src/components/Section/Section.tsx +10 -3
- package/src/components/Slider/Slider.tsx +635 -0
- package/src/components/Stack/Stack.tsx +131 -0
- package/src/components/SuggestiveSearch/SuggestiveSearch.tsx +10 -1
- package/src/components/SummaryTile/SummaryTile.tsx +9 -2
- package/src/components/Table/Table.tsx +449 -0
- package/src/components/Text/Text.tsx +9 -2
- package/src/components/TextInput/TextInput.tsx +22 -12
- package/src/components/TextSegment/TextSegment.tsx +173 -0
- package/src/components/ThreadHero/ThreadHero.tsx +10 -3
- package/src/components/Title/Title.tsx +9 -2
- package/src/components/Toast/Toast.tsx +9 -2
- package/src/components/TransactionBubble/TransactionBubble.tsx +9 -2
- package/src/components/TransactionStatus/TransactionStatus.tsx +9 -2
- package/src/components/UpiHandle/UpiHandle.tsx +9 -3
- package/src/components/index.ts +33 -3
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/design-tokens/figma-modes.generated.ts +39 -9
- package/src/icons/registry.ts +1 -1
- package/src/utils/GlassFill/GlassFill.tsx +305 -0
- package/src/utils/GlassFill/GlassFill.web.tsx +148 -0
- package/src/utils/react-utils.ts +84 -0
- package/src/utils/web-platform-utils.ts +68 -0
- package/lib/commonjs/components/MediaCard/GlassFill.js +0 -62
- package/lib/commonjs/components/MediaCard/GlassFill.web.js +0 -48
- package/lib/module/components/MediaCard/GlassFill.js +0 -57
- package/lib/module/components/MediaCard/GlassFill.web.js +0 -43
- package/lib/typescript/scripts/extract-component-tokens.d.ts +0 -9
- package/lib/typescript/scripts/generate-component-docs.d.ts +0 -9
- package/lib/typescript/scripts/generate-icon-registry.d.ts +0 -3
- package/lib/typescript/scripts/generate-mode-types.d.ts +0 -2
- package/lib/typescript/scripts/retype-modes.d.cts +0 -2
- package/lib/typescript/src/components/MediaCard/GlassFill.d.ts +0 -47
- package/lib/typescript/src/components/MediaCard/GlassFill.web.d.ts +0 -20
- package/src/components/MediaCard/GlassFill.tsx +0 -89
- package/src/components/MediaCard/GlassFill.web.tsx +0 -53
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
type TextStyle,
|
|
9
|
+
type StyleProp,
|
|
10
|
+
type ImageSourcePropType,
|
|
11
|
+
} from 'react-native'
|
|
12
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
13
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils'
|
|
14
|
+
import Title from '../Title/Title'
|
|
15
|
+
import Divider from '../Divider/Divider'
|
|
16
|
+
import Button from '../Button/Button'
|
|
17
|
+
import Image from '../Image/Image'
|
|
18
|
+
import Icon from '../Icon/Icon'
|
|
19
|
+
import type { Modes } from '../../design-tokens'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A single metric column inside the card's stats row: a small title, a bold
|
|
23
|
+
* value and an optional muted caption.
|
|
24
|
+
*/
|
|
25
|
+
export interface PdpCcCardMetric {
|
|
26
|
+
/** Small label rendered above the value (e.g. `"Weight"`). */
|
|
27
|
+
title?: string
|
|
28
|
+
/** The prominent value (e.g. `"24K"`). */
|
|
29
|
+
value?: string
|
|
30
|
+
/** Optional muted caption rendered below the value. */
|
|
31
|
+
caption?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PdpCcCardProps {
|
|
35
|
+
/**
|
|
36
|
+
* Image source for the default media slot. Accepts a URL string or any RN
|
|
37
|
+
* `ImageSourcePropType`. Ignored when `media` is provided.
|
|
38
|
+
*/
|
|
39
|
+
imageSource?: ImageSourcePropType | string
|
|
40
|
+
/** Default media image width. Defaults to the Figma spec (`100`). */
|
|
41
|
+
imageWidth?: number
|
|
42
|
+
/** Default media image height. Defaults to the Figma spec (`60`). */
|
|
43
|
+
imageHeight?: number
|
|
44
|
+
/**
|
|
45
|
+
* Full override for the media slot (top of the card). Takes precedence over
|
|
46
|
+
* `imageSource`. `modes` cascade into it automatically.
|
|
47
|
+
*/
|
|
48
|
+
media?: React.ReactNode
|
|
49
|
+
/** Headline title (26px black). */
|
|
50
|
+
title?: string
|
|
51
|
+
/** Subtitle rendered below the title (14px medium). */
|
|
52
|
+
subtitle?: string
|
|
53
|
+
/**
|
|
54
|
+
* The metric columns rendered in the stats row. Vertical dividers are
|
|
55
|
+
* inserted automatically between adjacent metrics. Defaults to two sample
|
|
56
|
+
* metrics.
|
|
57
|
+
*/
|
|
58
|
+
metrics?: PdpCcCardMetric[]
|
|
59
|
+
/** CTA button label. Defaults to `"button"`. */
|
|
60
|
+
buttonLabel?: string
|
|
61
|
+
/**
|
|
62
|
+
* Registry icon name for the button's leading glyph. Defaults to
|
|
63
|
+
* `'ic_add_circle'`. Pass `null` to hide the leading icon.
|
|
64
|
+
*/
|
|
65
|
+
buttonIcon?: string | null
|
|
66
|
+
/** CTA press handler. */
|
|
67
|
+
onButtonPress?: () => void
|
|
68
|
+
/** Full override for the CTA. Takes precedence over `buttonLabel`. */
|
|
69
|
+
button?: React.ReactNode
|
|
70
|
+
/** Toggles the CTA button. Defaults to `true`. */
|
|
71
|
+
showButton?: boolean
|
|
72
|
+
/** Press handler for the whole card. When set, the card becomes pressable. */
|
|
73
|
+
onPress?: () => void
|
|
74
|
+
/** Card width. Defaults to the Figma spec (`344`). Pass `'100%'` to fill the parent. */
|
|
75
|
+
width?: number | `${number}%`
|
|
76
|
+
/** Modes object for design-token resolution. Cascaded to all children. */
|
|
77
|
+
modes?: Modes
|
|
78
|
+
/** Style overrides for the card container. */
|
|
79
|
+
style?: StyleProp<ViewStyle>
|
|
80
|
+
/** Accessibility label for the card. */
|
|
81
|
+
accessibilityLabel?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* PdpCcCard — Figma node 5352:935 ("PDP cc card").
|
|
86
|
+
*
|
|
87
|
+
* A centered white product/PDP card composed from the shared design-system
|
|
88
|
+
* primitives so it stays in sync with the rest of the library:
|
|
89
|
+
*
|
|
90
|
+
* - **Media** — a top image slot (`Image`, rounded via `image/radius`). Pass
|
|
91
|
+
* `imageSource` for the default image or `media` for a full slot override.
|
|
92
|
+
* - **Title** — a centered headline + subtitle rendered through the shared
|
|
93
|
+
* {@link Title} component (`title/*`, `pageSubtitle/*` tokens).
|
|
94
|
+
* - **Metrics** — a row of {@link PdpCcCardMetric} columns (title / value /
|
|
95
|
+
* caption) separated by vertical `Divider`s (`metricdata/*` tokens).
|
|
96
|
+
* - **CTA** — a small tonal {@link Button} (`Button / Size: S`,
|
|
97
|
+
* `AppearanceBrand: Secondary`, `Emphasis: Medium`) with a leading icon.
|
|
98
|
+
*
|
|
99
|
+
* All defaults can be overridden via `modes`.
|
|
100
|
+
*/
|
|
101
|
+
function PdpCcCard({
|
|
102
|
+
imageSource,
|
|
103
|
+
imageWidth = 100,
|
|
104
|
+
imageHeight = 60,
|
|
105
|
+
media,
|
|
106
|
+
title = 'Title',
|
|
107
|
+
subtitle = 'Subtitle',
|
|
108
|
+
metrics = DEFAULT_METRICS,
|
|
109
|
+
buttonLabel = 'button',
|
|
110
|
+
buttonIcon = 'ic_add_circle',
|
|
111
|
+
onButtonPress,
|
|
112
|
+
button,
|
|
113
|
+
showButton = true,
|
|
114
|
+
onPress,
|
|
115
|
+
width = 344,
|
|
116
|
+
modes = EMPTY_MODES,
|
|
117
|
+
style,
|
|
118
|
+
accessibilityLabel,
|
|
119
|
+
}: PdpCcCardProps) {
|
|
120
|
+
const tokens = useMemo(() => resolveTokens(modes), [modes])
|
|
121
|
+
|
|
122
|
+
// The CTA uses the brand "Secondary" appearance at "Medium" emphasis (lilac
|
|
123
|
+
// fill + purple label) and the small size — matching the design. A
|
|
124
|
+
// consumer-supplied `modes` value still wins via spread order.
|
|
125
|
+
const ctaModes = useMemo<Modes>(
|
|
126
|
+
() => ({ AppearanceBrand: 'Secondary', Emphasis: 'Medium', 'Button / Size': 'S', ...modes }),
|
|
127
|
+
[modes]
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const buttonForeground = useMemo(
|
|
131
|
+
() => asStr(getVariableByName('button/foreground', ctaModes), '#5d00b5'),
|
|
132
|
+
[ctaModes]
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
const mediaNode = media ? (
|
|
136
|
+
cloneChildrenWithModes(media, modes)
|
|
137
|
+
) : (
|
|
138
|
+
<Image
|
|
139
|
+
imageSource={imageSource}
|
|
140
|
+
width={imageWidth}
|
|
141
|
+
height={imageHeight}
|
|
142
|
+
borderRadius={tokens.imageRadius}
|
|
143
|
+
resizeMode="cover"
|
|
144
|
+
accessibilityElementsHidden
|
|
145
|
+
importantForAccessibility="no"
|
|
146
|
+
/>
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
const ctaNode = button ? (
|
|
150
|
+
cloneChildrenWithModes(button, ctaModes)
|
|
151
|
+
) : (
|
|
152
|
+
<Button
|
|
153
|
+
label={buttonLabel}
|
|
154
|
+
modes={ctaModes}
|
|
155
|
+
onPress={onButtonPress}
|
|
156
|
+
leading={
|
|
157
|
+
buttonIcon ? (
|
|
158
|
+
<Icon iconName={buttonIcon} size={tokens.buttonIconSize} color={buttonForeground} />
|
|
159
|
+
) : undefined
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
const content = (
|
|
165
|
+
<>
|
|
166
|
+
<View style={styles.mediaSlot}>{mediaNode}</View>
|
|
167
|
+
|
|
168
|
+
<Title title={title} subtitle={subtitle} textAlign="Center" modes={modes} />
|
|
169
|
+
|
|
170
|
+
{metrics.length > 0 ? (
|
|
171
|
+
<View style={styles.metricsRow}>
|
|
172
|
+
{metrics.map((metric, index) => (
|
|
173
|
+
<React.Fragment key={index}>
|
|
174
|
+
{index > 0 ? (
|
|
175
|
+
<Divider direction="vertical" modes={modes} style={styles.metricDivider} />
|
|
176
|
+
) : null}
|
|
177
|
+
<Metricdata metric={metric} tokens={tokens} />
|
|
178
|
+
</React.Fragment>
|
|
179
|
+
))}
|
|
180
|
+
</View>
|
|
181
|
+
) : null}
|
|
182
|
+
|
|
183
|
+
{showButton ? ctaNode : null}
|
|
184
|
+
</>
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
const containerStyle = useMemo<ViewStyle>(
|
|
188
|
+
() => ({ ...tokens.container, width }),
|
|
189
|
+
[tokens.container, width]
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
if (onPress) {
|
|
193
|
+
return (
|
|
194
|
+
<Pressable
|
|
195
|
+
style={({ pressed }) => [containerStyle, pressed ? styles.pressed : null, style]}
|
|
196
|
+
accessibilityRole="button"
|
|
197
|
+
accessibilityLabel={accessibilityLabel ?? title}
|
|
198
|
+
onPress={onPress}
|
|
199
|
+
>
|
|
200
|
+
{content}
|
|
201
|
+
</Pressable>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<View style={[containerStyle, style]} accessibilityLabel={accessibilityLabel}>
|
|
207
|
+
{content}
|
|
208
|
+
</View>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
// Metricdata — internal metric column (Figma node 5352:256)
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
function Metricdata({ metric, tokens }: { metric: PdpCcCardMetric; tokens: ResolvedTokens }) {
|
|
217
|
+
return (
|
|
218
|
+
<View style={tokens.metric}>
|
|
219
|
+
{metric.title != null ? <Text style={tokens.metricTitle}>{metric.title}</Text> : null}
|
|
220
|
+
{metric.value != null ? <Text style={tokens.metricValue}>{metric.value}</Text> : null}
|
|
221
|
+
{metric.caption != null ? <Text style={tokens.metricCaption}>{metric.caption}</Text> : null}
|
|
222
|
+
</View>
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
// Tokens / static styles
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
interface ResolvedTokens {
|
|
231
|
+
container: ViewStyle
|
|
232
|
+
imageRadius: number
|
|
233
|
+
buttonIconSize: number
|
|
234
|
+
metric: ViewStyle
|
|
235
|
+
metricTitle: TextStyle
|
|
236
|
+
metricValue: TextStyle
|
|
237
|
+
metricCaption: TextStyle
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function asNum(raw: unknown, fallback: number): number {
|
|
241
|
+
const n = typeof raw === 'number' ? raw : parseFloat(raw as string)
|
|
242
|
+
return Number.isFinite(n) ? n : fallback
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function asStr(raw: unknown, fallback: string): string {
|
|
246
|
+
return raw != null ? String(raw) : fallback
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function resolveTokens(modes: Modes): ResolvedTokens {
|
|
250
|
+
// NOTE: token names are passed as string literals DIRECTLY to
|
|
251
|
+
// getVariableByName so the `extract-component-tokens` script can statically
|
|
252
|
+
// collect them for the generated docs. Do not refactor these into a helper
|
|
253
|
+
// that receives the name as a variable.
|
|
254
|
+
const background = asStr(getVariableByName('PDPcccard/bg/color', modes), '#ffffff')
|
|
255
|
+
const paddingHorizontal = asNum(getVariableByName('PDPcccard/padding/horizontal', modes), 16)
|
|
256
|
+
const paddingVertical = asNum(getVariableByName('PDPcccard/padding/vertical', modes), 20)
|
|
257
|
+
const gap = asNum(getVariableByName('PDPcccard/gap', modes), 12)
|
|
258
|
+
|
|
259
|
+
const imageRadius = asNum(getVariableByName('image/radius', modes), 8)
|
|
260
|
+
const buttonIconSize = asNum(getVariableByName('button/iconSize', modes), 16)
|
|
261
|
+
|
|
262
|
+
const metricGap = asNum(getVariableByName('metricdata/gap', modes), 4)
|
|
263
|
+
const metricPadH = asNum(getVariableByName('metricdata/padding/horizontal', modes), 10)
|
|
264
|
+
const metricPadV = asNum(getVariableByName('metricdata/padding/vertical', modes), 10)
|
|
265
|
+
|
|
266
|
+
const titleColor = asStr(getVariableByName('metricdata/title/color', modes), '#000000')
|
|
267
|
+
const titleSize = asNum(getVariableByName('metricdata/title/fontsize', modes), 12)
|
|
268
|
+
const titleFamily = asStr(getVariableByName('metricdata/title/fontfamily', modes), 'JioType Var')
|
|
269
|
+
const titleWeight = asStr(getVariableByName('metricdata/title/fontweight', modes), '400')
|
|
270
|
+
|
|
271
|
+
const valueColor = asStr(getVariableByName('metricdata/value/color', modes), '#000000')
|
|
272
|
+
const valueSize = asNum(getVariableByName('metricdata/value/fontsize', modes), 20)
|
|
273
|
+
const valueFamily = asStr(getVariableByName('metricdata/value/fontfamily', modes), 'JioType Var')
|
|
274
|
+
const valueWeight = asStr(getVariableByName('metricdata/value/fontweight', modes), '700')
|
|
275
|
+
|
|
276
|
+
const captionColor = asStr(getVariableByName('metricdata/caption/color', modes), '#777777')
|
|
277
|
+
const captionSize = asNum(getVariableByName('metricdata/caption/fontsize', modes), 12)
|
|
278
|
+
const captionFamily = asStr(getVariableByName('metricdata/caption/fontfamily', modes), 'JioType Var')
|
|
279
|
+
const captionWeight = asStr(getVariableByName('metricdata/caption/fontweight', modes), '500')
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
container: {
|
|
283
|
+
backgroundColor: background,
|
|
284
|
+
paddingHorizontal,
|
|
285
|
+
paddingVertical,
|
|
286
|
+
gap,
|
|
287
|
+
flexDirection: 'column',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
justifyContent: 'center',
|
|
290
|
+
},
|
|
291
|
+
imageRadius,
|
|
292
|
+
buttonIconSize,
|
|
293
|
+
metric: {
|
|
294
|
+
flex: 1,
|
|
295
|
+
gap: metricGap,
|
|
296
|
+
paddingHorizontal: metricPadH,
|
|
297
|
+
paddingVertical: metricPadV,
|
|
298
|
+
alignItems: 'center',
|
|
299
|
+
justifyContent: 'center',
|
|
300
|
+
},
|
|
301
|
+
metricTitle: {
|
|
302
|
+
color: titleColor,
|
|
303
|
+
fontSize: titleSize,
|
|
304
|
+
fontFamily: titleFamily,
|
|
305
|
+
fontWeight: titleWeight as TextStyle['fontWeight'],
|
|
306
|
+
lineHeight: Math.round(titleSize * 1.2),
|
|
307
|
+
textAlign: 'center',
|
|
308
|
+
includeFontPadding: false as any,
|
|
309
|
+
},
|
|
310
|
+
metricValue: {
|
|
311
|
+
color: valueColor,
|
|
312
|
+
fontSize: valueSize,
|
|
313
|
+
fontFamily: valueFamily,
|
|
314
|
+
fontWeight: valueWeight as TextStyle['fontWeight'],
|
|
315
|
+
lineHeight: Math.round(valueSize * 1.2),
|
|
316
|
+
textAlign: 'center',
|
|
317
|
+
includeFontPadding: false as any,
|
|
318
|
+
},
|
|
319
|
+
metricCaption: {
|
|
320
|
+
color: captionColor,
|
|
321
|
+
fontSize: captionSize,
|
|
322
|
+
fontFamily: captionFamily,
|
|
323
|
+
fontWeight: captionWeight as TextStyle['fontWeight'],
|
|
324
|
+
lineHeight: Math.round(captionSize * 1.2),
|
|
325
|
+
textAlign: 'center',
|
|
326
|
+
includeFontPadding: false as any,
|
|
327
|
+
},
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const DEFAULT_METRICS: PdpCcCardMetric[] = [
|
|
332
|
+
{ title: 'Title', value: 'Value', caption: 'caption' },
|
|
333
|
+
{ title: 'Title', value: 'Value', caption: 'caption' },
|
|
334
|
+
]
|
|
335
|
+
|
|
336
|
+
const styles = StyleSheet.create({
|
|
337
|
+
mediaSlot: {
|
|
338
|
+
alignSelf: 'stretch',
|
|
339
|
+
alignItems: 'center',
|
|
340
|
+
justifyContent: 'center',
|
|
341
|
+
},
|
|
342
|
+
metricsRow: {
|
|
343
|
+
alignSelf: 'stretch',
|
|
344
|
+
flexDirection: 'row',
|
|
345
|
+
alignItems: 'stretch',
|
|
346
|
+
},
|
|
347
|
+
metricDivider: {
|
|
348
|
+
alignSelf: 'center',
|
|
349
|
+
height: '70%',
|
|
350
|
+
},
|
|
351
|
+
pressed: {
|
|
352
|
+
opacity: 0.92,
|
|
353
|
+
},
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
export default PdpCcCard
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react-native'
|
|
10
10
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
11
11
|
import { useTokens } from '../../design-tokens/JFSThemeProvider'
|
|
12
|
-
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils'
|
|
12
|
+
import { EMPTY_MODES, cloneChildrenWithModes, resolveTruncation } from '../../utils/react-utils'
|
|
13
13
|
import MediaSource, { type UnifiedSource } from '../../utils/MediaSource'
|
|
14
14
|
import type { Modes } from '../../design-tokens'
|
|
15
15
|
|
|
@@ -65,6 +65,12 @@ export type PoweredByLabelProps = {
|
|
|
65
65
|
* (which is decorative) does not need to be announced separately.
|
|
66
66
|
*/
|
|
67
67
|
accessibilityLabel?: string
|
|
68
|
+
/**
|
|
69
|
+
* When `true`, disables text truncation: the trailing ellipsis (`…`) is never
|
|
70
|
+
* shown and any `numberOfLines` clamp is ignored, so the text wraps to as many
|
|
71
|
+
* lines as it needs even when horizontal space is tight.
|
|
72
|
+
*/
|
|
73
|
+
disableTruncation?: boolean
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
const toNumber = (value: unknown, fallback: number): number => {
|
|
@@ -115,6 +121,7 @@ function PoweredByLabel({
|
|
|
115
121
|
textStyle,
|
|
116
122
|
imageStyle,
|
|
117
123
|
accessibilityLabel,
|
|
124
|
+
disableTruncation,
|
|
118
125
|
}: PoweredByLabelProps) {
|
|
119
126
|
const { modes: globalModes } = useTokens()
|
|
120
127
|
const modes = useMemo(
|
|
@@ -210,7 +217,7 @@ function PoweredByLabel({
|
|
|
210
217
|
style={[labelTextStyle, textStyle]}
|
|
211
218
|
accessibilityElementsHidden={true}
|
|
212
219
|
importantForAccessibility="no"
|
|
213
|
-
|
|
220
|
+
{...resolveTruncation(disableTruncation, 1)}
|
|
214
221
|
>
|
|
215
222
|
{label}
|
|
216
223
|
</Text>
|