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.
Files changed (105) hide show
  1. package/lib/commonjs/components/Accordion/Accordion.js +217 -0
  2. package/lib/commonjs/components/Accordion/Accordion.js.map +1 -0
  3. package/lib/commonjs/components/Accordion/Accordion.mdx +122 -0
  4. package/lib/commonjs/components/ActionTile/ActionTile.js +93 -0
  5. package/lib/commonjs/components/ActionTile/ActionTile.js.map +1 -0
  6. package/lib/commonjs/components/ActionTile/ActionTile.mdx +54 -0
  7. package/lib/commonjs/components/ActionTile/index.js +14 -0
  8. package/lib/commonjs/components/ActionTile/index.js.map +1 -0
  9. package/lib/commonjs/components/CtaCard/CtaCard.js +122 -0
  10. package/lib/commonjs/components/CtaCard/CtaCard.js.map +1 -0
  11. package/lib/commonjs/components/CtaCard/CtaCard.mdx +66 -0
  12. package/lib/commonjs/components/CtaCard/index.js +14 -0
  13. package/lib/commonjs/components/CtaCard/index.js.map +1 -0
  14. package/lib/commonjs/components/MoneyValue/MoneyValue.js +36 -4
  15. package/lib/commonjs/components/MoneyValue/MoneyValue.js.map +1 -1
  16. package/lib/commonjs/components/ThreadHero/ThreadHero.js +114 -0
  17. package/lib/commonjs/components/ThreadHero/ThreadHero.js.map +1 -0
  18. package/lib/commonjs/components/ThreadHero/ThreadHero.mdx +69 -0
  19. package/lib/commonjs/components/TransactionBubble/TransactionBubble.js +101 -0
  20. package/lib/commonjs/components/TransactionBubble/TransactionBubble.js.map +1 -0
  21. package/lib/commonjs/components/TransactionBubble/TransactionBubble.mdx +40 -0
  22. package/lib/commonjs/components/TransactionDetails/TransactionDetails.js +177 -0
  23. package/lib/commonjs/components/TransactionDetails/TransactionDetails.js.map +1 -0
  24. package/lib/commonjs/components/TransactionDetails/TransactionDetails.mdx +98 -0
  25. package/lib/commonjs/components/TransactionStatus/TransactionStatus.js +82 -0
  26. package/lib/commonjs/components/TransactionStatus/TransactionStatus.js.map +1 -0
  27. package/lib/commonjs/components/TransactionStatus/TransactionStatus.mdx +41 -0
  28. package/lib/commonjs/components/index.js +35 -0
  29. package/lib/commonjs/components/index.js.map +1 -1
  30. package/lib/commonjs/design-tokens/figma-variables-resolver.js +3 -9
  31. package/lib/commonjs/icons/registry.js +1 -1
  32. package/lib/module/components/Accordion/Accordion.js +212 -0
  33. package/lib/module/components/Accordion/Accordion.js.map +1 -0
  34. package/lib/module/components/Accordion/Accordion.mdx +122 -0
  35. package/lib/module/components/ActionTile/ActionTile.js +88 -0
  36. package/lib/module/components/ActionTile/ActionTile.js.map +1 -0
  37. package/lib/module/components/ActionTile/ActionTile.mdx +54 -0
  38. package/lib/module/components/ActionTile/index.js +4 -0
  39. package/lib/module/components/ActionTile/index.js.map +1 -0
  40. package/lib/module/components/CtaCard/CtaCard.js +117 -0
  41. package/lib/module/components/CtaCard/CtaCard.js.map +1 -0
  42. package/lib/module/components/CtaCard/CtaCard.mdx +66 -0
  43. package/lib/module/components/CtaCard/index.js +4 -0
  44. package/lib/module/components/CtaCard/index.js.map +1 -0
  45. package/lib/module/components/MoneyValue/MoneyValue.js +36 -4
  46. package/lib/module/components/MoneyValue/MoneyValue.js.map +1 -1
  47. package/lib/module/components/ThreadHero/ThreadHero.js +109 -0
  48. package/lib/module/components/ThreadHero/ThreadHero.js.map +1 -0
  49. package/lib/module/components/ThreadHero/ThreadHero.mdx +69 -0
  50. package/lib/module/components/TransactionBubble/TransactionBubble.js +96 -0
  51. package/lib/module/components/TransactionBubble/TransactionBubble.js.map +1 -0
  52. package/lib/module/components/TransactionBubble/TransactionBubble.mdx +40 -0
  53. package/lib/module/components/TransactionDetails/TransactionDetails.js +174 -0
  54. package/lib/module/components/TransactionDetails/TransactionDetails.js.map +1 -0
  55. package/lib/module/components/TransactionDetails/TransactionDetails.mdx +98 -0
  56. package/lib/module/components/TransactionStatus/TransactionStatus.js +77 -0
  57. package/lib/module/components/TransactionStatus/TransactionStatus.js.map +1 -0
  58. package/lib/module/components/TransactionStatus/TransactionStatus.mdx +41 -0
  59. package/lib/module/components/index.js +5 -0
  60. package/lib/module/components/index.js.map +1 -1
  61. package/lib/module/icons/registry.js +1 -1
  62. package/lib/typescript/components/Accordion/Accordion.d.ts +58 -0
  63. package/lib/typescript/components/Accordion/Accordion.d.ts.map +1 -0
  64. package/lib/typescript/components/ActionTile/ActionTile.d.ts +26 -0
  65. package/lib/typescript/components/ActionTile/ActionTile.d.ts.map +1 -0
  66. package/lib/typescript/components/ActionTile/index.d.ts +2 -0
  67. package/lib/typescript/components/ActionTile/index.d.ts.map +1 -0
  68. package/lib/typescript/components/CtaCard/CtaCard.d.ts +61 -0
  69. package/lib/typescript/components/CtaCard/CtaCard.d.ts.map +1 -0
  70. package/lib/typescript/components/CtaCard/index.d.ts +2 -0
  71. package/lib/typescript/components/CtaCard/index.d.ts.map +1 -0
  72. package/lib/typescript/components/MoneyValue/MoneyValue.d.ts +9 -2
  73. package/lib/typescript/components/MoneyValue/MoneyValue.d.ts.map +1 -1
  74. package/lib/typescript/components/ThreadHero/ThreadHero.d.ts +21 -0
  75. package/lib/typescript/components/ThreadHero/ThreadHero.d.ts.map +1 -0
  76. package/lib/typescript/components/TransactionBubble/TransactionBubble.d.ts +24 -0
  77. package/lib/typescript/components/TransactionBubble/TransactionBubble.d.ts.map +1 -0
  78. package/lib/typescript/components/TransactionDetails/TransactionDetails.d.ts +57 -0
  79. package/lib/typescript/components/TransactionDetails/TransactionDetails.d.ts.map +1 -0
  80. package/lib/typescript/components/TransactionStatus/TransactionStatus.d.ts +16 -0
  81. package/lib/typescript/components/TransactionStatus/TransactionStatus.d.ts.map +1 -0
  82. package/lib/typescript/components/index.d.ts +5 -0
  83. package/lib/typescript/components/index.d.ts.map +1 -1
  84. package/lib/typescript/icons/registry.d.ts +1 -1
  85. package/package.json +5 -2
  86. package/src/components/.token-metadata.json +161 -0
  87. package/src/components/Accordion/Accordion.mdx +122 -0
  88. package/src/components/Accordion/Accordion.tsx +279 -0
  89. package/src/components/ActionTile/ActionTile.mdx +54 -0
  90. package/src/components/ActionTile/ActionTile.tsx +100 -0
  91. package/src/components/ActionTile/index.ts +1 -0
  92. package/src/components/CtaCard/CtaCard.mdx +66 -0
  93. package/src/components/CtaCard/CtaCard.tsx +185 -0
  94. package/src/components/CtaCard/index.ts +1 -0
  95. package/src/components/MoneyValue/MoneyValue.tsx +39 -3
  96. package/src/components/ThreadHero/ThreadHero.mdx +69 -0
  97. package/src/components/ThreadHero/ThreadHero.tsx +124 -0
  98. package/src/components/TransactionBubble/TransactionBubble.mdx +40 -0
  99. package/src/components/TransactionBubble/TransactionBubble.tsx +113 -0
  100. package/src/components/TransactionDetails/TransactionDetails.mdx +98 -0
  101. package/src/components/TransactionDetails/TransactionDetails.tsx +236 -0
  102. package/src/components/TransactionStatus/TransactionStatus.mdx +41 -0
  103. package/src/components/TransactionStatus/TransactionStatus.tsx +94 -0
  104. package/src/components/index.ts +5 -0
  105. package/src/icons/registry.ts +1 -1
@@ -0,0 +1,122 @@
1
+ import { Meta, Story, Canvas, PureArgsTable as ArgsTable } from '@storybook/addon-docs/blocks';
2
+ import * as AccordionStories from './Accordion.stories';
3
+ import Accordion from './Accordion';
4
+ import { AccessibilitySection, AnatomySection, UsageConstraintsSection } from '../docs/DocSections';
5
+
6
+ <Meta of={AccordionStories} />
7
+
8
+ # Accordion
9
+
10
+ Accordion component that mirrors the Figma "Accordion" component. It provides an expandable/collapsible container for content with smooth animation.
11
+
12
+ ## Available Collections and Modes
13
+
14
+ This component uses the following design token collections. Each collection supports multiple modes that can be configured via the `modes` prop.
15
+
16
+ ### Accordion States
17
+ - **Modes:** Idle | Hover | Open | Open Hover | Disabled
18
+ - **Default:** Idle
19
+ ## Usage
20
+
21
+ <Canvas>
22
+ <Story of={AccordionStories.Default} />
23
+ </Canvas>
24
+
25
+ ## With ListItem Content
26
+
27
+ <Canvas>
28
+ <Story of={AccordionStories.WithListItems} />
29
+ </Canvas>
30
+
31
+ ## Accordion Group
32
+
33
+ <Canvas>
34
+ <Story of={AccordionStories.AccordionGroup} />
35
+ </Canvas>
36
+
37
+ <AccessibilitySection
38
+ items={[
39
+ 'The accordion header has `accessibilityRole="button"` for proper screen reader announcement.',
40
+ 'The `accessibilityState.expanded` property indicates the current state to assistive technology.',
41
+ 'When disabled, `accessibilityState.disabled` is set to true.',
42
+ 'Custom `accessibilityLabel` and `accessibilityHint` can be provided for better context.',
43
+ 'Content within the accordion should maintain its own accessibility attributes.',
44
+ ]}
45
+ />
46
+
47
+ <AnatomySection>
48
+ <ul>
49
+ <li><strong>Header</strong> — Pressable area containing the title and expand/collapse icon (plus/minus).</li>
50
+ <li><strong>Content Slot</strong> — Expandable area that shows/hides with animation. Pass any React children.</li>
51
+ <li><strong>Border</strong> — Bottom border separating accordions when stacked.</li>
52
+ </ul>
53
+ </AnatomySection>
54
+
55
+ <UsageConstraintsSection
56
+ items={[
57
+ 'Use the `modes` prop to ensure consistent theming with surrounding components.',
58
+ 'When nesting components in the content slot, they automatically receive the parent modes via cloning.',
59
+ 'Avoid deeply nested interactive elements that may confuse keyboard navigation.',
60
+ 'For controlled behavior, provide both `expanded` and `onExpandedChange` props.',
61
+ 'Keep accordion titles concise; they are truncated to a single line.',
62
+ ]}
63
+ />
64
+
65
+ ## Props
66
+
67
+ <ArgsTable of={Accordion} />
68
+
69
+ ## Design Tokens
70
+
71
+ This component uses the following design tokens, resolved through `getVariableByName`:
72
+
73
+ - **`accordion/border/color`**
74
+ - **`accordion/content/gap`**
75
+ - **`accordion/content/padding/bottom`**
76
+ - **`accordion/content/padding/top`**
77
+ - **`accordion/header/background`**
78
+ - **`accordion/header/gap`**
79
+ - **`accordion/header/padding/vertical`**
80
+ - **`accordion/icon/color`**
81
+ - **`accordion/icon/size`**
82
+ - **`accordion/title/color`**
83
+ - **`accordion/title/fontFamily`**
84
+ - **`accordion/title/fontSize`**
85
+ - **`accordion/title/lineHeight`**
86
+
87
+ All tokens support mode-based theming through the `modes` prop.
88
+ ## Example Usage
89
+
90
+ ```tsx
91
+ import { Accordion, ListItem, IconCapsule, MoneyValue } from '@jsf/components';
92
+
93
+ function PaymentSection() {
94
+ return (
95
+ <Accordion
96
+ title="Payment Methods"
97
+ defaultExpanded={true}
98
+ modes={{ 'Color Mode': 'Light' }}
99
+ >
100
+ <ListItem
101
+ layout="Horizontal"
102
+ title="Credit Card"
103
+ supportText="Ending in 4242"
104
+ leading={<IconCapsule iconName="ic_card" />}
105
+ endSlot={<MoneyValue value="500" currency="₹" />}
106
+ navArrow={true}
107
+ />
108
+ <ListItem
109
+ layout="Horizontal"
110
+ title="Savings Account"
111
+ supportText="HDFC Bank"
112
+ leading={<IconCapsule iconName="ic_bank_account" />}
113
+ endSlot={<MoneyValue value="25,000" currency="₹" />}
114
+ navArrow={true}
115
+ />
116
+ </Accordion>
117
+ );
118
+ }
119
+ ```
120
+
121
+
122
+
@@ -0,0 +1,279 @@
1
+ import React, { useState } from 'react'
2
+ import {
3
+ View,
4
+ Text,
5
+ Pressable,
6
+ LayoutAnimation,
7
+ Platform,
8
+ UIManager,
9
+ type StyleProp,
10
+ type ViewStyle,
11
+ type TextStyle,
12
+ type AccessibilityState,
13
+ } from 'react-native'
14
+ import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
15
+ import Icon from '../../icons/Icon'
16
+ import { usePressableWebSupport, type WebAccessibilityProps } from '../../utils/web-platform-utils'
17
+
18
+ // Enable LayoutAnimation on Android
19
+ if (Platform.OS === 'android' && UIManager.setLayoutAnimationEnabledExperimental) {
20
+ UIManager.setLayoutAnimationEnabledExperimental(true)
21
+ }
22
+
23
+ /**
24
+ * Helper function to recursively clone children and pass modes prop to components that accept it.
25
+ * This ensures that all child components in slots receive the modes prop from the parent.
26
+ */
27
+ function cloneChildrenWithModes(
28
+ children: React.ReactNode,
29
+ modes: Record<string, any>
30
+ ): React.ReactNode[] {
31
+ const result = React.Children.map(children, (child) => {
32
+ if (!React.isValidElement(child)) {
33
+ return child
34
+ }
35
+
36
+ // Get existing children
37
+ const childChildren = (child.props as any)?.children
38
+ const hasChildren = childChildren !== undefined && childChildren !== null
39
+
40
+ // Merge modes: parent modes first, then child's explicit modes override them
41
+ const existingModes = (child.props as any)?.modes
42
+ const mergedModes = existingModes
43
+ ? { ...modes, ...existingModes }
44
+ : modes
45
+
46
+ // Recursively process children if they exist
47
+ const processedChildren: React.ReactNode | undefined = hasChildren
48
+ ? cloneChildrenWithModes(
49
+ React.Children.toArray(childChildren),
50
+ modes
51
+ )
52
+ : undefined
53
+
54
+ // Clone element with modes and processed children
55
+ return React.cloneElement(
56
+ child,
57
+ {
58
+ ...(child.props as any),
59
+ modes: mergedModes,
60
+ },
61
+ processedChildren
62
+ )
63
+ })
64
+ return result || []
65
+ }
66
+
67
+ export type AccordionProps = {
68
+ /** The accordion header title */
69
+ title?: string;
70
+ /** Initial expanded state. Defaults to false (collapsed) */
71
+ defaultExpanded?: boolean;
72
+ /** Controlled expanded state. When provided, the component becomes controlled */
73
+ expanded?: boolean;
74
+ /** Callback fired when the accordion's expanded state changes */
75
+ onExpandedChange?: (expanded: boolean) => void;
76
+ /** Whether the accordion is disabled */
77
+ disabled?: boolean;
78
+ /** Content to display when the accordion is expanded (Figma Slot: 'content') */
79
+ children?: React.ReactNode;
80
+ /** Modes object passed to getVariableByName for all design tokens */
81
+ modes?: Record<string, any>;
82
+ /** Optional container style overrides */
83
+ style?: StyleProp<ViewStyle>;
84
+ /** Accessibility label for screen readers. If not provided, uses title */
85
+ accessibilityLabel?: string;
86
+ /** Additional accessibility hint for screen readers */
87
+ accessibilityHint?: string;
88
+ /** Additional accessibility state information */
89
+ accessibilityState?: AccessibilityState;
90
+ /** Web-specific accessibility props (only used on web platform) */
91
+ webAccessibilityProps?: WebAccessibilityProps;
92
+ } & React.ComponentProps<typeof View>;
93
+
94
+ /**
95
+ * Accordion component that mirrors the Figma "Accordion" component.
96
+ *
97
+ * This component supports:
98
+ * - **Expandable/collapsible content** with smooth animation
99
+ * - **States**: Idle, Hover, Open, Disabled
100
+ * - **Slot** for custom content
101
+ * - **Design-token driven styling** via `getVariableByName` and `modes`
102
+ *
103
+ * Wherever the Figma layer name contains "Slot", this component exposes a
104
+ * dedicated React "slot" prop:
105
+ * - Slot "content" → `children`
106
+ *
107
+ * @component
108
+ * @param {Object} props
109
+ * @param {string} [props.title='Accordion title'] - The accordion header title
110
+ * @param {boolean} [props.defaultExpanded=false] - Initial expanded state
111
+ * @param {boolean} [props.expanded] - Controlled expanded state
112
+ * @param {Function} [props.onExpandedChange] - Callback fired when expanded state changes
113
+ * @param {boolean} [props.disabled=false] - Whether the accordion is disabled
114
+ * @param {React.ReactNode} [props.children] - Content to display when expanded
115
+ * @param {Object} [props.modes={}] - Modes object passed to `getVariableByName` for all design tokens
116
+ * @param {Object} [props.style] - Optional container style overrides
117
+ * @param {string} [props.accessibilityLabel] - Accessibility label for the accordion. If not provided, uses title
118
+ * @param {string} [props.accessibilityHint] - Additional accessibility hint for screen readers
119
+ */
120
+ function Accordion({
121
+ title = 'Accordion title',
122
+ defaultExpanded = false,
123
+ expanded: controlledExpanded,
124
+ onExpandedChange,
125
+ disabled = false,
126
+ children,
127
+ modes = {},
128
+ style,
129
+ accessibilityLabel,
130
+ accessibilityHint,
131
+ accessibilityState,
132
+ webAccessibilityProps,
133
+ ...rest
134
+ }: AccordionProps) {
135
+ // Internal state for uncontrolled mode
136
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded)
137
+
138
+ // Determine if controlled or uncontrolled
139
+ const isControlled = controlledExpanded !== undefined
140
+ const isExpanded = isControlled ? controlledExpanded : internalExpanded
141
+
142
+ // Hover state for web
143
+ const [isHovered, setIsHovered] = useState(false)
144
+
145
+ // Handle toggle
146
+ const handleToggle = () => {
147
+ if (disabled) return
148
+
149
+ // Animate the layout change
150
+ LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
151
+
152
+ if (isControlled) {
153
+ onExpandedChange?.(!isExpanded)
154
+ } else {
155
+ setInternalExpanded(!isExpanded)
156
+ onExpandedChange?.(!isExpanded)
157
+ }
158
+ }
159
+
160
+ // Resolve design tokens
161
+ const titleColor = disabled
162
+ ? '#999999'
163
+ : getVariableByName('accordion/title/color', modes) || '#0d0d0d'
164
+ const titleFontSize = getVariableByName('accordion/title/fontSize', modes) || 18
165
+ const titleLineHeight = getVariableByName('accordion/title/lineHeight', modes) || 20
166
+ const titleFontFamily = getVariableByName('accordion/title/fontFamily', modes) || 'System'
167
+
168
+ const iconColor = getVariableByName('accordion/icon/color', modes) || '#141414'
169
+ const iconSize = getVariableByName('accordion/icon/size', modes) || 24
170
+
171
+ const headerGap = getVariableByName('accordion/header/gap', modes) || 12
172
+ const headerPaddingVertical = getVariableByName('accordion/header/padding/vertical', modes) || 24
173
+ const headerBackground = isHovered && !disabled
174
+ ? '#f2f2f2'
175
+ : getVariableByName('accordion/header/background', modes) || 'transparent'
176
+
177
+ const contentGap = getVariableByName('accordion/content/gap', modes) || 12
178
+ const contentPaddingTop = getVariableByName('accordion/content/padding/top', modes) || 8
179
+ const contentPaddingBottom = isExpanded
180
+ ? (getVariableByName('accordion/content/padding/bottom', modes) ?? 24)
181
+ : 8
182
+
183
+ const borderColor = getVariableByName('accordion/border/color', modes) || '#e6e6e6'
184
+
185
+ // Styles
186
+ const containerStyle: ViewStyle = {
187
+ borderBottomWidth: 1,
188
+ borderBottomColor: borderColor,
189
+ }
190
+
191
+ const headerStyle: ViewStyle = {
192
+ flexDirection: 'row',
193
+ alignItems: 'center',
194
+ gap: headerGap,
195
+ paddingVertical: headerPaddingVertical,
196
+ paddingHorizontal: 0,
197
+ backgroundColor: headerBackground,
198
+ overflow: 'hidden',
199
+ }
200
+
201
+ const titleStyle: TextStyle = {
202
+ flex: 1,
203
+ color: titleColor,
204
+ fontSize: titleFontSize,
205
+ lineHeight: titleLineHeight,
206
+ fontFamily: titleFontFamily,
207
+ fontWeight: '700',
208
+ }
209
+
210
+ const contentStyle: ViewStyle = {
211
+ backgroundColor: 'transparent',
212
+ gap: contentGap,
213
+ paddingTop: contentPaddingTop,
214
+ paddingBottom: contentPaddingBottom,
215
+ paddingHorizontal: 0,
216
+ overflow: 'hidden',
217
+ }
218
+
219
+ // Generate default accessibility label
220
+ const defaultAccessibilityLabel = accessibilityLabel || title
221
+
222
+ // Web platform support
223
+ const webProps = usePressableWebSupport({
224
+ restProps: {},
225
+ onPress: handleToggle,
226
+ disabled,
227
+ accessibilityLabel: defaultAccessibilityLabel,
228
+ webAccessibilityProps,
229
+ })
230
+
231
+ // Process children to pass modes
232
+ const processedChildren = children
233
+ ? cloneChildrenWithModes(React.Children.toArray(children), modes)
234
+ : null
235
+
236
+ return (
237
+ <View style={[containerStyle, style]} {...rest}>
238
+ <Pressable
239
+ accessibilityRole="button"
240
+ accessibilityLabel={defaultAccessibilityLabel}
241
+ accessibilityHint={accessibilityHint || (isExpanded ? 'Collapse accordion' : 'Expand accordion')}
242
+ accessibilityState={{
243
+ expanded: isExpanded,
244
+ disabled,
245
+ ...accessibilityState,
246
+ }}
247
+ onPress={handleToggle}
248
+ disabled={disabled}
249
+ onHoverIn={() => setIsHovered(true)}
250
+ onHoverOut={() => setIsHovered(false)}
251
+ style={({ pressed }) => [
252
+ headerStyle,
253
+ pressed && !disabled ? { opacity: 0.9 } : null,
254
+ ]}
255
+ {...webProps}
256
+ >
257
+ <Text style={titleStyle} numberOfLines={1}>
258
+ {title}
259
+ </Text>
260
+ <Icon
261
+ name={isExpanded ? 'ic_minus' : 'ic_add'}
262
+ size={iconSize}
263
+ color={disabled ? '#999999' : iconColor}
264
+ accessibilityElementsHidden={true}
265
+ importantForAccessibility="no"
266
+ />
267
+ </Pressable>
268
+
269
+ {isExpanded && processedChildren && (
270
+ <View style={contentStyle}>
271
+ {processedChildren}
272
+ </View>
273
+ )}
274
+ </View>
275
+ )
276
+ }
277
+
278
+ export default Accordion
279
+
@@ -0,0 +1,54 @@
1
+ import { Meta, Story, Canvas, PureArgsTable as Controls } from '@storybook/addon-docs/blocks';
2
+ import * as ActionTileStories from './ActionTile.stories';
3
+
4
+ <Meta of={ActionTileStories} />
5
+
6
+ # ActionTile
7
+
8
+ A tile component used for dashboard actions, displaying an icon and a label.
9
+
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
+ ### Color Mode
16
+ - **Modes:** Light | Dark
17
+ - **Default:** Light
18
+ ## Usage
19
+
20
+ ```tsx
21
+ import ActionTile from './ActionTile';
22
+ import IconCapsule from '../IconCapsule/IconCapsule';
23
+
24
+ // Default usage
25
+ <ActionTile label="Cards" />
26
+
27
+ // With custom icon
28
+ <ActionTile
29
+ label="Offers"
30
+ icon={<IconCapsule iconName="ic_offers" />}
31
+ />
32
+ ```
33
+
34
+ <Canvas of={ActionTileStories.Default} />
35
+
36
+ <Controls />
37
+
38
+
39
+ ## Design Tokens
40
+
41
+ This component uses the following design tokens, resolved through `getVariableByName`:
42
+
43
+ - **`actionTile/background`**
44
+ - **`actionTile/fontFamily`**
45
+ - **`actionTile/fontSize`**
46
+ - **`actionTile/fontWeight`**
47
+ - **`actionTile/foreground`**
48
+ - **`actionTile/gap`**
49
+ - **`actionTile/lineHeight`**
50
+ - **`actionTile/padding/horizontal`**
51
+ - **`actionTile/padding/vertical`**
52
+ - **`actionTile/radius`**
53
+
54
+ All tokens support mode-based theming through the `modes` prop.
@@ -0,0 +1,100 @@
1
+ import React from 'react'
2
+ import { View, Text, type ViewStyle, type TextStyle, TouchableOpacity } from 'react-native'
3
+ import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
4
+ import IconCapsule from '../IconCapsule/IconCapsule'
5
+
6
+ export type ActionTileProps = {
7
+ /** Label text, e.g. "Cards" */
8
+ label?: string
9
+ /**
10
+ * Icon component slot.
11
+ * Expects an IconCapsule or compatible component.
12
+ * Modes will be passed to this slot if it's a valid React element.
13
+ */
14
+ icon?: React.ReactNode
15
+ /** Modes for design token resolution */
16
+ modes?: Record<string, any>
17
+ /** Optional container style */
18
+ style?: ViewStyle
19
+ /** Callback when tile is pressed */
20
+ onPress?: () => void
21
+ }
22
+
23
+ /**
24
+ * ActionTile component from Figma design.
25
+ * Displays an icon (defaulting to IconCapsule) and a label.
26
+ *
27
+ * @component
28
+ */
29
+ export default function ActionTile({
30
+ label = 'Cards',
31
+ icon,
32
+ modes = {},
33
+ style,
34
+ onPress,
35
+ }: ActionTileProps) {
36
+ // Resolve tokens
37
+ const backgroundColor = getVariableByName('actionTile/background', modes) || '#ffffff'
38
+ const gap = Number(getVariableByName('actionTile/gap', modes)) || 8
39
+ const paddingHorizontal = Number(getVariableByName('actionTile/padding/horizontal', modes)) || 12
40
+ const paddingVertical = Number(getVariableByName('actionTile/padding/vertical', modes)) || 16
41
+ const radius = Number(getVariableByName('actionTile/radius', modes)) || 16
42
+
43
+ // Text tokens
44
+ const textColor = getVariableByName('actionTile/foreground', modes) || '#0d0d0f'
45
+ const fontSize = Number(getVariableByName('actionTile/fontSize', modes)) || 14
46
+ const fontFamily = getVariableByName('actionTile/fontFamily', modes) || 'JioType Var'
47
+ const fontWeightStr = getVariableByName('actionTile/fontWeight', modes) || '500'
48
+ const lineHeight = Number(getVariableByName('actionTile/lineHeight', modes)) || 17
49
+
50
+ const containerStyle: ViewStyle = {
51
+ backgroundColor,
52
+ borderRadius: radius,
53
+ paddingHorizontal,
54
+ paddingVertical,
55
+ gap,
56
+ width: 168, // Fixed width from design
57
+ height: 90, // Fixed height from design
58
+ alignItems: 'flex-start',
59
+ // ensure content stretches if needed, though design implies fixed size block
60
+ ...style,
61
+ }
62
+
63
+ const textStyle: TextStyle = {
64
+ color: textColor,
65
+ fontSize,
66
+ fontFamily,
67
+ fontWeight: fontWeightStr as any, // Cast to any or TextStyle fontWeight enum if needed
68
+ lineHeight,
69
+ }
70
+
71
+ // Handle Icon Slot: Pass modes safely
72
+ const renderIcon = () => {
73
+ if (React.isValidElement(icon)) {
74
+ // Pass modes down to the slot child
75
+ return React.cloneElement(icon as React.ReactElement<any>, { modes })
76
+ }
77
+ // Default fallback if no icon prop is provided, matching design default
78
+ if (!icon) {
79
+ return <IconCapsule modes={modes} />
80
+ }
81
+ return icon
82
+ }
83
+
84
+ const Content = (
85
+ <View style={containerStyle}>
86
+ {renderIcon()}
87
+ <Text style={textStyle}>{label}</Text>
88
+ </View>
89
+ )
90
+
91
+ if (onPress) {
92
+ return (
93
+ <TouchableOpacity onPress={onPress}>
94
+ {Content}
95
+ </TouchableOpacity>
96
+ )
97
+ }
98
+
99
+ return Content
100
+ }
@@ -0,0 +1 @@
1
+ export { default } from './ActionTile'
@@ -0,0 +1,66 @@
1
+ import { Meta, Story, Canvas, PureArgsTable as ArgsTable } from '@storybook/addon-docs/blocks';
2
+ import * as CtaCardStories from './CtaCard.stories';
3
+ import CtaCard from './CtaCard';
4
+
5
+ <Meta of={CtaCardStories} />
6
+
7
+ # CtaCard
8
+
9
+ `CtaCard` is a component used to display a Call-to-Action with an icon, title, body text, and a button.
10
+ It is designed to be flexible, allowing content to be passed via props or fully customized via slots.
11
+
12
+
13
+ ## Available Collections and Modes
14
+
15
+ This component does not use any design token collections with multiple modes.
16
+ ## Usage
17
+
18
+ ```tsx
19
+ import { CtaCard } from 'jfs-components'; // Adjust import based on your package structure
20
+
21
+ // Basic Usage
22
+ <CtaCard
23
+ title="Lets create your UPI ID"
24
+ body="Send and receive money securely."
25
+ iconName="ic_upi_number"
26
+ buttonLabel="Get started"
27
+ onPressButton={() => console.log('Pressed')}
28
+ />
29
+
30
+ // Using Slots
31
+ <CtaCard
32
+ titleSlot={<CustomTitle />}
33
+ buttonSlot={<CustomButton />}
34
+ />
35
+ ```
36
+
37
+ <Canvas>
38
+ <Story of={CtaCardStories.Default} />
39
+ </Canvas>
40
+
41
+ ## Props
42
+
43
+ <ArgsTable of={CtaCard} />
44
+
45
+
46
+ ## Design Tokens
47
+
48
+ This component uses the following design tokens, resolved through `getVariableByName`:
49
+
50
+ - **`ctaCard/background`**
51
+ - **`ctaCard/body/color`**
52
+ - **`ctaCard/body/fontFamily`**
53
+ - **`ctaCard/body/fontSize`**
54
+ - **`ctaCard/body/lineHeight`**
55
+ - **`ctaCard/content/gap`**
56
+ - **`ctaCard/gap`**
57
+ - **`ctaCard/padding/horizontal`**
58
+ - **`ctaCard/padding/vertical`**
59
+ - **`ctaCard/radius`**
60
+ - **`ctaCard/title/color`**
61
+ - **`ctaCard/title/fontFamily`**
62
+ - **`ctaCard/title/fontSize`**
63
+ - **`ctaCard/title/lineHeight`**
64
+
65
+ All tokens support mode-based theming through the `modes` prop.
66
+