@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/Text/styles.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
|
|
3
|
+
header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
|
|
4
|
+
header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
5
|
+
header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
|
|
6
|
+
header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
|
|
7
|
+
body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
|
|
8
|
+
body_default_regularstrikethrought: {
|
|
9
|
+
fontSize: 14,
|
|
10
|
+
lineHeight: 20,
|
|
11
|
+
fontWeight: '400',
|
|
12
|
+
textDecorationLine: 'line-through',
|
|
13
|
+
},
|
|
14
|
+
description_default_regular: {
|
|
15
|
+
fontSize: 12,
|
|
16
|
+
lineHeight: 18,
|
|
17
|
+
fontWeight: '400',
|
|
18
|
+
},
|
|
19
|
+
description_default_regularstrikethrought: {
|
|
20
|
+
fontSize: 12,
|
|
21
|
+
lineHeight: 18,
|
|
22
|
+
fontWeight: '400',
|
|
23
|
+
textDecorationLine: 'line-through',
|
|
24
|
+
},
|
|
25
|
+
description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
|
|
26
|
+
description_xs_regularstrikethrought: {
|
|
27
|
+
fontSize: 10,
|
|
28
|
+
lineHeight: 14,
|
|
29
|
+
fontWeight: '400',
|
|
30
|
+
textDecorationLine: 'line-through',
|
|
31
|
+
},
|
|
32
|
+
label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
|
|
33
|
+
label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
|
|
34
|
+
label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
|
|
35
|
+
action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
|
|
36
|
+
action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
|
|
37
|
+
action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
|
|
38
|
+
action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
|
|
39
|
+
/**non-support**/
|
|
2
40
|
headline_default: {
|
|
3
41
|
fontSize: 28,
|
|
4
42
|
lineHeight: 34,
|
package/Text/types.ts
CHANGED
|
@@ -14,27 +14,39 @@ export type TypographyWeight = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type Typography =
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
**/
|
|
17
20
|
| 'headline_default'
|
|
18
|
-
| 'headline_s'
|
|
19
21
|
| 'headline_l'
|
|
20
22
|
| 'headline_xl'
|
|
21
23
|
| 'title_default'
|
|
22
24
|
| 'title_xs'
|
|
23
25
|
| 'title_s'
|
|
24
26
|
| 'header_default'
|
|
25
|
-
| 'header_xs'
|
|
26
|
-
| 'header_s'
|
|
27
27
|
| 'paragraph_default'
|
|
28
28
|
| 'paragraph_bold'
|
|
29
29
|
| 'paragraph_italic'
|
|
30
|
-
| 'description_default'
|
|
31
|
-
| 'description_xs'
|
|
32
|
-
| 'description_s'
|
|
33
|
-
| 'label_default'
|
|
34
30
|
| 'label_xxs'
|
|
35
|
-
| '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| '
|
|
40
|
-
| '
|
|
31
|
+
| 'action_s'
|
|
32
|
+
/**
|
|
33
|
+
* end
|
|
34
|
+
**/
|
|
35
|
+
| 'headline_default_bold'
|
|
36
|
+
| 'header_m_bold'
|
|
37
|
+
| 'header_default_bold'
|
|
38
|
+
| 'header_s_semibold'
|
|
39
|
+
| 'header_xs_semibold'
|
|
40
|
+
| 'body_default_regular'
|
|
41
|
+
| 'body_default_regularstrikethrought'
|
|
42
|
+
| 'description_default_regular'
|
|
43
|
+
| 'description_default_regularstrikethrought'
|
|
44
|
+
| 'description_xs_regular'
|
|
45
|
+
| 'description_xs_regularstrikethrought'
|
|
46
|
+
| 'label_default_medium'
|
|
47
|
+
| 'label_s_medium'
|
|
48
|
+
| 'label_xs_medium'
|
|
49
|
+
| 'action_default_bold'
|
|
50
|
+
| 'action_s_bold'
|
|
51
|
+
| 'action_xs_bold'
|
|
52
|
+
| 'action_xxs_bold';
|
package/Title/index.tsx
CHANGED
|
@@ -1,86 +1,199 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {Text as RNText, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import React, {FC, useContext, useState} from 'react';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
Typography,
|
|
5
|
+
Colors,
|
|
6
|
+
Icon,
|
|
7
|
+
Badge,
|
|
8
|
+
ApplicationContext,
|
|
9
|
+
scaleSize,
|
|
10
|
+
Text,
|
|
11
|
+
} from '@momo-kits/foundation';
|
|
5
12
|
import styles from './styles';
|
|
6
|
-
import {
|
|
7
|
-
import {Colors, Spacing} from '../Consts';
|
|
8
|
-
import {Button} from '../Button';
|
|
9
|
-
import {scaleSize, Text} from '../Text';
|
|
13
|
+
import {TitleProps} from './types';
|
|
10
14
|
|
|
11
15
|
const Title: FC<TitleProps> = ({
|
|
12
|
-
size = 'large',
|
|
13
|
-
type = 'section',
|
|
14
|
-
onPressAction,
|
|
15
|
-
actionTitle,
|
|
16
16
|
title = 'Title',
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
type = 'section',
|
|
18
|
+
size = 'medium',
|
|
19
19
|
icon,
|
|
20
20
|
description,
|
|
21
|
+
iconColor = null,
|
|
22
|
+
iconAlign = 'top',
|
|
23
|
+
showRightAction = false,
|
|
24
|
+
showTrailingAction = false,
|
|
25
|
+
badgeLabel,
|
|
26
|
+
buttonTitle,
|
|
27
|
+
onPressRightAction = () => {},
|
|
28
|
+
onPressTrailingAction = () => {},
|
|
29
|
+
buttonSize = 'small',
|
|
30
|
+
textOnly = false,
|
|
31
|
+
style,
|
|
21
32
|
}) => {
|
|
22
33
|
const {theme} = useContext(ApplicationContext);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
|
|
34
|
+
const [badgeWidth, setBadgeWidth] = useState(0);
|
|
35
|
+
const [contentWidth, setContentWidth] = useState(0);
|
|
36
|
+
const styleSheet: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
} = styles;
|
|
39
|
+
const typography = `${type}_${size}`;
|
|
40
|
+
const isSection = type === 'section';
|
|
41
|
+
const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
|
|
42
|
+
const buttonTypo: Typography =
|
|
43
|
+
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
44
|
+
const flexStyle = showTrailingAction && {maxWidth: '70%'};
|
|
35
45
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
46
|
+
const renderIcon = () => {
|
|
47
|
+
if (!icon) return null;
|
|
48
|
+
|
|
49
|
+
let iconStyle: ViewStyle = {
|
|
50
|
+
justifyContent: 'flex-start',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (iconAlign === 'middle') {
|
|
54
|
+
iconStyle = {justifyContent: 'center'};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (iconAlign === 'bottom') {
|
|
58
|
+
iconStyle = {justifyContent: 'flex-end'};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<View style={[styles.iconView, iconStyle]}>
|
|
63
|
+
<Icon color={iconColor} source={icon} />
|
|
64
|
+
</View>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const renderContent = () => {
|
|
69
|
+
return (
|
|
70
|
+
<View style={styles.contentView}>
|
|
71
|
+
<View
|
|
72
|
+
onLayout={e => {
|
|
73
|
+
if (e.nativeEvent.layout.width !== contentWidth) {
|
|
74
|
+
setContentWidth(e.nativeEvent.layout.width);
|
|
75
|
+
}
|
|
76
|
+
}}
|
|
77
|
+
style={[styles.iconLeftView, flexStyle]}>
|
|
78
|
+
<RNText
|
|
79
|
+
numberOfLines={numberOfLines}
|
|
80
|
+
style={[
|
|
81
|
+
styleSheet[typography],
|
|
82
|
+
styles.title,
|
|
83
|
+
{
|
|
84
|
+
maxWidth:
|
|
85
|
+
contentWidth > 0 ? contentWidth - badgeWidth : undefined,
|
|
86
|
+
},
|
|
87
|
+
]}>
|
|
88
|
+
{title}
|
|
89
|
+
</RNText>
|
|
90
|
+
{badgeLabel && (
|
|
91
|
+
<View
|
|
92
|
+
onLayout={e => {
|
|
93
|
+
if (e.nativeEvent.layout.width !== badgeWidth) {
|
|
94
|
+
setBadgeWidth(e.nativeEvent.layout.width);
|
|
95
|
+
}
|
|
96
|
+
}}
|
|
97
|
+
style={{
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
}}>
|
|
100
|
+
<Badge style={styles.badge} label={badgeLabel} />
|
|
101
|
+
</View>
|
|
102
|
+
)}
|
|
103
|
+
{renderActionLeft()}
|
|
104
|
+
</View>
|
|
105
|
+
{description && (
|
|
106
|
+
<Text
|
|
107
|
+
style={styles.description}
|
|
108
|
+
color={theme.colors.text.secondary}
|
|
109
|
+
typography={'description_default_regular'}>
|
|
110
|
+
{description}
|
|
111
|
+
</Text>
|
|
112
|
+
)}
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const renderActionLeft = () => {
|
|
118
|
+
return (
|
|
44
119
|
<TouchableOpacity
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
120
|
+
onPress={onPressTrailingAction}
|
|
121
|
+
style={styles.iconLeftView}>
|
|
122
|
+
{showTrailingAction && !showRightAction && (
|
|
123
|
+
<View
|
|
124
|
+
style={[
|
|
125
|
+
styles.iconLeft,
|
|
126
|
+
{
|
|
127
|
+
backgroundColor: isSection
|
|
128
|
+
? Colors.black_06 + '99'
|
|
129
|
+
: Colors.black_06 + '4D',
|
|
130
|
+
},
|
|
131
|
+
]}>
|
|
132
|
+
<Icon
|
|
133
|
+
source={'arrow_chevron_right_small'}
|
|
134
|
+
size={scaleSize(18)}
|
|
135
|
+
color={theme.colors.text.default}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
)}
|
|
56
139
|
</TouchableOpacity>
|
|
57
140
|
);
|
|
58
141
|
};
|
|
59
142
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
143
|
+
const renderActionRight = () => {
|
|
144
|
+
if (!showRightAction || showTrailingAction) return false;
|
|
145
|
+
|
|
146
|
+
const lineHeight = styleSheet[typography].lineHeight;
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<View
|
|
150
|
+
style={{
|
|
151
|
+
height: lineHeight,
|
|
152
|
+
justifyContent: 'center',
|
|
153
|
+
}}>
|
|
154
|
+
{!buttonTitle ? (
|
|
155
|
+
<TouchableOpacity
|
|
156
|
+
onPress={onPressRightAction}
|
|
157
|
+
style={[
|
|
158
|
+
styles.iconRight,
|
|
159
|
+
{
|
|
160
|
+
backgroundColor: theme.colors.primary + '0F',
|
|
161
|
+
},
|
|
162
|
+
]}>
|
|
163
|
+
<Icon
|
|
164
|
+
source={'arrow_chevron_right_small'}
|
|
165
|
+
size={scaleSize(22)}
|
|
166
|
+
color={theme.colors.primary}
|
|
167
|
+
/>
|
|
168
|
+
</TouchableOpacity>
|
|
169
|
+
) : (
|
|
170
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
171
|
+
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
172
|
+
{buttonTitle}
|
|
173
|
+
</Text>
|
|
174
|
+
</TouchableOpacity>
|
|
65
175
|
)}
|
|
176
|
+
</View>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
if (textOnly) {
|
|
181
|
+
return (
|
|
182
|
+
<View style={isSection && styles.margin}>
|
|
66
183
|
<RNText
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
flexStyle,
|
|
70
|
-
styles.title,
|
|
71
|
-
{
|
|
72
|
-
fontFamily: `${theme.font}-${titleWeight}`,
|
|
73
|
-
},
|
|
74
|
-
]}>
|
|
184
|
+
numberOfLines={numberOfLines}
|
|
185
|
+
style={[styleSheet[typography], styles.title]}>
|
|
75
186
|
{title}
|
|
76
187
|
</RNText>
|
|
77
|
-
{showAction && type !== 'screen' && renderAction()}
|
|
78
188
|
</View>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<View style={[style, styles.wrapper, isSection && styles.margin]}>
|
|
194
|
+
{renderIcon()}
|
|
195
|
+
{renderContent()}
|
|
196
|
+
{renderActionRight()}
|
|
84
197
|
</View>
|
|
85
198
|
);
|
|
86
199
|
};
|
package/Title/styles.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
2
|
import {scaleSize} from '../Text';
|
|
3
|
-
import {Radius, Spacing} from '../Consts';
|
|
3
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
4
4
|
|
|
5
5
|
export default StyleSheet.create({
|
|
6
6
|
card_small: {
|
|
7
|
+
fontSize: scaleSize(14),
|
|
8
|
+
lineHeight: scaleSize(20),
|
|
9
|
+
},
|
|
10
|
+
card_medium: {
|
|
7
11
|
fontSize: scaleSize(16),
|
|
8
12
|
lineHeight: scaleSize(22),
|
|
9
13
|
},
|
|
@@ -11,36 +15,65 @@ export default StyleSheet.create({
|
|
|
11
15
|
fontSize: scaleSize(18),
|
|
12
16
|
lineHeight: scaleSize(26),
|
|
13
17
|
},
|
|
14
|
-
|
|
18
|
+
section_medium: {
|
|
15
19
|
fontSize: scaleSize(20),
|
|
16
20
|
lineHeight: scaleSize(28),
|
|
17
21
|
},
|
|
22
|
+
section_small: {
|
|
23
|
+
fontSize: scaleSize(16),
|
|
24
|
+
lineHeight: scaleSize(22),
|
|
25
|
+
},
|
|
18
26
|
section_large: {
|
|
19
27
|
fontSize: scaleSize(24),
|
|
20
28
|
lineHeight: scaleSize(34),
|
|
21
29
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
actionIcon: {
|
|
31
|
+
borderRadius: Radius.M,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
25
34
|
},
|
|
26
|
-
|
|
27
|
-
marginRight: Spacing.
|
|
35
|
+
icon: {
|
|
36
|
+
marginRight: Spacing.S,
|
|
37
|
+
borderRadius: Radius.XS,
|
|
28
38
|
},
|
|
29
|
-
|
|
39
|
+
wrapper: {
|
|
30
40
|
flexDirection: 'row',
|
|
41
|
+
},
|
|
42
|
+
margin: {
|
|
43
|
+
marginTop: Spacing.S,
|
|
44
|
+
},
|
|
45
|
+
iconView: {
|
|
46
|
+
marginRight: Spacing.S,
|
|
47
|
+
},
|
|
48
|
+
iconRight: {
|
|
49
|
+
width: scaleSize(22),
|
|
50
|
+
height: scaleSize(22),
|
|
51
|
+
borderRadius: Radius.M,
|
|
31
52
|
alignItems: 'center',
|
|
32
|
-
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
marginLeft: Spacing.S,
|
|
33
55
|
},
|
|
34
|
-
|
|
56
|
+
iconLeft: {
|
|
57
|
+
width: scaleSize(18),
|
|
58
|
+
height: scaleSize(18),
|
|
35
59
|
borderRadius: Radius.M,
|
|
36
60
|
alignItems: 'center',
|
|
37
61
|
justifyContent: 'center',
|
|
62
|
+
marginHorizontal: Spacing.XS,
|
|
38
63
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
iconLeftView: {
|
|
65
|
+
flexDirection: 'row',
|
|
66
|
+
alignItems: 'center',
|
|
42
67
|
},
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
contentView: {marginRight: Spacing.S, flex: 1},
|
|
69
|
+
title: {
|
|
70
|
+
fontWeight: 'bold',
|
|
71
|
+
color: Colors.black_17,
|
|
72
|
+
},
|
|
73
|
+
badge: {
|
|
74
|
+
marginLeft: Spacing.XS,
|
|
75
|
+
},
|
|
76
|
+
description: {
|
|
77
|
+
marginTop: Spacing.XS,
|
|
45
78
|
},
|
|
46
79
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
1
3
|
export type TitleProps = {
|
|
2
|
-
type?: '
|
|
4
|
+
type?: 'card' | 'section';
|
|
5
|
+
size?: 'small' | 'medium' | 'large';
|
|
3
6
|
title: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
size?: 'large' | 'small';
|
|
6
7
|
icon?: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
description?: string;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
iconAlign?: 'top' | 'middle' | 'bottom';
|
|
11
|
+
showRightAction?: boolean;
|
|
12
|
+
showTrailingAction?: boolean;
|
|
13
|
+
badgeLabel?: string;
|
|
14
|
+
buttonTitle?: string;
|
|
15
|
+
buttonSize?: 'small' | 'large';
|
|
16
|
+
onPressRightAction?: () => void;
|
|
17
|
+
onPressTrailingAction?: () => void;
|
|
18
|
+
textOnly?: boolean;
|
|
19
|
+
style?: ViewStyle;
|
|
11
20
|
};
|
package/code-scanner.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const scanner = require('react-scanner');
|
|
2
|
+
const fs = require('fs');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
|
|
4
5
|
const scan = async config => {
|
|
@@ -9,43 +10,151 @@ const calcSum = array => {
|
|
|
9
10
|
return array.reduce((a, b) => a + b, 0);
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
const calculateAdoptionRate = (
|
|
13
|
+
const calculateAdoptionRate = async (
|
|
14
|
+
branchName,
|
|
15
|
+
kitJsonPath,
|
|
16
|
+
miniappJsonPath,
|
|
17
|
+
reactNativeJsonPath,
|
|
18
|
+
fsJsonPath,
|
|
19
|
+
) => {
|
|
13
20
|
const kitJson = require(kitJsonPath);
|
|
14
21
|
const miniAppJson = require(miniappJsonPath);
|
|
22
|
+
const reactNativeJson = require(reactNativeJsonPath);
|
|
23
|
+
const fsJson = require(fsJsonPath);
|
|
24
|
+
|
|
15
25
|
const numOfKitComponents = calcSum(Object.values(kitJson));
|
|
16
26
|
const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
|
|
28
|
+
const numOfFSComponents = calcSum(Object.values(fsJson));
|
|
29
|
+
|
|
30
|
+
const adoptionRate =
|
|
31
|
+
((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) /
|
|
32
|
+
numOfMiniAppComponents) *
|
|
33
|
+
100;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
miniAppName: branchName,
|
|
37
|
+
numOfKitComponents: numOfKitComponents,
|
|
38
|
+
numOfMiniAppComponents: numOfMiniAppComponents,
|
|
39
|
+
numOfReactNativeComponents: numOfReactNativeComponents,
|
|
40
|
+
numOfFSComponents: numOfFSComponents,
|
|
41
|
+
adoptionRate: adoptionRate.toFixed(2) + '%',
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function ensureFileExists(filePath, defaultContent = {}) {
|
|
46
|
+
if (!fs.existsSync(filePath)) {
|
|
47
|
+
fs.mkdirSync(path.dirname(filePath), {recursive: true});
|
|
48
|
+
fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sendMessage = ({
|
|
53
|
+
numOfKitComponents,
|
|
54
|
+
numOfMiniAppComponents,
|
|
55
|
+
numOfFSComponents,
|
|
56
|
+
numOfReactNativeComponents,
|
|
57
|
+
adoptionRate,
|
|
58
|
+
miniAppName = '',
|
|
59
|
+
}) => {
|
|
60
|
+
const url =
|
|
61
|
+
'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
|
|
62
|
+
|
|
63
|
+
const data = {
|
|
64
|
+
text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
fetch(url, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify(data),
|
|
73
|
+
})
|
|
74
|
+
.then(response => response.json())
|
|
75
|
+
.then(data => {
|
|
76
|
+
console.log('Success:', data);
|
|
77
|
+
})
|
|
78
|
+
.catch(error => {
|
|
79
|
+
console.error('Error:', error);
|
|
80
|
+
});
|
|
21
81
|
};
|
|
22
82
|
|
|
23
83
|
const main = async () => {
|
|
24
|
-
const
|
|
25
|
-
|
|
84
|
+
const rootPath = `${__dirname}/../../../`;
|
|
85
|
+
const app = path.join(`${__dirname}/../../../`, 'app.json');
|
|
86
|
+
const appJson = require(app);
|
|
87
|
+
const branchName = appJson.appId;
|
|
88
|
+
|
|
89
|
+
if (!branchName || !branchName.includes('vn.momo')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
26
92
|
|
|
27
|
-
const
|
|
28
|
-
const
|
|
93
|
+
const scanPath = path.join(rootPath, 'src');
|
|
94
|
+
const kitJsonPath = path.join(rootPath, './scan/kit.json');
|
|
95
|
+
const miniappJsonPath = path.join(rootPath, './scan/miniapp.json');
|
|
96
|
+
const reactNativeJsonPath = path.join(rootPath, './scan/RN.json');
|
|
97
|
+
const fsJsonPath = path.join(rootPath, './scan/verLib.json');
|
|
98
|
+
|
|
99
|
+
const allKitsReg = /@momo-kits/;
|
|
100
|
+
const fsReg =
|
|
101
|
+
/^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
|
|
102
|
+
const RNReg = 'react-native';
|
|
29
103
|
|
|
30
104
|
const config1 = {
|
|
31
105
|
crawlFrom: scanPath,
|
|
32
106
|
includeSubComponents: true,
|
|
33
|
-
importedFrom:
|
|
107
|
+
importedFrom: allKitsReg,
|
|
34
108
|
processors: [['count-components', {outputTo: kitJsonPath}]],
|
|
35
|
-
rootDir:
|
|
109
|
+
rootDir: process.cwd(),
|
|
36
110
|
};
|
|
37
111
|
|
|
38
112
|
const config2 = {
|
|
39
113
|
crawlFrom: scanPath,
|
|
40
114
|
includeSubComponents: true,
|
|
41
115
|
processors: [['count-components', {outputTo: miniappJsonPath}]],
|
|
42
|
-
rootDir:
|
|
116
|
+
rootDir: process.cwd(),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const config3 = {
|
|
120
|
+
crawlFrom: scanPath,
|
|
121
|
+
includeSubComponents: true,
|
|
122
|
+
importedFrom: RNReg,
|
|
123
|
+
processors: [['count-components', {outputTo: reactNativeJsonPath}]],
|
|
124
|
+
rootDir: process.cwd(),
|
|
43
125
|
};
|
|
44
126
|
|
|
45
|
-
|
|
46
|
-
|
|
127
|
+
const config4 = {
|
|
128
|
+
crawlFrom: scanPath,
|
|
129
|
+
includeSubComponents: true,
|
|
130
|
+
importedFrom: fsReg,
|
|
131
|
+
processors: [['count-components', {outputTo: fsJsonPath}]],
|
|
132
|
+
rootDir: process.cwd(),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
ensureFileExists(kitJsonPath, {});
|
|
137
|
+
ensureFileExists(miniappJsonPath, {});
|
|
138
|
+
ensureFileExists(reactNativeJsonPath, {});
|
|
139
|
+
ensureFileExists(fsJsonPath, {});
|
|
140
|
+
|
|
141
|
+
await scan(config1);
|
|
142
|
+
await scan(config2);
|
|
143
|
+
await scan(config3);
|
|
144
|
+
await scan(config4);
|
|
47
145
|
|
|
48
|
-
|
|
146
|
+
const result = await calculateAdoptionRate(
|
|
147
|
+
branchName,
|
|
148
|
+
kitJsonPath,
|
|
149
|
+
miniappJsonPath,
|
|
150
|
+
reactNativeJsonPath,
|
|
151
|
+
fsJsonPath,
|
|
152
|
+
);
|
|
153
|
+
sendMessage(result);
|
|
154
|
+
console.log(result);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('Error during scan or calculation:', error);
|
|
157
|
+
}
|
|
49
158
|
};
|
|
50
159
|
|
|
51
|
-
main()
|
|
160
|
+
main();
|
package/index.ts
CHANGED
|
@@ -47,3 +47,12 @@ export * from './Loader';
|
|
|
47
47
|
export * from './Loader/types';
|
|
48
48
|
export * from './Title';
|
|
49
49
|
export * from './Title/types';
|
|
50
|
+
export * from './Badge';
|
|
51
|
+
export * from './Badge/types';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* export trick for keep old mini app working
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
57
|
+
export * from 'react-native-modalize';
|
|
58
|
+
export * from '@gorhom/bottom-sheet';
|