jfs-components 0.0.2 → 0.0.4
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/lib/commonjs/components/Accordion/Accordion.js +217 -0
- package/lib/commonjs/components/Accordion/Accordion.js.map +1 -0
- package/lib/commonjs/components/Accordion/Accordion.mdx +122 -0
- package/lib/commonjs/components/ActionTile/ActionTile.js +93 -0
- package/lib/commonjs/components/ActionTile/ActionTile.js.map +1 -0
- package/lib/commonjs/components/ActionTile/ActionTile.mdx +54 -0
- package/lib/commonjs/components/ActionTile/index.js +14 -0
- package/lib/commonjs/components/ActionTile/index.js.map +1 -0
- package/lib/commonjs/components/CtaCard/CtaCard.js +122 -0
- package/lib/commonjs/components/CtaCard/CtaCard.js.map +1 -0
- package/lib/commonjs/components/CtaCard/CtaCard.mdx +66 -0
- package/lib/commonjs/components/CtaCard/index.js +14 -0
- package/lib/commonjs/components/CtaCard/index.js.map +1 -0
- package/lib/commonjs/components/MoneyValue/MoneyValue.js +36 -4
- package/lib/commonjs/components/MoneyValue/MoneyValue.js.map +1 -1
- package/lib/commonjs/components/ThreadHero/ThreadHero.js +114 -0
- package/lib/commonjs/components/ThreadHero/ThreadHero.js.map +1 -0
- package/lib/commonjs/components/ThreadHero/ThreadHero.mdx +69 -0
- package/lib/commonjs/components/TransactionBubble/TransactionBubble.js +101 -0
- package/lib/commonjs/components/TransactionBubble/TransactionBubble.js.map +1 -0
- package/lib/commonjs/components/TransactionBubble/TransactionBubble.mdx +40 -0
- package/lib/commonjs/components/TransactionDetails/TransactionDetails.js +177 -0
- package/lib/commonjs/components/TransactionDetails/TransactionDetails.js.map +1 -0
- package/lib/commonjs/components/TransactionDetails/TransactionDetails.mdx +98 -0
- package/lib/commonjs/components/TransactionStatus/TransactionStatus.js +82 -0
- package/lib/commonjs/components/TransactionStatus/TransactionStatus.js.map +1 -0
- package/lib/commonjs/components/TransactionStatus/TransactionStatus.mdx +41 -0
- package/lib/commonjs/components/index.js +35 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/design-tokens/figma-variables-resolver.js +3 -9
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/Accordion/Accordion.js +212 -0
- package/lib/module/components/Accordion/Accordion.js.map +1 -0
- package/lib/module/components/Accordion/Accordion.mdx +122 -0
- package/lib/module/components/ActionTile/ActionTile.js +88 -0
- package/lib/module/components/ActionTile/ActionTile.js.map +1 -0
- package/lib/module/components/ActionTile/ActionTile.mdx +54 -0
- package/lib/module/components/ActionTile/index.js +4 -0
- package/lib/module/components/ActionTile/index.js.map +1 -0
- package/lib/module/components/CtaCard/CtaCard.js +117 -0
- package/lib/module/components/CtaCard/CtaCard.js.map +1 -0
- package/lib/module/components/CtaCard/CtaCard.mdx +66 -0
- package/lib/module/components/CtaCard/index.js +4 -0
- package/lib/module/components/CtaCard/index.js.map +1 -0
- package/lib/module/components/MoneyValue/MoneyValue.js +36 -4
- package/lib/module/components/MoneyValue/MoneyValue.js.map +1 -1
- package/lib/module/components/ThreadHero/ThreadHero.js +109 -0
- package/lib/module/components/ThreadHero/ThreadHero.js.map +1 -0
- package/lib/module/components/ThreadHero/ThreadHero.mdx +69 -0
- package/lib/module/components/TransactionBubble/TransactionBubble.js +96 -0
- package/lib/module/components/TransactionBubble/TransactionBubble.js.map +1 -0
- package/lib/module/components/TransactionBubble/TransactionBubble.mdx +40 -0
- package/lib/module/components/TransactionDetails/TransactionDetails.js +174 -0
- package/lib/module/components/TransactionDetails/TransactionDetails.js.map +1 -0
- package/lib/module/components/TransactionDetails/TransactionDetails.mdx +98 -0
- package/lib/module/components/TransactionStatus/TransactionStatus.js +77 -0
- package/lib/module/components/TransactionStatus/TransactionStatus.js.map +1 -0
- package/lib/module/components/TransactionStatus/TransactionStatus.mdx +41 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/components/Accordion/Accordion.d.ts +58 -0
- package/lib/typescript/components/Accordion/Accordion.d.ts.map +1 -0
- package/lib/typescript/components/ActionTile/ActionTile.d.ts +26 -0
- package/lib/typescript/components/ActionTile/ActionTile.d.ts.map +1 -0
- package/lib/typescript/components/ActionTile/index.d.ts +2 -0
- package/lib/typescript/components/ActionTile/index.d.ts.map +1 -0
- package/lib/typescript/components/CtaCard/CtaCard.d.ts +61 -0
- package/lib/typescript/components/CtaCard/CtaCard.d.ts.map +1 -0
- package/lib/typescript/components/CtaCard/index.d.ts +2 -0
- package/lib/typescript/components/CtaCard/index.d.ts.map +1 -0
- package/lib/typescript/components/MoneyValue/MoneyValue.d.ts +9 -2
- package/lib/typescript/components/MoneyValue/MoneyValue.d.ts.map +1 -1
- package/lib/typescript/components/ThreadHero/ThreadHero.d.ts +21 -0
- package/lib/typescript/components/ThreadHero/ThreadHero.d.ts.map +1 -0
- package/lib/typescript/components/TransactionBubble/TransactionBubble.d.ts +24 -0
- package/lib/typescript/components/TransactionBubble/TransactionBubble.d.ts.map +1 -0
- package/lib/typescript/components/TransactionDetails/TransactionDetails.d.ts +57 -0
- package/lib/typescript/components/TransactionDetails/TransactionDetails.d.ts.map +1 -0
- package/lib/typescript/components/TransactionStatus/TransactionStatus.d.ts +16 -0
- package/lib/typescript/components/TransactionStatus/TransactionStatus.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +5 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/icons/registry.d.ts +1 -1
- package/package.json +5 -2
- package/src/components/.token-metadata.json +161 -0
- package/src/components/Accordion/Accordion.mdx +122 -0
- package/src/components/Accordion/Accordion.tsx +279 -0
- package/src/components/ActionTile/ActionTile.mdx +54 -0
- package/src/components/ActionTile/ActionTile.tsx +100 -0
- package/src/components/ActionTile/index.ts +1 -0
- package/src/components/CtaCard/CtaCard.mdx +66 -0
- package/src/components/CtaCard/CtaCard.tsx +185 -0
- package/src/components/CtaCard/index.ts +1 -0
- package/src/components/MoneyValue/MoneyValue.tsx +39 -3
- package/src/components/ThreadHero/ThreadHero.mdx +69 -0
- package/src/components/ThreadHero/ThreadHero.tsx +124 -0
- package/src/components/TransactionBubble/TransactionBubble.mdx +40 -0
- package/src/components/TransactionBubble/TransactionBubble.tsx +113 -0
- package/src/components/TransactionDetails/TransactionDetails.mdx +98 -0
- package/src/components/TransactionDetails/TransactionDetails.tsx +236 -0
- package/src/components/TransactionStatus/TransactionStatus.mdx +41 -0
- package/src/components/TransactionStatus/TransactionStatus.tsx +94 -0
- package/src/components/index.ts +5 -0
- package/src/icons/registry.ts +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Meta, Story, Canvas, PureArgsTable as ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as TransactionDetailsStories from './TransactionDetails.stories';
|
|
3
|
+
import TransactionDetails from './TransactionDetails';
|
|
4
|
+
import { AccessibilitySection, AnatomySection, UsageConstraintsSection } from '../docs/DocSections';
|
|
5
|
+
|
|
6
|
+
<Meta of={TransactionDetailsStories} />
|
|
7
|
+
|
|
8
|
+
# TransactionDetails
|
|
9
|
+
|
|
10
|
+
TransactionDetails is a container component that displays a list of transaction detail items, each showing a label-value pair. It uses design tokens from Figma for consistent styling.
|
|
11
|
+
|
|
12
|
+
## Available Collections and Modes
|
|
13
|
+
|
|
14
|
+
This component does not use any design token collections with multiple modes.
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
<Canvas>
|
|
18
|
+
<Story of={TransactionDetailsStories.Default} />
|
|
19
|
+
</Canvas>
|
|
20
|
+
|
|
21
|
+
## Usage Example
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import TransactionDetails from 'jfs-components';
|
|
25
|
+
|
|
26
|
+
function PaymentConfirmation() {
|
|
27
|
+
return (
|
|
28
|
+
<TransactionDetails>
|
|
29
|
+
<TransactionDetails.Item label="UPI transaction ID" value="101674916166" />
|
|
30
|
+
<TransactionDetails.Item label="From: 5678 XXXX XXXX 1234" value="JioFinance • shivashankar@okjio" />
|
|
31
|
+
<TransactionDetails.Item label="To: SHIVASHANKAR RAJAN" value="JioFinance • shivashankar@okjio" />
|
|
32
|
+
<TransactionDetails.Item label="Payment method" value="UPI" />
|
|
33
|
+
</TransactionDetails>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Single Item
|
|
39
|
+
|
|
40
|
+
<Canvas>
|
|
41
|
+
<Story of={TransactionDetailsStories.SingleItem} />
|
|
42
|
+
</Canvas>
|
|
43
|
+
|
|
44
|
+
<AccessibilitySection
|
|
45
|
+
items={[
|
|
46
|
+
'TransactionDetails has role "summary" for screen readers to announce it as a summary section.',
|
|
47
|
+
'Each DetailItem has role "text" with a combined label and value for clear reading.',
|
|
48
|
+
'Use descriptive labels that clearly indicate what the value represents.',
|
|
49
|
+
'Ensure sufficient color contrast between label and value text.',
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<AnatomySection>
|
|
54
|
+
<ul>
|
|
55
|
+
<li><strong>TransactionDetails (Container)</strong> — Wraps all Item children with consistent gap and padding.</li>
|
|
56
|
+
<li><strong>TransactionDetails.Item</strong> — Individual label-value pair component.</li>
|
|
57
|
+
<li><strong>Label</strong> — Descriptive text above the value, using token typography.</li>
|
|
58
|
+
<li><strong>Value</strong> — The actual data/content text, using token typography.</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</AnatomySection>
|
|
61
|
+
|
|
62
|
+
<UsageConstraintsSection
|
|
63
|
+
items={[
|
|
64
|
+
'Always use TransactionDetails.Item as direct children of TransactionDetails for proper mode propagation.',
|
|
65
|
+
'Keep label text concise and descriptive.',
|
|
66
|
+
'Values can be longer but consider text wrapping on smaller screens.',
|
|
67
|
+
'Use consistent date/time and number formatting across all detail items.',
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
## TransactionDetails Props
|
|
72
|
+
|
|
73
|
+
<ArgsTable of={TransactionDetails} />
|
|
74
|
+
|
|
75
|
+
## TransactionDetails.Item Props
|
|
76
|
+
|
|
77
|
+
<ArgsTable of={TransactionDetails.Item} />
|
|
78
|
+
|
|
79
|
+
## Design Tokens
|
|
80
|
+
|
|
81
|
+
This component uses the following design tokens, resolved through `getVariableByName`:
|
|
82
|
+
|
|
83
|
+
- **`detailItem/gap`**
|
|
84
|
+
- **`detailItem/label/color`**
|
|
85
|
+
- **`detailItem/label/fontFamily`**
|
|
86
|
+
- **`detailItem/label/fontSize`**
|
|
87
|
+
- **`detailItem/label/fontWeight`**
|
|
88
|
+
- **`detailItem/label/lineHeight`**
|
|
89
|
+
- **`detailItem/value/color`**
|
|
90
|
+
- **`detailItem/value/fontFamily`**
|
|
91
|
+
- **`detailItem/value/fontSize`**
|
|
92
|
+
- **`detailItem/value/fontWeight`**
|
|
93
|
+
- **`detailItem/value/lineHeight`**
|
|
94
|
+
- **`transationDetails/gap`**
|
|
95
|
+
- **`transationDetails/padding/horizontal`**
|
|
96
|
+
- **`transationDetails/padding/vertical`**
|
|
97
|
+
|
|
98
|
+
All tokens support mode-based theming through the `modes` prop.
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, type StyleProp, type ViewStyle, type TextStyle } from 'react-native'
|
|
3
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to recursively clone children and pass modes prop to components that accept it.
|
|
7
|
+
*/
|
|
8
|
+
function cloneChildrenWithModes(
|
|
9
|
+
children: React.ReactNode,
|
|
10
|
+
modes: Record<string, any>
|
|
11
|
+
): React.ReactNode[] {
|
|
12
|
+
const result = React.Children.map(children, (child) => {
|
|
13
|
+
if (!React.isValidElement(child)) {
|
|
14
|
+
return child
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const childChildren = (child.props as any)?.children
|
|
18
|
+
const hasChildren = childChildren !== undefined && childChildren !== null
|
|
19
|
+
|
|
20
|
+
const existingModes = (child.props as any)?.modes
|
|
21
|
+
const mergedModes = existingModes
|
|
22
|
+
? { ...modes, ...existingModes }
|
|
23
|
+
: modes
|
|
24
|
+
|
|
25
|
+
const processedChildren: React.ReactNode | undefined = hasChildren
|
|
26
|
+
? cloneChildrenWithModes(
|
|
27
|
+
React.Children.toArray(childChildren),
|
|
28
|
+
modes
|
|
29
|
+
)
|
|
30
|
+
: undefined
|
|
31
|
+
|
|
32
|
+
return React.cloneElement(
|
|
33
|
+
child,
|
|
34
|
+
{
|
|
35
|
+
...(child.props as any),
|
|
36
|
+
modes: mergedModes,
|
|
37
|
+
},
|
|
38
|
+
processedChildren
|
|
39
|
+
)
|
|
40
|
+
})
|
|
41
|
+
return result || []
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ===== Item Subcomponent =====
|
|
45
|
+
|
|
46
|
+
export type TransactionDetailsItemProps = {
|
|
47
|
+
/** The label text displayed above the value (e.g., "UPI transaction ID") */
|
|
48
|
+
label?: string
|
|
49
|
+
/** The value text displayed below the label (e.g., "101674916166") */
|
|
50
|
+
value?: string
|
|
51
|
+
/** Modes object passed to `getVariableByName` for design token resolution */
|
|
52
|
+
modes?: Record<string, any>
|
|
53
|
+
/** Optional container style overrides */
|
|
54
|
+
style?: StyleProp<ViewStyle>
|
|
55
|
+
/** Optional label text style overrides */
|
|
56
|
+
labelStyle?: StyleProp<TextStyle>
|
|
57
|
+
/** Optional value text style overrides */
|
|
58
|
+
valueStyle?: StyleProp<TextStyle>
|
|
59
|
+
/** Accessibility label for screen readers */
|
|
60
|
+
accessibilityLabel?: string
|
|
61
|
+
} & React.ComponentProps<typeof View>
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Item component that displays a label-value pair, used within TransactionDetails.
|
|
65
|
+
* Access via `TransactionDetails.Item`.
|
|
66
|
+
*
|
|
67
|
+
* @component
|
|
68
|
+
* @param {Object} props
|
|
69
|
+
* @param {string} [props.label='Label'] - The label text displayed above the value.
|
|
70
|
+
* @param {string} [props.value='Value'] - The value text displayed below the label.
|
|
71
|
+
* @param {Object} [props.modes={}] - Modes object passed to `getVariableByName` for design tokens.
|
|
72
|
+
* @param {Object} [props.style] - Optional container style overrides.
|
|
73
|
+
* @param {Object} [props.labelStyle] - Optional label text style overrides.
|
|
74
|
+
* @param {Object} [props.valueStyle] - Optional value text style overrides.
|
|
75
|
+
* @param {string} [props.accessibilityLabel] - Accessibility label for screen readers.
|
|
76
|
+
*/
|
|
77
|
+
function Item({
|
|
78
|
+
label = 'Label',
|
|
79
|
+
value = 'Value',
|
|
80
|
+
modes = {},
|
|
81
|
+
style,
|
|
82
|
+
labelStyle,
|
|
83
|
+
valueStyle,
|
|
84
|
+
accessibilityLabel,
|
|
85
|
+
...rest
|
|
86
|
+
}: TransactionDetailsItemProps) {
|
|
87
|
+
// Resolve design tokens for Item
|
|
88
|
+
const gap = getVariableByName('detailItem/gap', modes) ?? 4
|
|
89
|
+
|
|
90
|
+
// Label typography tokens
|
|
91
|
+
const labelColor = getVariableByName('detailItem/label/color', modes) || '#0c0d10'
|
|
92
|
+
const labelFontSize = getVariableByName('detailItem/label/fontSize', modes) || 14
|
|
93
|
+
const labelFontFamily = getVariableByName('detailItem/label/fontFamily', modes) || 'System'
|
|
94
|
+
const labelLineHeight = getVariableByName('detailItem/label/lineHeight', modes) || 17
|
|
95
|
+
const labelFontWeightRaw = getVariableByName('detailItem/label/fontWeight', modes) || 500
|
|
96
|
+
const labelFontWeight = typeof labelFontWeightRaw === 'number'
|
|
97
|
+
? labelFontWeightRaw.toString()
|
|
98
|
+
: labelFontWeightRaw
|
|
99
|
+
|
|
100
|
+
// Value typography tokens
|
|
101
|
+
const valueColor = getVariableByName('detailItem/value/color', modes) || '#24262b'
|
|
102
|
+
const valueFontSize = getVariableByName('detailItem/value/fontSize', modes) || 14
|
|
103
|
+
const valueFontFamily = getVariableByName('detailItem/value/fontFamily', modes) || 'System'
|
|
104
|
+
const valueLineHeight = getVariableByName('detailItem/value/lineHeight', modes) || 17
|
|
105
|
+
const valueFontWeightRaw = getVariableByName('detailItem/value/fontWeight', modes) || 'Medium'
|
|
106
|
+
const valueFontWeight = typeof valueFontWeightRaw === 'number'
|
|
107
|
+
? valueFontWeightRaw.toString()
|
|
108
|
+
: valueFontWeightRaw === 'Medium' ? '500' : valueFontWeightRaw
|
|
109
|
+
|
|
110
|
+
const containerStyle: ViewStyle = {
|
|
111
|
+
flexDirection: 'column',
|
|
112
|
+
alignItems: 'flex-start',
|
|
113
|
+
justifyContent: 'center',
|
|
114
|
+
gap,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const labelTextStyle: TextStyle = {
|
|
118
|
+
color: labelColor,
|
|
119
|
+
fontSize: labelFontSize,
|
|
120
|
+
fontFamily: labelFontFamily,
|
|
121
|
+
lineHeight: labelLineHeight,
|
|
122
|
+
fontWeight: labelFontWeight,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const valueTextStyle: TextStyle = {
|
|
126
|
+
color: valueColor,
|
|
127
|
+
fontSize: valueFontSize,
|
|
128
|
+
fontFamily: valueFontFamily,
|
|
129
|
+
lineHeight: valueLineHeight,
|
|
130
|
+
fontWeight: valueFontWeight,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const defaultAccessibilityLabel = accessibilityLabel || `${label}: ${value}`
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<View
|
|
137
|
+
style={[containerStyle, style]}
|
|
138
|
+
accessibilityRole="text"
|
|
139
|
+
accessibilityLabel={defaultAccessibilityLabel}
|
|
140
|
+
{...rest}
|
|
141
|
+
>
|
|
142
|
+
<Text
|
|
143
|
+
style={[labelTextStyle, labelStyle]}
|
|
144
|
+
accessibilityElementsHidden={true}
|
|
145
|
+
importantForAccessibility="no"
|
|
146
|
+
>
|
|
147
|
+
{label}
|
|
148
|
+
</Text>
|
|
149
|
+
<Text
|
|
150
|
+
style={[valueTextStyle, valueStyle]}
|
|
151
|
+
accessibilityElementsHidden={true}
|
|
152
|
+
importantForAccessibility="no"
|
|
153
|
+
>
|
|
154
|
+
{value}
|
|
155
|
+
</Text>
|
|
156
|
+
</View>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ===== TransactionDetails Component =====
|
|
161
|
+
|
|
162
|
+
export type TransactionDetailsProps = {
|
|
163
|
+
/** Slot for TransactionDetails.Item children */
|
|
164
|
+
children?: React.ReactNode
|
|
165
|
+
/** Modes object passed to `getVariableByName` for design token resolution */
|
|
166
|
+
modes?: Record<string, any>
|
|
167
|
+
/** Optional container style overrides */
|
|
168
|
+
style?: StyleProp<ViewStyle>
|
|
169
|
+
/** Accessibility label for screen readers */
|
|
170
|
+
accessibilityLabel?: string
|
|
171
|
+
} & React.ComponentProps<typeof View>
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* TransactionDetails component that displays a list of transaction detail items.
|
|
175
|
+
*
|
|
176
|
+
* This component serves as a container for TransactionDetails.Item children, applying consistent
|
|
177
|
+
* spacing and padding as defined by Figma design tokens.
|
|
178
|
+
*
|
|
179
|
+
* @component
|
|
180
|
+
* @param {Object} props
|
|
181
|
+
* @param {React.ReactNode} [props.children] - TransactionDetails.Item children to render.
|
|
182
|
+
* @param {Object} [props.modes={}] - Modes object passed to `getVariableByName` for design tokens.
|
|
183
|
+
* @param {Object} [props.style] - Optional container style overrides.
|
|
184
|
+
* @param {string} [props.accessibilityLabel] - Accessibility label for screen readers.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* <TransactionDetails modes={{ 'Color Mode': 'Light' }}>
|
|
189
|
+
* <TransactionDetails.Item label="UPI transaction ID" value="101674916166" />
|
|
190
|
+
* <TransactionDetails.Item label="From" value="JioFinance • shivashankar@okjio" />
|
|
191
|
+
* <TransactionDetails.Item label="To" value="JioFinance • shivashankar@okjio" />
|
|
192
|
+
* <TransactionDetails.Item label="Payment method" value="UPI" />
|
|
193
|
+
* </TransactionDetails>
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
function TransactionDetails({
|
|
197
|
+
children,
|
|
198
|
+
modes = {},
|
|
199
|
+
style,
|
|
200
|
+
accessibilityLabel,
|
|
201
|
+
...rest
|
|
202
|
+
}: TransactionDetailsProps) {
|
|
203
|
+
// Resolve design tokens for TransactionDetails
|
|
204
|
+
const gap = getVariableByName('transationDetails/gap', modes) ?? 16
|
|
205
|
+
const paddingHorizontal = getVariableByName('transationDetails/padding/horizontal', modes) ?? 0
|
|
206
|
+
const paddingVertical = getVariableByName('transationDetails/padding/vertical', modes) ?? 0
|
|
207
|
+
|
|
208
|
+
const containerStyle: ViewStyle = {
|
|
209
|
+
flexDirection: 'column',
|
|
210
|
+
alignItems: 'flex-start',
|
|
211
|
+
gap,
|
|
212
|
+
paddingHorizontal,
|
|
213
|
+
paddingVertical,
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Process children to pass modes prop
|
|
217
|
+
const processedChildren = children
|
|
218
|
+
? cloneChildrenWithModes(React.Children.toArray(children), modes)
|
|
219
|
+
: null
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<View
|
|
223
|
+
style={[containerStyle, style]}
|
|
224
|
+
accessibilityRole="summary"
|
|
225
|
+
accessibilityLabel={accessibilityLabel || 'Transaction details'}
|
|
226
|
+
{...rest}
|
|
227
|
+
>
|
|
228
|
+
{processedChildren}
|
|
229
|
+
</View>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Attach Item as a static property for compound component pattern
|
|
234
|
+
TransactionDetails.Item = Item
|
|
235
|
+
|
|
236
|
+
export default TransactionDetails
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Meta, Story, Canvas, PureArgsTable as ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as TransactionStatusStories from './TransactionStatus.stories';
|
|
3
|
+
import TransactionStatus from './TransactionStatus';
|
|
4
|
+
|
|
5
|
+
<Meta of={TransactionStatusStories} />
|
|
6
|
+
|
|
7
|
+
# TransactionStatus
|
|
8
|
+
|
|
9
|
+
TransactionStatus component with design-token-driven styling.
|
|
10
|
+
|
|
11
|
+
## Available Collections and Modes
|
|
12
|
+
|
|
13
|
+
This component uses the following design token collections. Each collection supports multiple modes that can be configured via the `modes` prop.
|
|
14
|
+
|
|
15
|
+
### Transaction Status
|
|
16
|
+
- **Modes:** Request | Paid | Declined | Expired
|
|
17
|
+
- **Default:** Request
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
<Canvas>
|
|
21
|
+
<Story of={TransactionStatusStories.Default} />
|
|
22
|
+
</Canvas>
|
|
23
|
+
|
|
24
|
+
## Props
|
|
25
|
+
|
|
26
|
+
<ArgsTable of={TransactionStatus} />
|
|
27
|
+
|
|
28
|
+
## Design Tokens
|
|
29
|
+
|
|
30
|
+
This component uses the following design tokens, resolved through `getVariableByName`:
|
|
31
|
+
|
|
32
|
+
- **`transactionBubble/statusWrap/gap`**
|
|
33
|
+
- **`transactionStatus/color`**
|
|
34
|
+
- **`transactionStatus/fontFamily`**
|
|
35
|
+
- **`transactionStatus/fontSize`**
|
|
36
|
+
- **`transactionStatus/fontWeight2`**
|
|
37
|
+
- **`transactionStatus/icon/color`**
|
|
38
|
+
- **`transactionStatus/iconSize`**
|
|
39
|
+
- **`transactionStatus/lineHeight`**
|
|
40
|
+
|
|
41
|
+
All tokens support mode-based theming through the `modes` prop.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, type ViewStyle, type TextStyle } from 'react-native'
|
|
3
|
+
import { Svg, Path } from 'react-native-svg'
|
|
4
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
5
|
+
|
|
6
|
+
// --- Internal Icon Component ---
|
|
7
|
+
type StatusIconProps = {
|
|
8
|
+
modes?: Record<string, any>
|
|
9
|
+
width?: number
|
|
10
|
+
height?: number
|
|
11
|
+
color?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const StatusIcon = ({
|
|
15
|
+
modes = {},
|
|
16
|
+
width = 15,
|
|
17
|
+
height = 15,
|
|
18
|
+
color,
|
|
19
|
+
}: StatusIconProps) => {
|
|
20
|
+
const resolvedColor = color || getVariableByName('transactionStatus/icon/color', modes) || '#F06D0F'
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Svg
|
|
24
|
+
width={width}
|
|
25
|
+
height={height}
|
|
26
|
+
viewBox="0 0 15 15"
|
|
27
|
+
fill="none"
|
|
28
|
+
>
|
|
29
|
+
<Path
|
|
30
|
+
d="M7.5 0C6.01664 0 4.5666 0.439867 3.33323 1.26398C2.09986 2.08809 1.13856 3.25943 0.570907 4.62987C0.00324963 6.00032 -0.145275 7.50832 0.144114 8.96318C0.433503 10.418 1.14781 11.7544 2.1967 12.8033C3.2456 13.8522 4.58197 14.5665 6.03683 14.8559C7.49168 15.1453 8.99968 14.9968 10.3701 14.4291C11.7406 13.8614 12.9119 12.9001 13.736 11.6668C14.5601 10.4334 15 8.98336 15 7.5C15 6.51509 14.806 5.53982 14.4291 4.62987C14.0522 3.71993 13.4997 2.89314 12.8033 2.1967C12.1069 1.50026 11.2801 0.947814 10.3701 0.570904C9.46019 0.193993 8.48492 0 7.5 0V0ZM6.75 3.375C6.75 3.17609 6.82902 2.98532 6.96967 2.84467C7.11033 2.70402 7.30109 2.625 7.5 2.625C7.69892 2.625 7.88968 2.70402 8.03033 2.84467C8.17099 2.98532 8.25 3.17609 8.25 3.375V7.875C8.25 8.07391 8.17099 8.26468 8.03033 8.40533C7.88968 8.54598 7.69892 8.625 7.5 8.625C7.30109 8.625 7.11033 8.54598 6.96967 8.40533C6.82902 8.26468 6.75 8.07391 6.75 7.875V3.375ZM7.5 12.375C7.2775 12.375 7.05999 12.309 6.87499 12.1854C6.68998 12.0618 6.54579 11.8861 6.46064 11.6805C6.37549 11.475 6.35321 11.2488 6.39662 11.0305C6.44003 10.8123 6.54717 10.6118 6.70451 10.4545C6.86184 10.2972 7.0623 10.19 7.28053 10.1466C7.49876 10.1032 7.72496 10.1255 7.93052 10.2106C8.13609 10.2958 8.31179 10.44 8.43541 10.625C8.55902 10.81 8.625 11.0275 8.625 11.25C8.625 11.5484 8.50648 11.8345 8.2955 12.0455C8.08452 12.2565 7.79837 12.375 7.5 12.375Z"
|
|
31
|
+
fill={resolvedColor}
|
|
32
|
+
fillRule="evenodd" // Added based on typical icon behavior, though Figma output said 'nonzero' default. SVG data usually needs checking.
|
|
33
|
+
/>
|
|
34
|
+
</Svg>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// --- Main Component ---
|
|
39
|
+
|
|
40
|
+
export type TransactionStatusProps = {
|
|
41
|
+
/** Status text, e.g. "Expired" */
|
|
42
|
+
status?: string
|
|
43
|
+
/** Date text, e.g. "20 Mar 2025" */
|
|
44
|
+
date?: string
|
|
45
|
+
/** Modes for design token resolution */
|
|
46
|
+
modes?: Record<string, any>
|
|
47
|
+
/** Optional container style */
|
|
48
|
+
style?: ViewStyle
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* TransactionStatus component displaying status icon, label, and date.
|
|
53
|
+
*/
|
|
54
|
+
export default function TransactionStatus({
|
|
55
|
+
status = 'Expired',
|
|
56
|
+
date = '20 Mar 2025',
|
|
57
|
+
modes = {},
|
|
58
|
+
style,
|
|
59
|
+
}: TransactionStatusProps) {
|
|
60
|
+
const gap = Number(getVariableByName('transactionBubble/statusWrap/gap', modes)) || 4
|
|
61
|
+
// Using 'transactionStatus' tokens for text
|
|
62
|
+
const textColor = getVariableByName('transactionStatus/color', modes) || '#191b1e'
|
|
63
|
+
const fontSize = Number(getVariableByName('transactionStatus/fontSize', modes)) || 12
|
|
64
|
+
const lineHeight = Number(getVariableByName('transactionStatus/lineHeight', modes)) || 16
|
|
65
|
+
const fontFamily = getVariableByName('transactionStatus/fontFamily', modes) || 'System'
|
|
66
|
+
const fontWeight = getVariableByName('transactionStatus/fontWeight2', modes) || '500'
|
|
67
|
+
|
|
68
|
+
const iconColor = getVariableByName('transactionStatus/icon/color', modes) || '#f06d0f'
|
|
69
|
+
const iconSize = Number(getVariableByName('transactionStatus/iconSize', modes)) || 18
|
|
70
|
+
|
|
71
|
+
const containerStyle: ViewStyle = {
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
gap,
|
|
75
|
+
...style,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const textStyle: TextStyle = {
|
|
79
|
+
color: textColor,
|
|
80
|
+
fontSize,
|
|
81
|
+
lineHeight,
|
|
82
|
+
fontFamily,
|
|
83
|
+
fontWeight: fontWeight as any,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View style={containerStyle}>
|
|
88
|
+
<StatusIcon width={iconSize} height={iconSize} color={iconColor} modes={modes} />
|
|
89
|
+
<Text style={textStyle} numberOfLines={1}>
|
|
90
|
+
{status} · {date}
|
|
91
|
+
</Text>
|
|
92
|
+
</View>
|
|
93
|
+
)
|
|
94
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { default as CardFeedback } from './CardFeedback/CardFeedback';
|
|
|
11
11
|
export { default as Disclaimer } from './Disclaimer/Disclaimer';
|
|
12
12
|
export { default as Divider, type DividerProps, type DividerDirection } from './Divider/Divider';
|
|
13
13
|
export { default as Drawer } from './Drawer/Drawer';
|
|
14
|
+
export { default as CtaCard } from './CtaCard/CtaCard';
|
|
14
15
|
export { default as FilterBar } from './FilterBar/FilterBar';
|
|
15
16
|
export { default as IconButton } from './IconButton/IconButton';
|
|
16
17
|
export { default as IconCapsule } from './IconCapsule/IconCapsule';
|
|
@@ -27,5 +28,9 @@ export { default as Stepper } from './Stepper/Stepper';
|
|
|
27
28
|
export { Step } from './Stepper/Step';
|
|
28
29
|
export { StepLabel } from './Stepper/StepLabel';
|
|
29
30
|
export { default as TextInput } from './TextInput/TextInput';
|
|
31
|
+
export { default as ThreadHero, type ThreadHeroProps } from './ThreadHero/ThreadHero';
|
|
30
32
|
export { Tooltip } from './Tooltip/Tooltip';
|
|
33
|
+
export { default as TransactionBubble } from './TransactionBubble/TransactionBubble';
|
|
34
|
+
export { default as TransactionDetails } from './TransactionDetails/TransactionDetails';
|
|
35
|
+
export { default as TransactionStatus } from './TransactionStatus/TransactionStatus';
|
|
31
36
|
export { default as UpiHandle } from './UpiHandle/UpiHandle';
|
package/src/icons/registry.ts
CHANGED