jfs-components 0.0.44 → 0.0.45
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/AmountInput/AmountInput.js +82 -0
- package/lib/commonjs/components/AmountInput/index.js +13 -0
- package/lib/commonjs/components/Button/Button.js +31 -28
- package/lib/commonjs/components/CardProviderInfo/CardProviderInfo.js +76 -0
- package/lib/commonjs/components/EmptyState/EmptyState.js +2 -1
- package/lib/commonjs/components/OTP/OTP.js +242 -0
- package/lib/commonjs/components/PortfolioHero/PortfolioHero.js +78 -0
- package/lib/commonjs/components/ProductLabel/ProductLabel.js +50 -0
- package/lib/commonjs/components/ProgressBadge/ProgressBadge.js +130 -0
- package/lib/commonjs/components/ProgressBadge/index.js +25 -0
- package/lib/commonjs/components/StatItem/StatItem.js +61 -0
- package/lib/commonjs/components/SwappableAmount/SwappableAmount.js +71 -0
- package/lib/commonjs/components/Text/Text.js +38 -0
- package/lib/commonjs/components/Toggle/Toggle.js +102 -0
- package/lib/commonjs/components/index.js +63 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -0
- package/lib/commonjs/design-tokens/figma-variables-resolver.js +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/AmountInput/AmountInput.js +77 -0
- package/lib/module/components/AmountInput/index.js +3 -0
- package/lib/module/components/Button/Button.js +31 -28
- package/lib/module/components/CardProviderInfo/CardProviderInfo.js +71 -0
- package/lib/module/components/EmptyState/EmptyState.js +2 -1
- package/lib/module/components/OTP/OTP.js +236 -0
- package/lib/module/components/PortfolioHero/PortfolioHero.js +73 -0
- package/lib/module/components/ProductLabel/ProductLabel.js +45 -0
- package/lib/module/components/ProgressBadge/ProgressBadge.js +125 -0
- package/lib/module/components/ProgressBadge/index.js +4 -0
- package/lib/module/components/StatItem/StatItem.js +56 -0
- package/lib/module/components/SwappableAmount/SwappableAmount.js +66 -0
- package/lib/module/components/Text/Text.js +33 -0
- package/lib/module/components/Toggle/Toggle.js +97 -0
- package/lib/module/components/index.js +10 -1
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -0
- package/lib/module/design-tokens/figma-variables-resolver.js +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/AmountInput/AmountInput.d.ts +23 -0
- package/lib/typescript/src/components/AmountInput/index.d.ts +3 -0
- package/lib/typescript/src/components/CardProviderInfo/CardProviderInfo.d.ts +24 -0
- package/lib/typescript/src/components/EmptyState/EmptyState.d.ts +6 -1
- package/lib/typescript/src/components/OTP/OTP.d.ts +36 -0
- package/lib/typescript/src/components/PortfolioHero/PortfolioHero.d.ts +21 -0
- package/lib/typescript/src/components/ProductLabel/ProductLabel.d.ts +14 -0
- package/lib/typescript/src/components/ProgressBadge/ProgressBadge.d.ts +36 -0
- package/lib/typescript/src/components/ProgressBadge/index.d.ts +3 -0
- package/lib/typescript/src/components/StatItem/StatItem.d.ts +21 -0
- package/lib/typescript/src/components/SwappableAmount/SwappableAmount.d.ts +22 -0
- package/lib/typescript/src/components/Text/Text.d.ts +14 -0
- package/lib/typescript/src/components/Toggle/Toggle.d.ts +29 -0
- package/lib/typescript/src/components/index.d.ts +9 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AmountInput/AmountInput.tsx +81 -0
- package/src/components/AmountInput/index.ts +2 -0
- package/src/components/Button/Button.tsx +27 -20
- package/src/components/CardProviderInfo/CardProviderInfo.tsx +81 -0
- package/src/components/EmptyState/EmptyState.tsx +7 -1
- package/src/components/OTP/OTP.tsx +275 -0
- package/src/components/PortfolioHero/PortfolioHero.tsx +91 -0
- package/src/components/ProductLabel/ProductLabel.tsx +58 -0
- package/src/components/ProgressBadge/ProgressBadge.tsx +172 -0
- package/src/components/ProgressBadge/index.ts +2 -0
- package/src/components/StatItem/StatItem.tsx +71 -0
- package/src/components/SwappableAmount/SwappableAmount.tsx +92 -0
- package/src/components/Text/Text.tsx +48 -0
- package/src/components/Toggle/Toggle.tsx +122 -0
- package/src/components/index.ts +9 -0
- package/src/design-tokens/Coin Variables-variables-full.json +1 -0
- package/src/design-tokens/figma-variables-resolver.ts +1 -1
- package/src/icons/registry.ts +1 -1
- package/lib/commonjs/design-tokens/JFS Variables-variables-full.json +0 -1
- package/lib/module/design-tokens/JFS Variables-variables-full.json +0 -1
- package/src/design-tokens/JFS Variables-variables-full.json +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Text, type ViewStyle, type TextStyle } from 'react-native'
|
|
3
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
|
+
import Button from '../Button/Button'
|
|
5
|
+
|
|
6
|
+
export type SwappableAmountProps = {
|
|
7
|
+
/** Large display value (e.g. "49g"). */
|
|
8
|
+
value?: string
|
|
9
|
+
/** Whether to show the schedule button above the value. */
|
|
10
|
+
schedule?: boolean
|
|
11
|
+
/** Label text for the schedule button (e.g. "Weekly on Mondays"). */
|
|
12
|
+
scheduleLabel?: string
|
|
13
|
+
/** Label text for the amount/swap button (e.g. "₹5100"). */
|
|
14
|
+
amountLabel?: string
|
|
15
|
+
/** Callback when the schedule button is pressed. */
|
|
16
|
+
onSchedulePress?: () => void
|
|
17
|
+
/** Callback when the amount/swap button is pressed. */
|
|
18
|
+
onAmountPress?: () => void
|
|
19
|
+
/** Modes configuration for design token resolution. */
|
|
20
|
+
modes?: Record<string, any>
|
|
21
|
+
/** Container style override. */
|
|
22
|
+
style?: ViewStyle
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function SwappableAmount({
|
|
26
|
+
value = '49g',
|
|
27
|
+
schedule = false,
|
|
28
|
+
scheduleLabel = 'Weekly on Mondays',
|
|
29
|
+
amountLabel = '₹5100',
|
|
30
|
+
onSchedulePress,
|
|
31
|
+
onAmountPress,
|
|
32
|
+
modes = {},
|
|
33
|
+
style,
|
|
34
|
+
}: SwappableAmountProps) {
|
|
35
|
+
const gap = getVariableByName('swappableAmount/gap', modes) ?? 24
|
|
36
|
+
const padding = getVariableByName('swappableAmount/padding', modes) ?? 8
|
|
37
|
+
|
|
38
|
+
const foreground = getVariableByName('swappableAmount/foreground', modes) ?? '#0d0d0f'
|
|
39
|
+
const fontSize = getVariableByName('swappableAmount/fontSize', modes) ?? 56
|
|
40
|
+
const fontFamily = getVariableByName('swappableAmount/fontFamily', modes) ?? 'System'
|
|
41
|
+
const fontWeight = getVariableByName('swappableAmount/fontWeight', modes) ?? 900
|
|
42
|
+
const lineHeight = getVariableByName('swappableAmount/lineHeight', modes) ?? 56
|
|
43
|
+
|
|
44
|
+
const containerStyle: ViewStyle = {
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
gap: gap as number,
|
|
49
|
+
padding: padding as number,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const valueTextStyle: TextStyle = {
|
|
53
|
+
color: foreground as string,
|
|
54
|
+
fontSize: fontSize as number,
|
|
55
|
+
fontFamily: fontFamily as string,
|
|
56
|
+
fontWeight: String(fontWeight) as TextStyle['fontWeight'],
|
|
57
|
+
lineHeight: lineHeight as number,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={[containerStyle, style]}>
|
|
62
|
+
{schedule && (
|
|
63
|
+
<Button
|
|
64
|
+
label={scheduleLabel}
|
|
65
|
+
icon="ic_calendar_week"
|
|
66
|
+
onPress={onSchedulePress}
|
|
67
|
+
modes={{
|
|
68
|
+
...modes,
|
|
69
|
+
AppearanceBrand: 'Neutral',
|
|
70
|
+
Emphasis: 'Low',
|
|
71
|
+
'Button / Size': 'S',
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
|
|
76
|
+
<Text style={valueTextStyle}>{value}</Text>
|
|
77
|
+
|
|
78
|
+
<Button
|
|
79
|
+
label={amountLabel}
|
|
80
|
+
icon="ic_data_in_out"
|
|
81
|
+
onPress={onAmountPress}
|
|
82
|
+
modes={{
|
|
83
|
+
...modes,
|
|
84
|
+
Emphasis: 'Medium',
|
|
85
|
+
AppearanceBrand: 'Secondary',
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</View>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default SwappableAmount
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text as RNText, type TextStyle, type StyleProp } from 'react-native'
|
|
3
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
4
|
+
|
|
5
|
+
export type TextProps = {
|
|
6
|
+
/** The text content to display. */
|
|
7
|
+
text?: string
|
|
8
|
+
/** Modes configuration for design token resolution. */
|
|
9
|
+
modes?: Record<string, any>
|
|
10
|
+
/** Style override for the text. */
|
|
11
|
+
style?: StyleProp<TextStyle>
|
|
12
|
+
/** Number of lines to limit the text to. */
|
|
13
|
+
numberOfLines?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Text({
|
|
17
|
+
text = 'Korem ipsum ',
|
|
18
|
+
modes = {},
|
|
19
|
+
style,
|
|
20
|
+
numberOfLines,
|
|
21
|
+
}: TextProps) {
|
|
22
|
+
const foreground = getVariableByName('text/foreground', modes) ?? '#000000'
|
|
23
|
+
const fontFamily = getVariableByName('text/fontFamily', modes) ?? 'JioType'
|
|
24
|
+
const fontSize = getVariableByName('text/fontSize', modes) ?? 14
|
|
25
|
+
const fontWeight = getVariableByName('text/fontWeight', modes) ?? '500'
|
|
26
|
+
const lineHeight = getVariableByName('text/lineHeight', modes) ?? 20
|
|
27
|
+
const letterSpacing = getVariableByName('text/letterSpacing', modes) ?? -0.5
|
|
28
|
+
|
|
29
|
+
const textStyle: TextStyle = {
|
|
30
|
+
color: foreground as string,
|
|
31
|
+
fontFamily: fontFamily as string,
|
|
32
|
+
fontSize: fontSize as number,
|
|
33
|
+
fontWeight: String(fontWeight) as TextStyle['fontWeight'],
|
|
34
|
+
lineHeight: lineHeight as number,
|
|
35
|
+
letterSpacing: letterSpacing as number,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<RNText
|
|
40
|
+
style={[textStyle, style]}
|
|
41
|
+
numberOfLines={numberOfLines}
|
|
42
|
+
>
|
|
43
|
+
{text}
|
|
44
|
+
</RNText>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default Text
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Pressable,
|
|
4
|
+
View,
|
|
5
|
+
Platform,
|
|
6
|
+
type StyleProp,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from 'react-native'
|
|
9
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver'
|
|
10
|
+
|
|
11
|
+
export interface ToggleProps {
|
|
12
|
+
/** Whether the toggle is on (controlled) */
|
|
13
|
+
value?: boolean
|
|
14
|
+
/** Initial value (uncontrolled) */
|
|
15
|
+
defaultValue?: boolean
|
|
16
|
+
/** Callback when the toggle state changes */
|
|
17
|
+
onValueChange?: (value: boolean) => void
|
|
18
|
+
/** Whether the toggle is disabled */
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
/** Design token modes for theming */
|
|
21
|
+
modes?: Record<string, any>
|
|
22
|
+
/** Override container styles */
|
|
23
|
+
style?: StyleProp<ViewStyle>
|
|
24
|
+
/** Accessibility label for screen readers */
|
|
25
|
+
accessibilityLabel?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Toggle (switch) component that maps directly to the Figma design using design tokens.
|
|
30
|
+
*
|
|
31
|
+
* Supports controlled and uncontrolled usage, on/off states, and disabled state.
|
|
32
|
+
* All styling is driven by design tokens with optional mode overrides.
|
|
33
|
+
*
|
|
34
|
+
* @component
|
|
35
|
+
* @param {ToggleProps} props
|
|
36
|
+
*/
|
|
37
|
+
function Toggle({
|
|
38
|
+
value: controlledValue,
|
|
39
|
+
defaultValue = false,
|
|
40
|
+
onValueChange,
|
|
41
|
+
disabled = false,
|
|
42
|
+
modes = {},
|
|
43
|
+
style,
|
|
44
|
+
accessibilityLabel,
|
|
45
|
+
}: ToggleProps) {
|
|
46
|
+
const isControlled = controlledValue !== undefined
|
|
47
|
+
const [internalValue, setInternalValue] = useState(defaultValue)
|
|
48
|
+
const isOn = isControlled ? controlledValue : internalValue
|
|
49
|
+
|
|
50
|
+
const toggleState = disabled
|
|
51
|
+
? (isOn ? 'Disabled On' : 'Disabled Off')
|
|
52
|
+
: (isOn ? 'On' : 'Off')
|
|
53
|
+
const resolvedModes = { ...modes, 'Toggle States': toggleState }
|
|
54
|
+
|
|
55
|
+
const width = getVariableByName('toggle/width', resolvedModes) ?? 52
|
|
56
|
+
const radius = getVariableByName('toggle/radius', resolvedModes) ?? 100
|
|
57
|
+
const paddingTrack = getVariableByName('toggle/padding/track', resolvedModes) ?? 3
|
|
58
|
+
const background = getVariableByName('toggle/background', resolvedModes) ?? (isOn ? '#5d00b5' : '#c7c7cc')
|
|
59
|
+
|
|
60
|
+
const thumbSize = getVariableByName('toggle/thumb/size', resolvedModes) ?? 25
|
|
61
|
+
const thumbRadius = getVariableByName('toggle/thumb/radius', resolvedModes) ?? 100
|
|
62
|
+
const thumbBackground = getVariableByName('toggle/thumb/background', resolvedModes) ?? '#ffffff'
|
|
63
|
+
const thumbShadowColor = getVariableByName('toggle/thumb/shadow/color', resolvedModes) ?? 'rgba(0,0,0,0.18)'
|
|
64
|
+
const thumbShadowRadius = getVariableByName('toggle/thumb/shadow/radius', resolvedModes) ?? 4
|
|
65
|
+
const thumbShadowOffsetX = getVariableByName('toggle/thumb/shadow/offsetX', resolvedModes) ?? 0
|
|
66
|
+
const thumbShadowOffsetY = getVariableByName('toggle/thumb/shadow/offsetY', resolvedModes) ?? 2
|
|
67
|
+
|
|
68
|
+
const trackHeight = (thumbSize as number) + (paddingTrack as number) * 2
|
|
69
|
+
|
|
70
|
+
const handlePress = useCallback(() => {
|
|
71
|
+
if (disabled) return
|
|
72
|
+
const next = !isOn
|
|
73
|
+
if (!isControlled) {
|
|
74
|
+
setInternalValue(next)
|
|
75
|
+
}
|
|
76
|
+
onValueChange?.(next)
|
|
77
|
+
}, [disabled, isOn, isControlled, onValueChange])
|
|
78
|
+
|
|
79
|
+
const trackStyle: ViewStyle = {
|
|
80
|
+
width: width as number,
|
|
81
|
+
height: trackHeight,
|
|
82
|
+
borderRadius: radius as number,
|
|
83
|
+
backgroundColor: background as string,
|
|
84
|
+
padding: paddingTrack as number,
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
alignItems: isOn ? 'flex-end' : 'flex-start',
|
|
87
|
+
opacity: disabled ? 0.5 : 1,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const thumbShadow: ViewStyle = Platform.OS === 'web'
|
|
91
|
+
? { boxShadow: `${thumbShadowOffsetX}px ${thumbShadowOffsetY}px ${thumbShadowRadius}px 0px ${thumbShadowColor}` } as ViewStyle
|
|
92
|
+
: {
|
|
93
|
+
shadowColor: thumbShadowColor as string,
|
|
94
|
+
shadowOffset: { width: thumbShadowOffsetX as number, height: thumbShadowOffsetY as number },
|
|
95
|
+
shadowRadius: thumbShadowRadius as number,
|
|
96
|
+
shadowOpacity: 1,
|
|
97
|
+
elevation: 4,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const thumbStyle: ViewStyle = {
|
|
101
|
+
width: thumbSize as number,
|
|
102
|
+
height: thumbSize as number,
|
|
103
|
+
borderRadius: thumbRadius as number,
|
|
104
|
+
backgroundColor: thumbBackground as string,
|
|
105
|
+
...thumbShadow,
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Pressable
|
|
110
|
+
style={[trackStyle, style]}
|
|
111
|
+
onPress={handlePress}
|
|
112
|
+
disabled={disabled}
|
|
113
|
+
accessibilityRole="switch"
|
|
114
|
+
accessibilityState={{ checked: isOn, disabled }}
|
|
115
|
+
accessibilityLabel={accessibilityLabel}
|
|
116
|
+
>
|
|
117
|
+
<View style={thumbStyle} />
|
|
118
|
+
</Pressable>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default Toggle
|
package/src/components/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ export { default as Accordion, type AccordionProps } from './Accordion/Accordion
|
|
|
50
50
|
export { default as ActionTile, type ActionTileProps } from './ActionTile/ActionTile';
|
|
51
51
|
export { default as Balance, type BalanceProps } from './Balance/Balance';
|
|
52
52
|
export { default as ButtonGroup, type ButtonGroupProps } from './ButtonGroup/ButtonGroup';
|
|
53
|
+
export { default as CardProviderInfo, type CardProviderInfoProps } from './CardProviderInfo/CardProviderInfo';
|
|
53
54
|
export { default as ChipSelect, type ChipSelectProps } from './ChipSelect/ChipSelect';
|
|
54
55
|
export { default as InputSearch, type InputSearchProps } from './InputSearch/InputSearch';
|
|
55
56
|
export { default as SupportText, type SupportTextProps } from './SupportText/SupportText';
|
|
@@ -60,3 +61,11 @@ export { default as TabItem, type TabItemProps } from './Tabs/TabItem';
|
|
|
60
61
|
export { default as Toast, type ToastProps } from './Toast/Toast';
|
|
61
62
|
export { default as ToastProvider, type ToastProviderProps } from './Toast/ToastProvider';
|
|
62
63
|
export { useToast, addToast, closeToast, closeAll, type ToastOptions, type ToastEntry, type ToastPlacement } from './Toast/useToast';
|
|
64
|
+
export { default as AmountInput, type AmountInputProps } from './AmountInput/AmountInput';
|
|
65
|
+
export { default as PortfolioHero, type PortfolioHeroProps } from './PortfolioHero/PortfolioHero';
|
|
66
|
+
export { default as ProductLabel, type ProductLabelProps } from './ProductLabel/ProductLabel';
|
|
67
|
+
export { default as SwappableAmount, type SwappableAmountProps } from './SwappableAmount/SwappableAmount';
|
|
68
|
+
export { default as OTP, type OTPProps } from './OTP/OTP';
|
|
69
|
+
export { default as StatItem, type StatItemProps } from './StatItem/StatItem';
|
|
70
|
+
export { default as Text, type TextProps } from './Text/Text';
|
|
71
|
+
export { default as Toggle, type ToggleProps } from './Toggle/Toggle';
|