@momo-kits/foundation 0.80.8 → 0.81.1-beta.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/Application/BottomSheet.tsx +212 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/BottomTab/index.tsx +143 -0
- package/Application/Components.tsx +384 -213
- package/Application/ModalScreen.tsx +14 -178
- package/Application/Navigation.ts +15 -19
- package/Application/NavigationContainer.tsx +66 -63
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -9
- package/Application/index.ts +19 -6
- package/Application/types.ts +83 -26
- package/Application/utils.tsx +62 -74
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +3 -1
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +64 -28
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +62 -47
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +104 -25
- package/Input/InputDropDown.tsx +115 -110
- package/Input/InputMoney.tsx +79 -18
- package/Input/InputOTP.tsx +190 -149
- package/Input/InputSearch.tsx +96 -44
- package/Input/InputTextArea.tsx +33 -17
- package/Input/common.tsx +26 -17
- package/Input/index.tsx +108 -41
- package/Input/styles.ts +5 -7
- package/Input/utils.ts +1 -1
- package/Layout/AnimatedInputSearch.tsx +44 -0
- package/Layout/Card.tsx +37 -13
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +2 -3
- package/Layout/Item.tsx +1 -2
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +404 -181
- package/Layout/Section.tsx +22 -22
- package/Layout/TextTyping.tsx +114 -0
- package/Layout/index.ts +12 -2
- package/Layout/styles.ts +46 -13
- package/Layout/types.ts +13 -5
- package/Layout/utils.ts +7 -12
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationDot.tsx +6 -1
- package/Pagination/PaginationNumber.tsx +7 -4
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +6 -1
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +108 -40
- package/Popup/PopupPromotion.tsx +45 -10
- package/Popup/types.ts +13 -10
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +32 -19
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +26 -6
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Title/index.tsx +177 -64
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -7
- package/code-scanner.js +125 -16
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +8 -7
- package/publish.sh +21 -16
- package/tsconfig.json +1 -2
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
package/Badge/Badge.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {ApplicationContext} from '../Application';
|
|
5
|
+
import {BadgeProps} from './types';
|
|
6
|
+
import styles from './styles';
|
|
7
|
+
import {Colors} from '../Consts';
|
|
8
|
+
import {Text} from '../Text';
|
|
9
|
+
|
|
10
|
+
const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
11
|
+
const {theme} = useContext(ApplicationContext);
|
|
12
|
+
|
|
13
|
+
const isValidatedColor = () => {
|
|
14
|
+
const colorKeys = Object.keys(Colors);
|
|
15
|
+
const colorValue = Object.values(Colors);
|
|
16
|
+
if (backgroundColor) {
|
|
17
|
+
const colorIndex = colorValue.indexOf(backgroundColor);
|
|
18
|
+
if (colorIndex !== -1) {
|
|
19
|
+
if (colorKeys[colorIndex]?.includes('_03')) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isNumber = () => {
|
|
28
|
+
const numberRegex = /^\d+$/;
|
|
29
|
+
return numberRegex.test(String(label));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const formatTitle = () => {
|
|
33
|
+
if (isNumber() && Number(label) > 99) {
|
|
34
|
+
return '99+';
|
|
35
|
+
}
|
|
36
|
+
return label.toString();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let badgeColor = isNumber()
|
|
40
|
+
? theme.colors.error.primary
|
|
41
|
+
: theme.colors.warning.primary;
|
|
42
|
+
|
|
43
|
+
if (backgroundColor && isValidatedColor()) {
|
|
44
|
+
badgeColor = backgroundColor;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
+
<Text color={Colors.black_01} typography={'action_xxs_bold'}>
|
|
50
|
+
{formatTitle()}
|
|
51
|
+
</Text>
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default Badge;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {BadgeDotProps} from './types';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
|
|
6
|
+
const BadgeDot: FC<BadgeDotProps> = ({size = 'large', style}) => {
|
|
7
|
+
const dotStyle = size === 'small' ? styles.dotSmall : styles.dot;
|
|
8
|
+
return <View style={[style, dotStyle]} />;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default BadgeDot;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {DownTail, UpTail} from './Shape';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
import {BadgeRibbonProps} from './types';
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {Text} from '../Text';
|
|
8
|
+
import {Colors} from '../Consts';
|
|
9
|
+
import {Image} from '../Image';
|
|
10
|
+
|
|
11
|
+
const BadgeRibbon: FC<BadgeRibbonProps> = ({
|
|
12
|
+
position = 'top_right',
|
|
13
|
+
label = 'Label',
|
|
14
|
+
isRound = false,
|
|
15
|
+
style = {},
|
|
16
|
+
}) => {
|
|
17
|
+
const {theme} = useContext(ApplicationContext);
|
|
18
|
+
let ribbonRotate = '0deg';
|
|
19
|
+
let textRotate = '0deg';
|
|
20
|
+
let ribbonTail = <DownTail />;
|
|
21
|
+
let textMargin = 0;
|
|
22
|
+
let skewMargin = 0;
|
|
23
|
+
|
|
24
|
+
if (position === 'top_right' || position === 'bottom_right') {
|
|
25
|
+
ribbonRotate = '180deg';
|
|
26
|
+
textRotate = '180deg';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (position === 'bottom_left' || position === 'top_right') {
|
|
30
|
+
textMargin = 4;
|
|
31
|
+
ribbonTail = <UpTail />;
|
|
32
|
+
skewMargin = 4;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const renderRoundContent = () => {
|
|
36
|
+
return (
|
|
37
|
+
<View
|
|
38
|
+
style={[
|
|
39
|
+
styles.ribbonContent,
|
|
40
|
+
{
|
|
41
|
+
backgroundColor: theme.colors.warning.primary,
|
|
42
|
+
marginTop: textMargin,
|
|
43
|
+
},
|
|
44
|
+
]}>
|
|
45
|
+
<Text
|
|
46
|
+
style={[
|
|
47
|
+
styles.ribbonLabel,
|
|
48
|
+
{
|
|
49
|
+
transform: [
|
|
50
|
+
{
|
|
51
|
+
rotate: textRotate,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
color={Colors.black_01}
|
|
57
|
+
typography={'label_xs_medium'}>
|
|
58
|
+
{label}
|
|
59
|
+
</Text>
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const renderSkewContent = () => {
|
|
65
|
+
return (
|
|
66
|
+
<View
|
|
67
|
+
style={{
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
marginTop: skewMargin,
|
|
70
|
+
}}>
|
|
71
|
+
<View
|
|
72
|
+
style={[
|
|
73
|
+
styles.ribbonSkewContent,
|
|
74
|
+
{
|
|
75
|
+
backgroundColor: theme.colors.warning.primary,
|
|
76
|
+
},
|
|
77
|
+
]}>
|
|
78
|
+
<Text
|
|
79
|
+
style={[
|
|
80
|
+
styles.ribbonLabel,
|
|
81
|
+
{
|
|
82
|
+
transform: [
|
|
83
|
+
{
|
|
84
|
+
rotate: textRotate,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
]}
|
|
89
|
+
color={Colors.black_01}
|
|
90
|
+
typography={'label_xs_medium'}>
|
|
91
|
+
{label}
|
|
92
|
+
</Text>
|
|
93
|
+
</View>
|
|
94
|
+
<Image
|
|
95
|
+
source={{
|
|
96
|
+
uri: 'https://static.momocdn.net/app/img/kits/utils/Tail_4x.png',
|
|
97
|
+
}}
|
|
98
|
+
style={styles.skew}
|
|
99
|
+
/>
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const content = isRound ? renderRoundContent() : renderSkewContent();
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<View
|
|
108
|
+
style={[
|
|
109
|
+
style,
|
|
110
|
+
styles.ribbon,
|
|
111
|
+
{
|
|
112
|
+
transform: [
|
|
113
|
+
{
|
|
114
|
+
rotate: ribbonRotate,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
]}>
|
|
119
|
+
{ribbonTail}
|
|
120
|
+
{content}
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default BadgeRibbon;
|
package/Badge/Shape.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './styles';
|
|
3
|
+
import {Image} from '../Image';
|
|
4
|
+
|
|
5
|
+
const UpTail = () => {
|
|
6
|
+
return (
|
|
7
|
+
<Image
|
|
8
|
+
resizeMode={'stretch'}
|
|
9
|
+
source={{
|
|
10
|
+
uri: 'https://static.momocdn.net/app/img/kits/utils/Head_down_4x.png',
|
|
11
|
+
}}
|
|
12
|
+
style={[styles.tail, {transform: [{rotate: '180deg'}]}]}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const DownTail = () => {
|
|
18
|
+
return (
|
|
19
|
+
<Image
|
|
20
|
+
resizeMode={'stretch'}
|
|
21
|
+
source={{
|
|
22
|
+
uri: 'https://static.momocdn.net/app/img/kits/utils/Head_4x.png',
|
|
23
|
+
}}
|
|
24
|
+
style={styles.tail}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {UpTail, DownTail};
|
package/Badge/index.tsx
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Badge from './Badge';
|
|
2
|
+
import BadgeDot from './BadgeDot';
|
|
3
|
+
import BadgeRibbon from './BadgeRibbon';
|
|
4
|
+
import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
|
|
5
|
+
|
|
6
|
+
export {Badge, BadgeRibbon, BadgeDot};
|
|
7
|
+
export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
|
package/Badge/styles.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
|
+
import {scaleSize} from '../Text';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
badge: {
|
|
7
|
+
paddingHorizontal: Spacing.XS,
|
|
8
|
+
borderRadius: Radius.M,
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
height: scaleSize(16),
|
|
12
|
+
minWidth: scaleSize(16),
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderColor: Colors.black_01,
|
|
16
|
+
alignSelf: 'baseline',
|
|
17
|
+
},
|
|
18
|
+
dot: {
|
|
19
|
+
width: 16,
|
|
20
|
+
height: 16,
|
|
21
|
+
borderWidth: 2,
|
|
22
|
+
borderColor: Colors.black_01,
|
|
23
|
+
backgroundColor: Colors.red_03,
|
|
24
|
+
borderRadius: 8,
|
|
25
|
+
},
|
|
26
|
+
dotSmall: {
|
|
27
|
+
width: 10,
|
|
28
|
+
height: 10,
|
|
29
|
+
borderWidth: 1,
|
|
30
|
+
borderColor: Colors.black_01,
|
|
31
|
+
backgroundColor: Colors.red_03,
|
|
32
|
+
borderRadius: 5,
|
|
33
|
+
},
|
|
34
|
+
ribbon: {
|
|
35
|
+
alignSelf: 'baseline',
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
height: 20,
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
},
|
|
40
|
+
ribbonContent: {
|
|
41
|
+
height: 16,
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
borderBottomRightRadius: 12,
|
|
45
|
+
borderTopRightRadius: 12,
|
|
46
|
+
paddingRight: 6,
|
|
47
|
+
},
|
|
48
|
+
ribbonSkewContent: {
|
|
49
|
+
height: 16,
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
},
|
|
53
|
+
ribbonLabel: {
|
|
54
|
+
color: Colors.black_01,
|
|
55
|
+
},
|
|
56
|
+
skew: {width: 8, height: 16},
|
|
57
|
+
tail: {width: 5, height: 20},
|
|
58
|
+
});
|
package/Badge/types.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for a general Badge component. It can display a wide range of badges including simple labels, numbers, or dots.
|
|
5
|
+
*/
|
|
6
|
+
export type BadgeProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Optional. The text to display on the badge. This could be a number or string, depending on the badge's purpose.
|
|
9
|
+
*/
|
|
10
|
+
label?: string | number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Optional. Custom styles to apply to the badge component. Can be a single style or an array of styles.
|
|
14
|
+
*/
|
|
15
|
+
style?: ViewStyle | ViewStyle[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Optional. Custom background badge.
|
|
19
|
+
*/
|
|
20
|
+
backgroundColor?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Props for a BadgeDot component. It specifically represents a dot-style badge, typically used for notification indicators.
|
|
25
|
+
*/
|
|
26
|
+
export type BadgeDotProps = {
|
|
27
|
+
/**
|
|
28
|
+
* Optional. The size of the dot, either 'small' or 'large'. This allows for better visual alignment with different UI elements.
|
|
29
|
+
*/
|
|
30
|
+
size?: 'small' | 'large';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional. Custom styles to apply to the badge dot component. Can be a single style or an array of styles.
|
|
34
|
+
*/
|
|
35
|
+
style?: ViewStyle | ViewStyle[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Props for a BadgeRibbon component. It represents a more specialized badge in the shape of a ribbon, allowing for placement around containers.
|
|
40
|
+
*/
|
|
41
|
+
export type BadgeRibbonProps = {
|
|
42
|
+
/**
|
|
43
|
+
* The text to display on the ribbon-style badge. Unlike other badges, ribbons typically carry more descriptive text.
|
|
44
|
+
*/
|
|
45
|
+
label: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Optional. Determines the placement of the ribbon on its parent container. The position can be any corner of the container.
|
|
49
|
+
* Defaults to 'top_right' if not specified.
|
|
50
|
+
*/
|
|
51
|
+
position?: 'top_right' | 'top_left' | 'bottom_right' | 'bottom_left';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional. If true, the edges of the ribbon badge will be rounded. This is purely a stylistic choice.
|
|
55
|
+
* Defaults to `false` if not provided, resulting in a flat-edged ribbon.
|
|
56
|
+
*/
|
|
57
|
+
isRound?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Optional. Custom styles to apply to the ribbon badge component. Can be a single style or an array of styles.
|
|
61
|
+
*/
|
|
62
|
+
style?: ViewStyle | ViewStyle[];
|
|
63
|
+
};
|
package/Button/index.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, {FC, useContext} from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Animated,
|
|
3
4
|
StyleSheet,
|
|
4
5
|
TouchableOpacity,
|
|
5
6
|
TouchableOpacityProps,
|
|
6
7
|
View,
|
|
7
8
|
} from 'react-native';
|
|
8
|
-
import
|
|
9
|
+
import LinearGradient from 'react-native-linear-gradient';
|
|
10
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
9
11
|
import {Text} from '../Text';
|
|
10
12
|
import {Typography} from '../Text/types';
|
|
11
13
|
import {Colors, Spacing} from '../Consts';
|
|
@@ -13,6 +15,8 @@ import styles from './styles';
|
|
|
13
15
|
import {Icon} from '../Icon';
|
|
14
16
|
import {Loader} from '../Loader';
|
|
15
17
|
|
|
18
|
+
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
19
|
+
|
|
16
20
|
export interface ButtonProps extends TouchableOpacityProps {
|
|
17
21
|
/**
|
|
18
22
|
* Defines the visual style of the button.
|
|
@@ -54,7 +58,7 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
54
58
|
/**
|
|
55
59
|
* If true, the icon of button will use the tint color provided by its container.
|
|
56
60
|
*/
|
|
57
|
-
|
|
61
|
+
tintColor?: string;
|
|
58
62
|
|
|
59
63
|
/**
|
|
60
64
|
* If true, the icon of button will use be show indicator loading.
|
|
@@ -65,21 +69,39 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
65
69
|
* A callback function that is called when the button is pressed.
|
|
66
70
|
*/
|
|
67
71
|
onPress: () => void;
|
|
72
|
+
|
|
73
|
+
params?: any;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
const Button: FC<ButtonProps> = ({
|
|
71
77
|
type = 'primary',
|
|
72
78
|
size = 'large',
|
|
73
|
-
|
|
79
|
+
tintColor = null,
|
|
74
80
|
full = true,
|
|
75
81
|
iconRight,
|
|
76
82
|
iconLeft,
|
|
77
83
|
loading = false,
|
|
78
84
|
title = 'Button',
|
|
79
85
|
onPress,
|
|
86
|
+
params,
|
|
87
|
+
accessibilityLabel,
|
|
80
88
|
...rest
|
|
81
89
|
}) => {
|
|
82
|
-
const {theme} = useContext(ApplicationContext);
|
|
90
|
+
const {theme, config} = useContext(ApplicationContext);
|
|
91
|
+
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
92
|
+
let gradientPros;
|
|
93
|
+
let state = 'enabled';
|
|
94
|
+
if (loading) {
|
|
95
|
+
state = 'loading';
|
|
96
|
+
}
|
|
97
|
+
if (gradient?.length > 0 && type === 'primary') {
|
|
98
|
+
gradientPros = {
|
|
99
|
+
colors: gradient,
|
|
100
|
+
start: {x: 1, y: 0.5},
|
|
101
|
+
end: {x: 0, y: 0.5},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
83
105
|
const getSizeStyle = () => {
|
|
84
106
|
const styleSheet: {[key: string]: any} = styles;
|
|
85
107
|
return styleSheet[size ?? 'small'];
|
|
@@ -103,7 +125,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
103
125
|
return {
|
|
104
126
|
backgroundColor: theme.colors.background.surface,
|
|
105
127
|
borderWidth: 1,
|
|
106
|
-
borderColor: theme.colors.primary,
|
|
128
|
+
borderColor: color ?? theme.colors.primary,
|
|
107
129
|
};
|
|
108
130
|
case 'tonal':
|
|
109
131
|
return {
|
|
@@ -158,14 +180,14 @@ const Button: FC<ButtonProps> = ({
|
|
|
158
180
|
const getTypography = (): Typography => {
|
|
159
181
|
switch (size) {
|
|
160
182
|
case 'large':
|
|
161
|
-
return '
|
|
183
|
+
return 'action_default_bold';
|
|
162
184
|
case 'medium':
|
|
163
|
-
return '
|
|
185
|
+
return 'action_s_bold';
|
|
164
186
|
case 'small':
|
|
165
|
-
return '
|
|
187
|
+
return 'action_xs_bold';
|
|
166
188
|
|
|
167
189
|
default:
|
|
168
|
-
return '
|
|
190
|
+
return 'action_default_bold';
|
|
169
191
|
}
|
|
170
192
|
};
|
|
171
193
|
|
|
@@ -178,13 +200,13 @@ const Button: FC<ButtonProps> = ({
|
|
|
178
200
|
case 'secondary':
|
|
179
201
|
return theme.colors.text.default;
|
|
180
202
|
case 'outline':
|
|
181
|
-
return theme.colors.primary;
|
|
203
|
+
return color ?? theme.colors.primary;
|
|
182
204
|
case 'tonal':
|
|
183
205
|
return theme.colors.primary;
|
|
184
206
|
case 'danger':
|
|
185
207
|
return Colors.black_01;
|
|
186
208
|
case 'text':
|
|
187
|
-
return theme.colors.primary;
|
|
209
|
+
return color ?? theme.colors.primary;
|
|
188
210
|
default:
|
|
189
211
|
return Colors.black_01;
|
|
190
212
|
}
|
|
@@ -195,9 +217,9 @@ const Button: FC<ButtonProps> = ({
|
|
|
195
217
|
*/
|
|
196
218
|
const renderTitle = () => {
|
|
197
219
|
const typography = getTypography();
|
|
198
|
-
const
|
|
220
|
+
const textColor = getTextColor();
|
|
199
221
|
return (
|
|
200
|
-
<Text typography={typography} color={
|
|
222
|
+
<Text typography={typography} color={textColor} numberOfLines={1}>
|
|
201
223
|
{title}
|
|
202
224
|
</Text>
|
|
203
225
|
);
|
|
@@ -209,7 +231,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
209
231
|
const renderLeading = () => {
|
|
210
232
|
const iconSize = getIconSize();
|
|
211
233
|
const marginRight = getIconSpace();
|
|
212
|
-
const
|
|
234
|
+
const textColor = tintColor ?? getTextColor();
|
|
213
235
|
|
|
214
236
|
if (loading) {
|
|
215
237
|
return (
|
|
@@ -223,7 +245,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
223
245
|
borderRadius: Spacing.M,
|
|
224
246
|
},
|
|
225
247
|
]}>
|
|
226
|
-
<Loader type="spinner" color={
|
|
248
|
+
<Loader type="spinner" color={getTextColor()} />
|
|
227
249
|
</View>
|
|
228
250
|
);
|
|
229
251
|
}
|
|
@@ -234,7 +256,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
234
256
|
styles.leading,
|
|
235
257
|
{width: iconSize, height: iconSize, marginRight},
|
|
236
258
|
]}>
|
|
237
|
-
<Icon color={
|
|
259
|
+
<Icon color={textColor} source={iconLeft} size={iconSize} />
|
|
238
260
|
</View>
|
|
239
261
|
);
|
|
240
262
|
}
|
|
@@ -244,7 +266,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
244
266
|
* render trailing
|
|
245
267
|
*/
|
|
246
268
|
const renderTrailing = () => {
|
|
247
|
-
const
|
|
269
|
+
const textColor = tintColor ?? getTextColor();
|
|
248
270
|
const marginLeft = getIconSpace();
|
|
249
271
|
|
|
250
272
|
if (iconRight) {
|
|
@@ -255,7 +277,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
255
277
|
styles.trailing,
|
|
256
278
|
{width: iconSize, height: iconSize, marginLeft},
|
|
257
279
|
]}>
|
|
258
|
-
<Icon color={
|
|
280
|
+
<Icon color={textColor} source={iconRight} size={iconSize} />
|
|
259
281
|
</View>
|
|
260
282
|
);
|
|
261
283
|
}
|
|
@@ -277,16 +299,30 @@ const Button: FC<ButtonProps> = ({
|
|
|
277
299
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
278
300
|
|
|
279
301
|
return (
|
|
280
|
-
<
|
|
281
|
-
{
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
302
|
+
<ComponentContext.Provider
|
|
303
|
+
value={{
|
|
304
|
+
componentName: 'Button',
|
|
305
|
+
params,
|
|
306
|
+
state: state,
|
|
307
|
+
componentId: accessibilityLabel,
|
|
308
|
+
componentValue: title,
|
|
309
|
+
action: 'click',
|
|
310
|
+
}}>
|
|
311
|
+
<TouchableOpacity
|
|
312
|
+
{...rest}
|
|
313
|
+
accessibilityLabel={accessibilityLabel}
|
|
314
|
+
activeOpacity={activeOpacity}
|
|
315
|
+
onPress={onPressButton}
|
|
316
|
+
style={buttonStyle}>
|
|
317
|
+
{renderLeading()}
|
|
318
|
+
{renderTitle()}
|
|
319
|
+
{renderTrailing()}
|
|
320
|
+
{gradientPros && (
|
|
321
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
322
|
+
)}
|
|
323
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
324
|
+
</TouchableOpacity>
|
|
325
|
+
</ComponentContext.Provider>
|
|
290
326
|
);
|
|
291
327
|
};
|
|
292
328
|
|
package/Button/styles.ts
CHANGED
|
@@ -38,4 +38,23 @@ export default StyleSheet.create({
|
|
|
38
38
|
alignItems: 'center',
|
|
39
39
|
justifyContent: 'center',
|
|
40
40
|
},
|
|
41
|
+
gradientView: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
zIndex: -1,
|
|
44
|
+
borderRadius: 8,
|
|
45
|
+
top: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
right: 0,
|
|
49
|
+
},
|
|
50
|
+
strokeView: {
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
top: 2,
|
|
53
|
+
bottom: 2,
|
|
54
|
+
left: 2,
|
|
55
|
+
right: 2,
|
|
56
|
+
borderRadius: 6,
|
|
57
|
+
borderWidth: 0.5,
|
|
58
|
+
borderColor: '#FFF9E1',
|
|
59
|
+
},
|
|
41
60
|
});
|
package/CheckBox/index.tsx
CHANGED
|
@@ -2,17 +2,20 @@ import React, {FC, useContext} from 'react';
|
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {CheckBoxProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../Application';
|
|
5
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {formatNameLength} from '../Application/utils';
|
|
8
9
|
|
|
9
10
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
10
11
|
value,
|
|
11
|
-
disabled,
|
|
12
|
+
disabled = false,
|
|
12
13
|
onChange,
|
|
13
14
|
style,
|
|
14
15
|
label,
|
|
15
16
|
indeterminate,
|
|
17
|
+
params,
|
|
18
|
+
accessibilityLabel,
|
|
16
19
|
}) => {
|
|
17
20
|
const {theme} = useContext(ApplicationContext);
|
|
18
21
|
const haveValue = value || indeterminate;
|
|
@@ -35,32 +38,39 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
<ComponentContext.Provider
|
|
42
|
+
value={{
|
|
43
|
+
componentName: 'CheckBox',
|
|
44
|
+
params,
|
|
45
|
+
state: disabled ? 'disabled' : 'filled',
|
|
46
|
+
componentId: accessibilityLabel,
|
|
47
|
+
action: 'click',
|
|
48
|
+
componentLabel: formatNameLength(label || ''),
|
|
49
|
+
componentValue: indeterminate ? 'undetermined' : value,
|
|
50
|
+
}}>
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
accessibilityLabel={accessibilityLabel}
|
|
53
|
+
activeOpacity={0.8}
|
|
54
|
+
onPress={() => onChange?.(!value)}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
style={[style, styles.container]}>
|
|
57
|
+
<View
|
|
58
|
+
style={[
|
|
59
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
60
|
+
styles.checkbox,
|
|
61
|
+
]}>
|
|
62
|
+
{haveValue && (
|
|
63
|
+
<Icon
|
|
64
|
+
color={theme.colors.background.surface}
|
|
65
|
+
size={20}
|
|
66
|
+
source={iconSource}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</View>
|
|
70
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
</ComponentContext.Provider>
|
|
59
73
|
);
|
|
60
74
|
};
|
|
61
75
|
|
|
62
|
-
CheckBox.defaultProps = {
|
|
63
|
-
disabled: false,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
76
|
export {CheckBox};
|
package/CheckBox/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
1
|
+
import {TouchableOpacityProps, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface CheckBoxProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* Represents whether the CheckBox is currently checked (`true`) or unchecked (`false`).
|
|
6
6
|
*/
|
|
@@ -35,4 +35,6 @@ export type CheckBoxProps = {
|
|
|
35
35
|
* Accepts an object of style properties.
|
|
36
36
|
*/
|
|
37
37
|
style?: ViewStyle;
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
params?: any;
|
|
40
|
+
}
|