cpk-ui 0.5.5 → 0.7.0
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/README.md +80 -147
- package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/components/modals/AlertDialog/AlertDialog.js +14 -7
- package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
- package/components/modals/Snackbar/Snackbar.js +20 -17
- package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
- package/components/uis/Accordion/AccordionItem.js +41 -17
- package/components/uis/Button/Button.d.ts.map +1 -1
- package/components/uis/Button/Button.js +10 -10
- package/components/uis/Card/Card.d.ts +2 -1
- package/components/uis/Card/Card.d.ts.map +1 -1
- package/components/uis/Card/Card.js +12 -3
- package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
- package/components/uis/Checkbox/Checkbox.js +1 -1
- package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
- package/components/uis/CustomPressable/CustomPressable.js +6 -6
- package/components/uis/EditText/EditText.d.ts.map +1 -1
- package/components/uis/EditText/EditText.js +17 -12
- package/components/uis/Fab/Fab.d.ts +2 -2
- package/components/uis/Fab/Fab.d.ts.map +1 -1
- package/components/uis/Fab/Fab.js +22 -4
- package/components/uis/Icon/Icon.d.ts.map +1 -1
- package/components/uis/Icon/Icon.js +6 -3
- package/components/uis/IconButton/IconButton.d.ts.map +1 -1
- package/components/uis/IconButton/IconButton.js +43 -41
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +2 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.js +4 -4
- package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioButton.js +1 -1
- package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioGroup.js +16 -3
- package/components/uis/Rating/Rating.d.ts.map +1 -1
- package/components/uis/Rating/Rating.js +23 -19
- package/components/uis/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/components/uis/SegmentedControl/SegmentedControl.js +1 -1
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
- package/components/uis/StatusbarBrightness/StatusBarBrightness.js +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.js +1 -1
- package/hooks/useHoverState.d.ts +8 -0
- package/hooks/useHoverState.d.ts.map +1 -0
- package/hooks/useHoverState.js +16 -0
- package/package.json +18 -6
- package/providers/ThemeProvider.d.ts.map +1 -1
- package/providers/ThemeProvider.js +0 -1
- package/providers/index.d.ts.map +1 -1
- package/providers/index.js +3 -2
- package/components/uis/Icon/selection.json +0 -1
- package/src/components/common/ErrorBoundary/ErrorBoundary.tsx +0 -75
- package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +0 -216
- package/src/components/modals/AlertDialog/AlertDialog.test.tsx +0 -251
- package/src/components/modals/AlertDialog/AlertDialog.tsx +0 -356
- package/src/components/modals/Snackbar/Snackbar.stories.tsx +0 -182
- package/src/components/modals/Snackbar/Snackbar.test.tsx +0 -319
- package/src/components/modals/Snackbar/Snackbar.tsx +0 -260
- package/src/components/modals/Snackbar/const.ts +0 -4
- package/src/components/uis/Accordion/Accordion.stories.tsx +0 -167
- package/src/components/uis/Accordion/Accordion.test.tsx +0 -272
- package/src/components/uis/Accordion/Accordion.tsx +0 -109
- package/src/components/uis/Accordion/AccordionItem.tsx +0 -306
- package/src/components/uis/Button/Button.stories.tsx +0 -218
- package/src/components/uis/Button/Button.test.tsx +0 -694
- package/src/components/uis/Button/Button.tsx +0 -440
- package/src/components/uis/Card/Card.test.tsx +0 -146
- package/src/components/uis/Card/Card.tsx +0 -102
- package/src/components/uis/Checkbox/Checkbox.stories.tsx +0 -216
- package/src/components/uis/Checkbox/Checkbox.test.tsx +0 -267
- package/src/components/uis/Checkbox/Checkbox.tsx +0 -225
- package/src/components/uis/CustomPressable/CustomPressable.tsx +0 -48
- package/src/components/uis/EditText/EditText.stories.tsx +0 -124
- package/src/components/uis/EditText/EditText.test.tsx +0 -477
- package/src/components/uis/EditText/EditText.tsx +0 -593
- package/src/components/uis/Fab/Fab.stories.tsx +0 -133
- package/src/components/uis/Fab/Fab.test.tsx +0 -110
- package/src/components/uis/Fab/Fab.tsx +0 -168
- package/src/components/uis/Hr/Hr.test.tsx +0 -26
- package/src/components/uis/Hr/Hr.tsx +0 -19
- package/src/components/uis/Icon/Icon.stories.tsx +0 -98
- package/src/components/uis/Icon/Icon.test.tsx +0 -49
- package/src/components/uis/Icon/Icon.tsx +0 -3819
- package/src/components/uis/IconButton/IconButton.test.tsx +0 -204
- package/src/components/uis/IconButton/IconButton.tsx +0 -279
- package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +0 -126
- package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +0 -81
- package/src/components/uis/PinchZoom/PinchZoom.stories.tsx +0 -266
- package/src/components/uis/PinchZoom/PinchZoom.test.tsx +0 -113
- package/src/components/uis/PinchZoom/PinchZoom.tsx +0 -424
- package/src/components/uis/RadioGroup/RadioButton.tsx +0 -193
- package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
- package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -354
- package/src/components/uis/RadioGroup/RadioGroup.tsx +0 -109
- package/src/components/uis/Rating/Rating.test.tsx +0 -98
- package/src/components/uis/Rating/Rating.tsx +0 -200
- package/src/components/uis/SegmentedControl/SegmentedControl.stories.tsx +0 -546
- package/src/components/uis/SegmentedControl/SegmentedControl.test.tsx +0 -274
- package/src/components/uis/SegmentedControl/SegmentedControl.tsx +0 -232
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +0 -41
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +0 -26
- package/src/components/uis/Styled/StyledComponents.tsx +0 -217
- package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +0 -75
- package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +0 -149
- package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -309
- package/src/components/uis/Typography/Typography.stories.tsx +0 -149
- package/src/components/uis/Typography/Typography.test.tsx +0 -58
- package/src/components/uis/Typography/Typography.tsx +0 -386
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useAnimations.ts +0 -71
- package/src/hooks/useDebouncedColorScheme.tsx +0 -30
- package/src/hooks/useOptimizedStyles.ts +0 -22
- package/src/hooks/usePerformance.ts +0 -93
- package/src/index.tsx +0 -38
- package/src/providers/ThemeProvider.tsx +0 -177
- package/src/providers/index.tsx +0 -130
- package/src/test/testUtils.tsx +0 -101
- package/src/types/common.ts +0 -77
- package/src/types/index.ts +0 -1
- package/src/types/kstyled.d.ts +0 -6
- package/src/utils/accessibility.ts +0 -110
- package/src/utils/colors.ts +0 -151
- package/src/utils/createCtx.tsx +0 -26
- package/src/utils/guards.ts +0 -93
- package/src/utils/index.ts +0 -2
- package/src/utils/performanceTest.ts +0 -174
- package/src/utils/platform.ts +0 -69
- package/src/utils/theme.ts +0 -38
- package/test/testUtils.d.ts +0 -113
- package/test/testUtils.d.ts.map +0 -1
- package/test/testUtils.js +0 -65
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import React, {useCallback, useEffect, useMemo, useState, type ReactElement} from 'react';
|
|
2
|
-
import type {StyleProp, ViewStyle} from 'react-native';
|
|
3
|
-
import {Animated, TouchableOpacity, View} from 'react-native';
|
|
4
|
-
import {styled} from 'kstyled';
|
|
5
|
-
import {useTheme} from '../../../providers/ThemeProvider';
|
|
6
|
-
|
|
7
|
-
// Metro cache workaround: Using explicit pattern until cache is cleared
|
|
8
|
-
const AnimatedView = Animated.createAnimatedComponent(View);
|
|
9
|
-
|
|
10
|
-
type Styles = {
|
|
11
|
-
container?: ViewStyle;
|
|
12
|
-
onElementContainer?: StyleProp<ViewStyle>;
|
|
13
|
-
offElementContainer?: StyleProp<ViewStyle>;
|
|
14
|
-
circle?: ViewStyle;
|
|
15
|
-
button?: StyleProp<ViewStyle>;
|
|
16
|
-
circleColorOff?: string;
|
|
17
|
-
circleColorOn?: string;
|
|
18
|
-
backgroundColorOn?: string;
|
|
19
|
-
backgroundColorOff?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type SwitchToggleSizeType = 'small' | 'medium' | 'large' | number;
|
|
23
|
-
|
|
24
|
-
type Props = {
|
|
25
|
-
testID?: string;
|
|
26
|
-
size?: SwitchToggleSizeType;
|
|
27
|
-
isOn: boolean;
|
|
28
|
-
style?: StyleProp<ViewStyle>;
|
|
29
|
-
styles?: Styles;
|
|
30
|
-
duration?: number;
|
|
31
|
-
onElement?: any;
|
|
32
|
-
offElement?: any;
|
|
33
|
-
onPress?: () => void;
|
|
34
|
-
accessibilityLabel?: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Using AnimatedView created above - functionally identical to styled(Animated.View)
|
|
38
|
-
const AnimatedContainer = styled(AnimatedView)`
|
|
39
|
-
flex-direction: row;
|
|
40
|
-
align-items: center;
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
const smallContainer: ViewStyle = {
|
|
44
|
-
width: 40,
|
|
45
|
-
height: 24,
|
|
46
|
-
borderRadius: 25,
|
|
47
|
-
padding: 5,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const smallCircle: ViewStyle = {
|
|
51
|
-
width: 16,
|
|
52
|
-
height: 16,
|
|
53
|
-
borderRadius: 8,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const mediumContainer: ViewStyle = {
|
|
57
|
-
width: 56,
|
|
58
|
-
height: 30,
|
|
59
|
-
borderRadius: 25,
|
|
60
|
-
padding: 5,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const mediumCircle: ViewStyle = {
|
|
64
|
-
width: 20,
|
|
65
|
-
height: 20,
|
|
66
|
-
borderRadius: 10,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const largeContainer: ViewStyle = {
|
|
70
|
-
width: 80,
|
|
71
|
-
height: 40,
|
|
72
|
-
borderRadius: 25,
|
|
73
|
-
padding: 5,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const largeCircle: ViewStyle = {
|
|
77
|
-
width: 32,
|
|
78
|
-
height: 32,
|
|
79
|
-
borderRadius: 16,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export function SwitchToggle({
|
|
83
|
-
testID,
|
|
84
|
-
isOn,
|
|
85
|
-
style,
|
|
86
|
-
styles,
|
|
87
|
-
duration = 300,
|
|
88
|
-
onElement,
|
|
89
|
-
size = 'medium',
|
|
90
|
-
offElement,
|
|
91
|
-
onPress,
|
|
92
|
-
accessibilityLabel,
|
|
93
|
-
}: Props): ReactElement {
|
|
94
|
-
const {theme} = useTheme();
|
|
95
|
-
|
|
96
|
-
// Memoize size-based configurations
|
|
97
|
-
const sizeConfig = useMemo(() => {
|
|
98
|
-
if (typeof size === 'number') {
|
|
99
|
-
const containerConfig: ViewStyle = {
|
|
100
|
-
width: size * 1.87,
|
|
101
|
-
height: size,
|
|
102
|
-
borderRadius: size / 2,
|
|
103
|
-
padding: size * 0.17,
|
|
104
|
-
};
|
|
105
|
-
const circleConfig: ViewStyle = {
|
|
106
|
-
width: size * 0.67,
|
|
107
|
-
height: size * 0.67,
|
|
108
|
-
borderRadius: size / 3,
|
|
109
|
-
};
|
|
110
|
-
return {containerConfig, circleConfig};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const containerConfig =
|
|
114
|
-
size === 'large'
|
|
115
|
-
? largeContainer
|
|
116
|
-
: size === 'small'
|
|
117
|
-
? smallContainer
|
|
118
|
-
: mediumContainer;
|
|
119
|
-
|
|
120
|
-
const circleConfig =
|
|
121
|
-
size === 'large'
|
|
122
|
-
? largeCircle
|
|
123
|
-
: size === 'small'
|
|
124
|
-
? smallCircle
|
|
125
|
-
: mediumCircle;
|
|
126
|
-
|
|
127
|
-
return {containerConfig, circleConfig};
|
|
128
|
-
}, [size]);
|
|
129
|
-
|
|
130
|
-
// Memoize styles with defaults
|
|
131
|
-
const switchStyles = useMemo(() => {
|
|
132
|
-
const {
|
|
133
|
-
backgroundColorOn = theme.role.primary,
|
|
134
|
-
backgroundColorOff = theme.bg.disabled,
|
|
135
|
-
circleColorOn = theme.text.contrast,
|
|
136
|
-
circleColorOff = theme.text.basic,
|
|
137
|
-
container = sizeConfig.containerConfig,
|
|
138
|
-
circle = sizeConfig.circleConfig,
|
|
139
|
-
button,
|
|
140
|
-
onElementContainer,
|
|
141
|
-
offElementContainer,
|
|
142
|
-
} = styles ?? {};
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
backgroundColorOn,
|
|
146
|
-
backgroundColorOff,
|
|
147
|
-
circleColorOn,
|
|
148
|
-
circleColorOff,
|
|
149
|
-
container,
|
|
150
|
-
circle,
|
|
151
|
-
button,
|
|
152
|
-
onElementContainer,
|
|
153
|
-
offElementContainer,
|
|
154
|
-
};
|
|
155
|
-
}, [styles, theme, sizeConfig]);
|
|
156
|
-
|
|
157
|
-
// Memoize padding calculations
|
|
158
|
-
const padding = useMemo(() => {
|
|
159
|
-
const paddingLeft =
|
|
160
|
-
(switchStyles.container.padding as number) ||
|
|
161
|
-
(switchStyles.container.paddingLeft as number) ||
|
|
162
|
-
0;
|
|
163
|
-
const paddingRight =
|
|
164
|
-
(switchStyles.container.padding as number) ||
|
|
165
|
-
(switchStyles.container.paddingRight as number) ||
|
|
166
|
-
0;
|
|
167
|
-
return {paddingLeft, paddingRight};
|
|
168
|
-
}, [switchStyles.container]);
|
|
169
|
-
|
|
170
|
-
// Memoize position calculations
|
|
171
|
-
const positions = useMemo(() => {
|
|
172
|
-
const circlePosXStart = 0;
|
|
173
|
-
const circlePosXEnd =
|
|
174
|
-
((switchStyles.container.width ?? mediumContainer.width) as number) -
|
|
175
|
-
((switchStyles.circle.width ?? mediumCircle.width) as number) -
|
|
176
|
-
(padding.paddingRight + padding.paddingLeft);
|
|
177
|
-
|
|
178
|
-
return {circlePosXStart, circlePosXEnd};
|
|
179
|
-
}, [
|
|
180
|
-
switchStyles.container.width,
|
|
181
|
-
switchStyles.circle.width,
|
|
182
|
-
padding,
|
|
183
|
-
mediumContainer,
|
|
184
|
-
smallContainer,
|
|
185
|
-
largeContainer,
|
|
186
|
-
]);
|
|
187
|
-
|
|
188
|
-
const [animXValue] = useState(new Animated.Value(isOn ? 1 : 0));
|
|
189
|
-
|
|
190
|
-
// Memoize animation function
|
|
191
|
-
const runAnimation = useCallback(() => {
|
|
192
|
-
const option = {
|
|
193
|
-
fromValue: isOn ? 0 : 1,
|
|
194
|
-
toValue: isOn ? 1 : 0,
|
|
195
|
-
duration,
|
|
196
|
-
useNativeDriver: false,
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
Animated.timing(animXValue, option).start();
|
|
200
|
-
}, [animXValue, isOn, duration]);
|
|
201
|
-
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
runAnimation();
|
|
204
|
-
}, [runAnimation]);
|
|
205
|
-
|
|
206
|
-
// Memoize animated components
|
|
207
|
-
const CircleButton = useMemo(
|
|
208
|
-
() => (
|
|
209
|
-
<Animated.View
|
|
210
|
-
style={[
|
|
211
|
-
switchStyles.circle,
|
|
212
|
-
{
|
|
213
|
-
backgroundColor: animXValue.interpolate({
|
|
214
|
-
inputRange: [0.5, 1],
|
|
215
|
-
outputRange: [
|
|
216
|
-
switchStyles.circleColorOff as string | number,
|
|
217
|
-
switchStyles.circleColorOn as string | number,
|
|
218
|
-
] as string[] | number[],
|
|
219
|
-
}),
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
transform: [
|
|
223
|
-
{
|
|
224
|
-
translateX: animXValue.interpolate({
|
|
225
|
-
inputRange: [0, 1],
|
|
226
|
-
outputRange: [
|
|
227
|
-
positions.circlePosXStart as string | number,
|
|
228
|
-
positions.circlePosXEnd as string | number,
|
|
229
|
-
] as string[] | number[],
|
|
230
|
-
}),
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
},
|
|
234
|
-
switchStyles.button,
|
|
235
|
-
]}
|
|
236
|
-
/>
|
|
237
|
-
),
|
|
238
|
-
[switchStyles, animXValue, positions]
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
const OnElement = useMemo(
|
|
242
|
-
() => (
|
|
243
|
-
<Animated.View style={[{opacity: animXValue}, switchStyles.onElementContainer]}>
|
|
244
|
-
{onElement}
|
|
245
|
-
</Animated.View>
|
|
246
|
-
),
|
|
247
|
-
[animXValue, switchStyles.onElementContainer, onElement]
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
const OffElement = useMemo(
|
|
251
|
-
() => (
|
|
252
|
-
<Animated.View
|
|
253
|
-
style={[
|
|
254
|
-
{
|
|
255
|
-
opacity: animXValue.interpolate({
|
|
256
|
-
inputRange: [0, 1],
|
|
257
|
-
outputRange: [1, 0],
|
|
258
|
-
}),
|
|
259
|
-
},
|
|
260
|
-
switchStyles.offElementContainer,
|
|
261
|
-
]}
|
|
262
|
-
>
|
|
263
|
-
{offElement}
|
|
264
|
-
</Animated.View>
|
|
265
|
-
),
|
|
266
|
-
[animXValue, switchStyles.offElementContainer, offElement]
|
|
267
|
-
);
|
|
268
|
-
|
|
269
|
-
// Memoize container styles
|
|
270
|
-
const containerStyles = useMemo(
|
|
271
|
-
() => [
|
|
272
|
-
switchStyles.container,
|
|
273
|
-
{
|
|
274
|
-
paddingLeft: padding.paddingLeft,
|
|
275
|
-
paddingRight: padding.paddingRight,
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
backgroundColor: animXValue.interpolate({
|
|
279
|
-
inputRange: [0, 1],
|
|
280
|
-
outputRange: [
|
|
281
|
-
switchStyles.backgroundColorOff as string | number,
|
|
282
|
-
switchStyles.backgroundColorOn as string | number,
|
|
283
|
-
] as string[] | number[],
|
|
284
|
-
}),
|
|
285
|
-
},
|
|
286
|
-
],
|
|
287
|
-
[switchStyles, padding, animXValue]
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<TouchableOpacity
|
|
292
|
-
accessibilityLabel={accessibilityLabel}
|
|
293
|
-
accessibilityRole="switch"
|
|
294
|
-
accessibilityState={{checked: isOn}}
|
|
295
|
-
activeOpacity={0.8}
|
|
296
|
-
onPress={onPress}
|
|
297
|
-
style={style}
|
|
298
|
-
testID={testID}
|
|
299
|
-
>
|
|
300
|
-
<AnimatedContainer style={containerStyles}>
|
|
301
|
-
{isOn ? OnElement : OffElement}
|
|
302
|
-
{CircleButton}
|
|
303
|
-
</AnimatedContainer>
|
|
304
|
-
</TouchableOpacity>
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Export memoized component for better performance
|
|
309
|
-
export default React.memo(SwitchToggle) as typeof SwitchToggle;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type {Meta, StoryObj} from '@storybook/react';
|
|
2
|
-
import {Typography} from './Typography';
|
|
3
|
-
import {withThemeProvider} from '../../../../.storybook/decorators';
|
|
4
|
-
import {ScrollView, View} from 'react-native';
|
|
5
|
-
import {ThemeParam} from '../../../utils/theme';
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: 'Typography',
|
|
9
|
-
component: Typography.Title,
|
|
10
|
-
parameters: {
|
|
11
|
-
notes: `
|
|
12
|
-
A comprehensive typography system with predefined text styles for consistent design.
|
|
13
|
-
|
|
14
|
-
## Features
|
|
15
|
-
- **Pre-defined Text Styles**: Multiple typography variants for different use cases
|
|
16
|
-
- **Theme Integration**: Automatically uses theme colors and styles
|
|
17
|
-
- **Responsive**: Works across all platforms (iOS, Android, Web)
|
|
18
|
-
- **Customizable**: Can override styles while maintaining base typography
|
|
19
|
-
|
|
20
|
-
## Available Typography Variants
|
|
21
|
-
- **Title**: Large heading text
|
|
22
|
-
- **Heading1**: Primary heading
|
|
23
|
-
- **Heading2**: Secondary heading
|
|
24
|
-
- **Heading3**: Tertiary heading
|
|
25
|
-
- **Subtitle1**: Large subtitle
|
|
26
|
-
- **Subtitle2**: Standard subtitle
|
|
27
|
-
- **Body1**: Primary body text
|
|
28
|
-
- **Body2**: Secondary body text
|
|
29
|
-
- **Body3**: Tertiary body text
|
|
30
|
-
- **Body4**: Small body text
|
|
31
|
-
- **Caption**: Small caption text
|
|
32
|
-
- **Button**: Button text style
|
|
33
|
-
|
|
34
|
-
## Usage
|
|
35
|
-
\`\`\`tsx
|
|
36
|
-
<Typography.Title>Page Title</Typography.Title>
|
|
37
|
-
<Typography.Heading1>Main Heading</Typography.Heading1>
|
|
38
|
-
<Typography.Body1>This is body text.</Typography.Body1>
|
|
39
|
-
<Typography.Caption>Small caption text</Typography.Caption>
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
### With Custom Styling
|
|
43
|
-
\`\`\`tsx
|
|
44
|
-
<Typography.Body1 style={{color: 'blue', fontWeight: 'bold'}}>
|
|
45
|
-
Custom styled text
|
|
46
|
-
</Typography.Body1>
|
|
47
|
-
\`\`\`
|
|
48
|
-
`,
|
|
49
|
-
docs: {
|
|
50
|
-
description: {
|
|
51
|
-
component: `
|
|
52
|
-
A comprehensive typography system with predefined text styles for consistent design.
|
|
53
|
-
|
|
54
|
-
## Features
|
|
55
|
-
- **Pre-defined Text Styles**: Multiple typography variants for different use cases
|
|
56
|
-
- **Theme Integration**: Automatically uses theme colors and styles
|
|
57
|
-
- **Responsive**: Works across all platforms (iOS, Android, Web)
|
|
58
|
-
- **Customizable**: Can override styles while maintaining base typography
|
|
59
|
-
|
|
60
|
-
## Available Typography Variants
|
|
61
|
-
- **Title**: Large heading text
|
|
62
|
-
- **Heading1**: Primary heading
|
|
63
|
-
- **Heading2**: Secondary heading
|
|
64
|
-
- **Heading3**: Tertiary heading
|
|
65
|
-
- **Subtitle1**: Large subtitle
|
|
66
|
-
- **Subtitle2**: Standard subtitle
|
|
67
|
-
- **Body1**: Primary body text
|
|
68
|
-
- **Body2**: Secondary body text
|
|
69
|
-
- **Body3**: Tertiary body text
|
|
70
|
-
- **Body4**: Small body text
|
|
71
|
-
- **Caption**: Small caption text
|
|
72
|
-
- **Button**: Button text style
|
|
73
|
-
|
|
74
|
-
## Usage
|
|
75
|
-
\`\`\`tsx
|
|
76
|
-
<Typography.Title>Page Title</Typography.Title>
|
|
77
|
-
<Typography.Heading1>Main Heading</Typography.Heading1>
|
|
78
|
-
<Typography.Body1>This is body text.</Typography.Body1>
|
|
79
|
-
<Typography.Caption>Small caption text</Typography.Caption>
|
|
80
|
-
\`\`\`
|
|
81
|
-
|
|
82
|
-
### With Custom Styling
|
|
83
|
-
\`\`\`tsx
|
|
84
|
-
<Typography.Body1 style={{color: 'blue', fontWeight: 'bold'}}>
|
|
85
|
-
Custom styled text
|
|
86
|
-
</Typography.Body1>
|
|
87
|
-
\`\`\`
|
|
88
|
-
`,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
argTypes: {},
|
|
93
|
-
decorators: [withThemeProvider],
|
|
94
|
-
} satisfies Meta<typeof Typography.Title>;
|
|
95
|
-
|
|
96
|
-
export default meta;
|
|
97
|
-
|
|
98
|
-
type Story = StoryObj<typeof meta>;
|
|
99
|
-
|
|
100
|
-
export const AllTypography: Story = {
|
|
101
|
-
render: (args) => (
|
|
102
|
-
<ScrollView contentContainerStyle={{padding: 16}}>
|
|
103
|
-
{Object.entries(Typography).map(([key, Component]) => (
|
|
104
|
-
<View key={key} style={{marginBottom: 16}}>
|
|
105
|
-
<Component {...args}>
|
|
106
|
-
{key} {args.children}
|
|
107
|
-
</Component>
|
|
108
|
-
</View>
|
|
109
|
-
))}
|
|
110
|
-
</ScrollView>
|
|
111
|
-
),
|
|
112
|
-
args: {
|
|
113
|
-
children: 'Hello world',
|
|
114
|
-
},
|
|
115
|
-
argTypes: {
|
|
116
|
-
theme: {
|
|
117
|
-
control: 'select',
|
|
118
|
-
options: ['light', 'dark'],
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const CustomTitle: Story = {
|
|
124
|
-
args: {
|
|
125
|
-
children: 'Custom Color',
|
|
126
|
-
// @ts-ignore
|
|
127
|
-
theme: {
|
|
128
|
-
light: {
|
|
129
|
-
text: {
|
|
130
|
-
basic: 'blue',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
dark: {
|
|
134
|
-
text: {
|
|
135
|
-
basic: 'skyblue',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
} as ThemeParam,
|
|
139
|
-
},
|
|
140
|
-
decorators: [
|
|
141
|
-
(Story, context) =>
|
|
142
|
-
withThemeProvider(
|
|
143
|
-
Story,
|
|
144
|
-
context,
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
context.args.theme as ThemeParam,
|
|
147
|
-
),
|
|
148
|
-
],
|
|
149
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React, {type ReactElement} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import type {RenderAPI} from '@testing-library/react-native';
|
|
4
|
-
import {render} from '@testing-library/react-native';
|
|
5
|
-
|
|
6
|
-
import {createComponent} from '../../../../test/testUtils';
|
|
7
|
-
import {Typography, TypographyInverted} from './Typography';
|
|
8
|
-
import {ThemeProvider} from '../../../providers/ThemeProvider';
|
|
9
|
-
|
|
10
|
-
let testingLib: RenderAPI;
|
|
11
|
-
|
|
12
|
-
const Component = (): ReactElement =>
|
|
13
|
-
createComponent(
|
|
14
|
-
<View>
|
|
15
|
-
<Typography.Title />,
|
|
16
|
-
<Typography.Heading1 />,
|
|
17
|
-
<Typography.Heading2 />,
|
|
18
|
-
<Typography.Heading3 />,
|
|
19
|
-
<Typography.Body1 />,
|
|
20
|
-
<Typography.Body2 />,
|
|
21
|
-
<TypographyInverted.Title />
|
|
22
|
-
<TypographyInverted.Heading1 />
|
|
23
|
-
<TypographyInverted.Heading2 />
|
|
24
|
-
<TypographyInverted.Heading3 />
|
|
25
|
-
<TypographyInverted.Body1 />
|
|
26
|
-
<TypographyInverted.Body2 />
|
|
27
|
-
</View>,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
describe('[Typography]', () => {
|
|
31
|
-
it('should render without crashing', () => {
|
|
32
|
-
testingLib = render(<Component />);
|
|
33
|
-
|
|
34
|
-
const json = testingLib.toJSON();
|
|
35
|
-
|
|
36
|
-
expect(json).toBeTruthy();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should render default theme', () => {
|
|
40
|
-
testingLib = render(Component());
|
|
41
|
-
|
|
42
|
-
const json = testingLib.toJSON();
|
|
43
|
-
|
|
44
|
-
expect(json).toBeTruthy();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should render [dark] mode', () => {
|
|
48
|
-
testingLib = render(
|
|
49
|
-
<ThemeProvider initialThemeType="dark">
|
|
50
|
-
<Component />
|
|
51
|
-
</ThemeProvider>,
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const json = testingLib.toJSON();
|
|
55
|
-
|
|
56
|
-
expect(json).toBeTruthy();
|
|
57
|
-
});
|
|
58
|
-
});
|