cpk-ui 0.5.4 → 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 +2 -1
- package/components/uis/Button/Button.d.ts.map +1 -1
- package/components/uis/Button/Button.js +11 -11
- 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 +2 -1
- package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
- package/components/uis/Checkbox/Checkbox.js +2 -2
- 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 +1 -0
- package/components/uis/EditText/EditText.d.ts.map +1 -1
- package/components/uis/EditText/EditText.js +18 -13
- 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 +2 -1
- package/components/uis/IconButton/IconButton.d.ts.map +1 -1
- package/components/uis/IconButton/IconButton.js +44 -42
- 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 +2 -1
- package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioButton.js +2 -2
- 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 +2 -1
- package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.js +2 -2
- 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 -620
- package/src/components/uis/Button/Button.tsx +0 -436
- 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 -173
- package/src/components/uis/Checkbox/Checkbox.tsx +0 -220
- 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 -590
- 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 -165
- package/src/components/uis/IconButton/IconButton.tsx +0 -275
- 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 -188
- package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +0 -188
- package/src/components/uis/RadioGroup/RadioGroup.test.tsx +0 -287
- 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 -229
- 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 -105
- package/src/components/uis/SwitchToggle/SwitchToggle.tsx +0 -305
- 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,110 +0,0 @@
|
|
|
1
|
-
import React, {type ReactElement} from 'react';
|
|
2
|
-
import {fireEvent, render} from '@testing-library/react-native';
|
|
3
|
-
|
|
4
|
-
import {createComponent} from '../../../../test/testUtils';
|
|
5
|
-
import type {IconName} from '../../..';
|
|
6
|
-
import {Fab} from './Fab';
|
|
7
|
-
|
|
8
|
-
const Component = (props): ReactElement => createComponent(<Fab {...props} />);
|
|
9
|
-
|
|
10
|
-
describe('[Fab]', () => {
|
|
11
|
-
it('should render', async () => {
|
|
12
|
-
let count = 0;
|
|
13
|
-
let items: IconName[] = ['AndroidLogo', 'AppleLogo'];
|
|
14
|
-
// let resItem: FabItem;
|
|
15
|
-
|
|
16
|
-
const {getByTestId} = render(
|
|
17
|
-
Component({
|
|
18
|
-
icons: items,
|
|
19
|
-
isActive: true,
|
|
20
|
-
onPressItem: () => {
|
|
21
|
-
count += 1;
|
|
22
|
-
// resItem = fab;
|
|
23
|
-
},
|
|
24
|
-
onPressFab: () => {},
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(count).toBe(0);
|
|
29
|
-
fireEvent.press(getByTestId('AndroidLogo'));
|
|
30
|
-
expect(count).toBe(1);
|
|
31
|
-
// expect(resItem.id).toBe(item.id);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should render custom Fab', async () => {
|
|
35
|
-
const testingLib = render(
|
|
36
|
-
Component({
|
|
37
|
-
icons: ['AppleLogo', 'AndroidLogo'],
|
|
38
|
-
isActive: true,
|
|
39
|
-
onPressItem: () => {},
|
|
40
|
-
onPressFab: () => {},
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const json = testingLib.toJSON();
|
|
45
|
-
|
|
46
|
-
expect(json).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('sizes', () => {
|
|
50
|
-
it('should render with small size', async () => {
|
|
51
|
-
const testingLib = render(
|
|
52
|
-
Component({
|
|
53
|
-
icons: ['AppleLogo', 'AndroidLogo'],
|
|
54
|
-
size: 'small',
|
|
55
|
-
isActive: true,
|
|
56
|
-
onPressItem: () => {},
|
|
57
|
-
onPressFab: () => {},
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const json = testingLib.toJSON();
|
|
62
|
-
expect(json).toBeTruthy();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should render with medium size', async () => {
|
|
66
|
-
const testingLib = render(
|
|
67
|
-
Component({
|
|
68
|
-
icons: ['AppleLogo', 'AndroidLogo'],
|
|
69
|
-
size: 'medium',
|
|
70
|
-
isActive: true,
|
|
71
|
-
onPressItem: () => {},
|
|
72
|
-
onPressFab: () => {},
|
|
73
|
-
}),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const json = testingLib.toJSON();
|
|
77
|
-
expect(json).toBeTruthy();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should render with large size', async () => {
|
|
81
|
-
const testingLib = render(
|
|
82
|
-
Component({
|
|
83
|
-
icons: ['AppleLogo', 'AndroidLogo'],
|
|
84
|
-
size: 'large',
|
|
85
|
-
isActive: true,
|
|
86
|
-
onPressItem: () => {},
|
|
87
|
-
onPressFab: () => {},
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const json = testingLib.toJSON();
|
|
92
|
-
expect(json).toBeTruthy();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should render with custom numeric size', async () => {
|
|
96
|
-
const testingLib = render(
|
|
97
|
-
Component({
|
|
98
|
-
icons: ['AppleLogo', 'AndroidLogo'],
|
|
99
|
-
size: 64,
|
|
100
|
-
isActive: true,
|
|
101
|
-
onPressItem: () => {},
|
|
102
|
-
onPressFab: () => {},
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const json = testingLib.toJSON();
|
|
107
|
-
expect(json).toBeTruthy();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import React, {useLayoutEffect, useMemo, useRef, useCallback, type ReactElement} from 'react';
|
|
2
|
-
import type {LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
|
|
3
|
-
import {Animated, Easing, Platform, View} from 'react-native';
|
|
4
|
-
import {IconName} from '../Icon/Icon';
|
|
5
|
-
import {ButtonSizeType} from '../Button/Button';
|
|
6
|
-
import {IconButton} from '../IconButton/IconButton';
|
|
7
|
-
import {useOptimizedStyles} from '../../../hooks/useOptimizedStyles';
|
|
8
|
-
import {safePlatformSelect} from '../../../utils/platform';
|
|
9
|
-
import {getButtonAccessibilityProps} from '../../../utils/accessibility';
|
|
10
|
-
|
|
11
|
-
type Styles = {
|
|
12
|
-
Fab?: StyleProp<ViewStyle>;
|
|
13
|
-
FabItem?: StyleProp<ViewStyle>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type FabProps = {
|
|
17
|
-
isActive?: boolean;
|
|
18
|
-
icons?: IconName[];
|
|
19
|
-
animationDuration?: number;
|
|
20
|
-
onPressFab: () => void;
|
|
21
|
-
onPressItem?: (item?: IconName) => void;
|
|
22
|
-
buttonSize?: ButtonSizeType | number;
|
|
23
|
-
fabIcon?: IconName;
|
|
24
|
-
gap?: number;
|
|
25
|
-
style?: StyleProp<ViewStyle>;
|
|
26
|
-
styles?: Styles;
|
|
27
|
-
iconButtonProps?: Omit<
|
|
28
|
-
React.ComponentProps<typeof IconButton>,
|
|
29
|
-
'icon' | 'onPress' | 'size'
|
|
30
|
-
>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function FloatingActionButtons({
|
|
34
|
-
isActive = false,
|
|
35
|
-
style,
|
|
36
|
-
styles,
|
|
37
|
-
fabIcon = 'Plus',
|
|
38
|
-
icons = [],
|
|
39
|
-
onPressFab,
|
|
40
|
-
onPressItem,
|
|
41
|
-
buttonSize = 'medium',
|
|
42
|
-
gap = Platform.select({
|
|
43
|
-
web: 60,
|
|
44
|
-
default: 12,
|
|
45
|
-
}) || 12,
|
|
46
|
-
animationDuration = 200,
|
|
47
|
-
iconButtonProps,
|
|
48
|
-
}: FabProps): ReactElement {
|
|
49
|
-
const {Fab, FabItem} = styles ?? {};
|
|
50
|
-
|
|
51
|
-
const spinValue = useRef(new Animated.Value(0));
|
|
52
|
-
const positionValue = useRef(new Animated.Value(0));
|
|
53
|
-
const fabHeight = useRef(0);
|
|
54
|
-
|
|
55
|
-
// Memoize animation configuration
|
|
56
|
-
const animationConfig = useMemo(() => ({
|
|
57
|
-
duration: animationDuration,
|
|
58
|
-
easing: Easing.linear,
|
|
59
|
-
useNativeDriver: true,
|
|
60
|
-
}), [animationDuration]);
|
|
61
|
-
|
|
62
|
-
useLayoutEffect(() => {
|
|
63
|
-
const config = {
|
|
64
|
-
toValue: isActive ? 1 : 0,
|
|
65
|
-
...animationConfig,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
Animated.parallel([
|
|
69
|
-
Animated.timing(spinValue.current, config),
|
|
70
|
-
Animated.timing(positionValue.current, config),
|
|
71
|
-
]).start();
|
|
72
|
-
}, [isActive, animationConfig]);
|
|
73
|
-
|
|
74
|
-
// Memoize offsets calculation
|
|
75
|
-
const offsets = useMemo(
|
|
76
|
-
() =>
|
|
77
|
-
icons?.map((_, idx) =>
|
|
78
|
-
positionValue.current.interpolate({
|
|
79
|
-
inputRange: [0, 1],
|
|
80
|
-
outputRange: [0, -1 * (idx + 1) * (fabHeight.current + gap)],
|
|
81
|
-
}),
|
|
82
|
-
),
|
|
83
|
-
[icons, gap],
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Memoize layout handler
|
|
87
|
-
const onLayout = useCallback((e: LayoutChangeEvent): void => {
|
|
88
|
-
fabHeight.current = e.nativeEvent.layout.height;
|
|
89
|
-
}, []);
|
|
90
|
-
|
|
91
|
-
// Memoize item press handler
|
|
92
|
-
const handleItemPress = useCallback((icon: IconName) => {
|
|
93
|
-
onPressItem?.(icon);
|
|
94
|
-
}, [onPressItem]);
|
|
95
|
-
|
|
96
|
-
// Memoize main FAB press handler
|
|
97
|
-
const handleFabPress = useCallback(() => {
|
|
98
|
-
onPressFab();
|
|
99
|
-
}, [onPressFab]);
|
|
100
|
-
|
|
101
|
-
// Memoize container styles
|
|
102
|
-
const containerStyles = useMemo(() => [
|
|
103
|
-
{
|
|
104
|
-
position: 'absolute' as const,
|
|
105
|
-
right: 10,
|
|
106
|
-
bottom: 10,
|
|
107
|
-
zIndex: 999,
|
|
108
|
-
},
|
|
109
|
-
style,
|
|
110
|
-
], [style]);
|
|
111
|
-
|
|
112
|
-
// Memoize spin interpolation
|
|
113
|
-
const spinInterpolation = useMemo(() =>
|
|
114
|
-
spinValue.current.interpolate({
|
|
115
|
-
inputRange: [0, 1],
|
|
116
|
-
outputRange: ['0deg', '45deg'],
|
|
117
|
-
}),
|
|
118
|
-
[]);
|
|
119
|
-
|
|
120
|
-
// Memoize main FAB styles
|
|
121
|
-
const mainFabStyles = useMemo(() => [
|
|
122
|
-
{
|
|
123
|
-
transform: [{ rotate: spinInterpolation }],
|
|
124
|
-
},
|
|
125
|
-
Fab,
|
|
126
|
-
], [spinInterpolation, Fab]);
|
|
127
|
-
|
|
128
|
-
// Memoize icon items rendering
|
|
129
|
-
const iconItems = useMemo(() =>
|
|
130
|
-
icons.map((icon, idx) => (
|
|
131
|
-
<Animated.View
|
|
132
|
-
key={`${icon}-${idx}`}
|
|
133
|
-
style={[
|
|
134
|
-
{
|
|
135
|
-
position: 'absolute' as const,
|
|
136
|
-
transform: [{translateY: offsets[idx]}],
|
|
137
|
-
},
|
|
138
|
-
FabItem,
|
|
139
|
-
]}
|
|
140
|
-
>
|
|
141
|
-
<IconButton
|
|
142
|
-
icon={icon}
|
|
143
|
-
onPress={() => handleItemPress(icon)}
|
|
144
|
-
size={buttonSize}
|
|
145
|
-
testID={icon}
|
|
146
|
-
{...iconButtonProps}
|
|
147
|
-
/>
|
|
148
|
-
</Animated.View>
|
|
149
|
-
)),
|
|
150
|
-
[icons, offsets, FabItem, handleItemPress, buttonSize, iconButtonProps],
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<View style={containerStyles}>
|
|
155
|
-
{iconItems}
|
|
156
|
-
<Animated.View onLayout={onLayout} style={mainFabStyles}>
|
|
157
|
-
<IconButton
|
|
158
|
-
icon={fabIcon}
|
|
159
|
-
onPress={handleFabPress}
|
|
160
|
-
size={buttonSize}
|
|
161
|
-
{...iconButtonProps}
|
|
162
|
-
/>
|
|
163
|
-
</Animated.View>
|
|
164
|
-
</View>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export {FloatingActionButtons as Fab};
|
|
@@ -1,26 +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 {Hr} from './Hr';
|
|
8
|
-
|
|
9
|
-
let testingLib: RenderAPI;
|
|
10
|
-
|
|
11
|
-
const Component = (): ReactElement =>
|
|
12
|
-
createComponent(
|
|
13
|
-
<View>
|
|
14
|
-
<Hr />
|
|
15
|
-
</View>,
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
describe('[Hr]', () => {
|
|
19
|
-
it('should render without crashing', () => {
|
|
20
|
-
testingLib = render(Component());
|
|
21
|
-
|
|
22
|
-
const json = testingLib.toJSON();
|
|
23
|
-
|
|
24
|
-
expect(json).toBeTruthy();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import {styled} from 'kstyled';
|
|
4
|
-
import {isEmptyObject} from '../../../utils/theme';
|
|
5
|
-
|
|
6
|
-
const StyledHr = styled(View)`
|
|
7
|
-
height: 0.5px;
|
|
8
|
-
width: 100%;
|
|
9
|
-
background-color: ${({theme}) => {
|
|
10
|
-
if (isEmptyObject(theme)) {
|
|
11
|
-
return theme.role.border;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return theme.role.border;
|
|
15
|
-
}};
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
// Memoized Hr component for performance optimization
|
|
19
|
-
export const Hr = React.memo(StyledHr);
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type {ComponentProps} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import {css} from 'kstyled';
|
|
4
|
-
import type {Meta, StoryObj} from '@storybook/react';
|
|
5
|
-
import {Icon, iconList} from './Icon';
|
|
6
|
-
import {withThemeProvider} from '../../../../.storybook/decorators';
|
|
7
|
-
import {Typography} from '../Typography/Typography';
|
|
8
|
-
|
|
9
|
-
const meta = {
|
|
10
|
-
title: 'Icon',
|
|
11
|
-
component: (props) => (
|
|
12
|
-
<View
|
|
13
|
-
style={css`
|
|
14
|
-
align-items: center;
|
|
15
|
-
`}
|
|
16
|
-
>
|
|
17
|
-
<Icon {...props} />
|
|
18
|
-
<Typography.Body2
|
|
19
|
-
style={css`
|
|
20
|
-
font-size: 12px;
|
|
21
|
-
text-align: center;
|
|
22
|
-
`}
|
|
23
|
-
>
|
|
24
|
-
{props?.name}
|
|
25
|
-
</Typography.Body2>
|
|
26
|
-
</View>
|
|
27
|
-
),
|
|
28
|
-
parameters: {
|
|
29
|
-
docs: {
|
|
30
|
-
description: {
|
|
31
|
-
component: `
|
|
32
|
-
A flexible Icon component with a comprehensive icon library and size presets.
|
|
33
|
-
|
|
34
|
-
## Features
|
|
35
|
-
- **Extensive Icon Library**: Large collection of commonly used icons
|
|
36
|
-
- **Flexible Sizing**: Preset sizes and custom numeric values
|
|
37
|
-
- **Color Customization**: Support for custom icon colors
|
|
38
|
-
- **Optimized Performance**: Efficiently rendered vector icons
|
|
39
|
-
|
|
40
|
-
## Size Options
|
|
41
|
-
- \`small\`: 18px icon
|
|
42
|
-
- \`medium\`: 24px icon (default)
|
|
43
|
-
- \`large\`: 32px icon
|
|
44
|
-
- Custom number: Any pixel value (e.g., \`size={40}\`)
|
|
45
|
-
|
|
46
|
-
## Available Icons
|
|
47
|
-
The component includes a wide variety of icons such as:
|
|
48
|
-
- UI elements (MagnifyingGlass, Bell, Settings, etc.)
|
|
49
|
-
- Actions (Check, X, Plus, Minus, etc.)
|
|
50
|
-
- Navigation (ChevronUp, ChevronDown, ArrowLeft, ArrowRight, etc.)
|
|
51
|
-
- And many more...
|
|
52
|
-
|
|
53
|
-
## Usage
|
|
54
|
-
\`\`\`tsx
|
|
55
|
-
<Icon
|
|
56
|
-
name="MagnifyingGlass"
|
|
57
|
-
size="medium"
|
|
58
|
-
color="#000000"
|
|
59
|
-
/>
|
|
60
|
-
\`\`\`
|
|
61
|
-
`,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
argTypes: {
|
|
66
|
-
name: {
|
|
67
|
-
control: 'select',
|
|
68
|
-
options: iconList,
|
|
69
|
-
description: 'Name of the icon to display',
|
|
70
|
-
},
|
|
71
|
-
size: {
|
|
72
|
-
control: 'radio',
|
|
73
|
-
options: ['small', 'medium', 'large', 16, 24, 32, 48],
|
|
74
|
-
description: 'Icon size: "small" (18px), "medium" (24px), "large" (32px), or custom number in pixels',
|
|
75
|
-
},
|
|
76
|
-
color: {
|
|
77
|
-
description: 'Custom color for the icon',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
decorators: [withThemeProvider],
|
|
81
|
-
} satisfies Meta<typeof Icon>;
|
|
82
|
-
|
|
83
|
-
export default meta;
|
|
84
|
-
|
|
85
|
-
type Story = StoryObj<typeof meta>;
|
|
86
|
-
|
|
87
|
-
export const Basic: Story = {
|
|
88
|
-
args: {
|
|
89
|
-
name: 'MagnifyingGlass',
|
|
90
|
-
size: 'medium',
|
|
91
|
-
},
|
|
92
|
-
argTypes: {
|
|
93
|
-
theme: {
|
|
94
|
-
control: 'select',
|
|
95
|
-
options: ['light', 'dark'],
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, {type ReactElement} from 'react';
|
|
2
|
-
import type {RenderAPI} from '@testing-library/react-native';
|
|
3
|
-
import {render} from '@testing-library/react-native';
|
|
4
|
-
import {createComponent} from '../../../../test/testUtils';
|
|
5
|
-
import {Icon} from './Icon';
|
|
6
|
-
|
|
7
|
-
let testingLib: RenderAPI;
|
|
8
|
-
|
|
9
|
-
const Component = (): ReactElement => createComponent(<Icon name="Person" />);
|
|
10
|
-
|
|
11
|
-
describe('[Icon]', () => {
|
|
12
|
-
it('should render without crashing', () => {
|
|
13
|
-
testingLib = render(Component());
|
|
14
|
-
|
|
15
|
-
const json = testingLib.toJSON();
|
|
16
|
-
|
|
17
|
-
expect(json).toBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('sizes', () => {
|
|
21
|
-
it('should render with small size preset', () => {
|
|
22
|
-
testingLib = render(createComponent(<Icon name="Person" size="small" />));
|
|
23
|
-
|
|
24
|
-
const json = testingLib.toJSON();
|
|
25
|
-
expect(json).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should render with medium size preset', () => {
|
|
29
|
-
testingLib = render(createComponent(<Icon name="Person" size="medium" />));
|
|
30
|
-
|
|
31
|
-
const json = testingLib.toJSON();
|
|
32
|
-
expect(json).toBeTruthy();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should render with large size preset', () => {
|
|
36
|
-
testingLib = render(createComponent(<Icon name="Person" size="large" />));
|
|
37
|
-
|
|
38
|
-
const json = testingLib.toJSON();
|
|
39
|
-
expect(json).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should render with custom numeric size', () => {
|
|
43
|
-
testingLib = render(createComponent(<Icon name="Person" size={32} />));
|
|
44
|
-
|
|
45
|
-
const json = testingLib.toJSON();
|
|
46
|
-
expect(json).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|