@momo-kits/foundation 1.0.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.
Files changed (51) hide show
  1. package/Assets/header-background.png +0 -0
  2. package/Button/index.tsx +307 -0
  3. package/Button/styles.ts +41 -0
  4. package/Button/types.ts +18 -0
  5. package/CheckBox/index.js +74 -0
  6. package/CheckBox/styles.js +3 -0
  7. package/Consts/colors+spacing+radius.ts +162 -0
  8. package/Consts/index.ts +76 -0
  9. package/Consts/styles.ts +137 -0
  10. package/ContentLoader/index.tsx +71 -0
  11. package/ContentLoader/styles.ts +5 -0
  12. package/ContentLoader/types.ts +3 -0
  13. package/Divider/index.js +43 -0
  14. package/Divider/styles.js +10 -0
  15. package/Icon/icon.json +3935 -0
  16. package/Icon/index.tsx +30 -0
  17. package/Icon/types.ts +8 -0
  18. package/IconButton/index.tsx +127 -0
  19. package/IconButton/types.ts +17 -0
  20. package/Image/index.tsx +67 -0
  21. package/Image/styles.ts +13 -0
  22. package/Image/types.ts +6 -0
  23. package/Layout/Row.tsx +42 -0
  24. package/Layout/Screen.tsx +68 -0
  25. package/Layout/Section.tsx +30 -0
  26. package/Layout/View.tsx +84 -0
  27. package/Layout/index.ts +6 -0
  28. package/Layout/styles.ts +24 -0
  29. package/Layout/types.ts +39 -0
  30. package/Layout/utils.ts +37 -0
  31. package/Navigation/Components.tsx +55 -0
  32. package/Navigation/ModalScreen.tsx +177 -0
  33. package/Navigation/Navigation.ts +34 -0
  34. package/Navigation/NavigationButton.tsx +25 -0
  35. package/Navigation/NavigationContainer.tsx +74 -0
  36. package/Navigation/Navigator.ts +45 -0
  37. package/Navigation/ScreenContainer.tsx +38 -0
  38. package/Navigation/StackScreen.tsx +19 -0
  39. package/Navigation/index.ts +10 -0
  40. package/Navigation/types.ts +87 -0
  41. package/Navigation/utils.tsx +84 -0
  42. package/SizedBox/index.js +23 -0
  43. package/SizedBox/styles.js +7 -0
  44. package/Text/index.tsx +164 -0
  45. package/Text/styles.ts +34 -0
  46. package/Text/types.ts +47 -0
  47. package/TextInput/index.js +225 -0
  48. package/TextInput/styles.js +55 -0
  49. package/index.ts +18 -0
  50. package/package.json +41 -0
  51. package/publish.sh +26 -0
Binary file
@@ -0,0 +1,307 @@
1
+ import React, {useContext} from 'react';
2
+ import {
3
+ ActivityIndicator,
4
+ StyleSheet,
5
+ TouchableOpacity,
6
+ View,
7
+ } from 'react-native';
8
+ import {NavigationContext, Colors, Styles, Text} from '../index';
9
+ import styles from './styles';
10
+
11
+ const Index = props => {
12
+ const {theme} = useContext(NavigationContext);
13
+ const {
14
+ style,
15
+ textStyle,
16
+ type,
17
+ size,
18
+ full,
19
+ disabled,
20
+ leading,
21
+ trailing,
22
+ loading,
23
+ children,
24
+ } = props;
25
+
26
+ /**
27
+ * export size style
28
+ */
29
+ const getSizeStyle = () => {
30
+ switch (size) {
31
+ case 'large':
32
+ return styles.large;
33
+ case 'medium':
34
+ return styles.medium;
35
+ case 'small':
36
+ return styles.small;
37
+
38
+ default:
39
+ return styles.large;
40
+ }
41
+ };
42
+
43
+ /**
44
+ * export type style
45
+ */
46
+ const getTypeStyle = () => {
47
+ if (disabled) {
48
+ return {
49
+ backgroundColor: theme.colors.border,
50
+ };
51
+ }
52
+ switch (type) {
53
+ case 'primary':
54
+ return {backgroundColor: theme.colors.primary};
55
+ case 'secondary':
56
+ return {
57
+ backgroundColor: theme.colors.card,
58
+ borderWidth: 1,
59
+ borderColor: theme.colors.border,
60
+ };
61
+ case 'outline':
62
+ return {
63
+ backgroundColor: theme.colors.card,
64
+ borderWidth: 1,
65
+ borderColor: theme.colors.primary,
66
+ };
67
+ case 'text':
68
+ return {};
69
+
70
+ default:
71
+ return {backgroundColor: theme.colors.primary};
72
+ }
73
+ };
74
+
75
+ /**
76
+ * export loading color
77
+ */
78
+ const getLoadingColor = () => {
79
+ if (disabled) {
80
+ return theme.colors.textSecondary;
81
+ }
82
+ switch (type) {
83
+ case 'primary':
84
+ return Colors.black_01;
85
+ case 'secondary':
86
+ return theme.colors.text;
87
+ case 'outline':
88
+ return theme.colors.primary;
89
+ case 'text':
90
+ return theme.colors.primary;
91
+ default:
92
+ return theme.colors.primary;
93
+ }
94
+ };
95
+
96
+ /**
97
+ * export icon size
98
+ */
99
+ const getIconSize = () => {
100
+ switch (size) {
101
+ case 'large':
102
+ return 24;
103
+ case 'medium':
104
+ case 'small':
105
+ return 16;
106
+
107
+ default:
108
+ return 24;
109
+ }
110
+ };
111
+
112
+ /**
113
+ * export icon size
114
+ */
115
+ const getIconSpace = () => {
116
+ switch (size) {
117
+ case 'large':
118
+ case 'medium':
119
+ return 8;
120
+ case 'small':
121
+ return 4;
122
+
123
+ default:
124
+ return 8;
125
+ }
126
+ };
127
+
128
+ /**
129
+ * export typography style
130
+ */
131
+ const getTypography = () => {
132
+ switch (size) {
133
+ case 'large':
134
+ return 'h4';
135
+ case 'medium':
136
+ return 'title';
137
+ case 'small':
138
+ return 'subtitle';
139
+
140
+ default:
141
+ return 'h4';
142
+ }
143
+ };
144
+
145
+ /**
146
+ * render Text
147
+ */
148
+ const renderText = () => {
149
+ const typography = getTypography();
150
+ if (disabled) {
151
+ return (
152
+ <Text
153
+ typography={typography}
154
+ weight="bold"
155
+ type="secondary"
156
+ numberOfLines={1}
157
+ style={textStyle}>
158
+ {children}
159
+ </Text>
160
+ );
161
+ }
162
+ switch (type) {
163
+ case 'primary':
164
+ return (
165
+ <Text
166
+ typography={typography}
167
+ weight="bold"
168
+ color="white"
169
+ numberOfLines={1}
170
+ style={textStyle}>
171
+ {children}
172
+ </Text>
173
+ );
174
+ case 'secondary':
175
+ return (
176
+ <Text
177
+ typography={typography}
178
+ weight="bold"
179
+ numberOfLines={1}
180
+ style={textStyle}>
181
+ {children}
182
+ </Text>
183
+ );
184
+ case 'outline':
185
+ return (
186
+ <Text
187
+ typography={typography}
188
+ weight="bold"
189
+ color="primary"
190
+ numberOfLines={1}
191
+ style={textStyle}>
192
+ {children}
193
+ </Text>
194
+ );
195
+ case 'text':
196
+ return (
197
+ <Text
198
+ typography={typography}
199
+ type="secondary"
200
+ weight="bold"
201
+ numberOfLines={1}
202
+ style={textStyle}>
203
+ {children}
204
+ </Text>
205
+ );
206
+
207
+ default:
208
+ return (
209
+ <Text
210
+ typography={typography}
211
+ weight="bold"
212
+ numberOfLines={1}
213
+ style={textStyle}>
214
+ {children}
215
+ </Text>
216
+ );
217
+ }
218
+ };
219
+
220
+ /**
221
+ * render leading
222
+ */
223
+ const renderLeading = () => {
224
+ if (leading) {
225
+ const iconSize = getIconSize();
226
+ const marginRight = getIconSpace();
227
+ return (
228
+ <View
229
+ style={[
230
+ styles.leading,
231
+ {width: iconSize, height: iconSize, marginRight},
232
+ ]}>
233
+ {leading}
234
+ </View>
235
+ );
236
+ }
237
+ };
238
+
239
+ /**
240
+ * render trailing
241
+ */
242
+ const renderTrailing = () => {
243
+ const marginLeft = getIconSpace();
244
+ if (loading) {
245
+ return (
246
+ <View style={[styles.trailing, {marginLeft}]}>
247
+ <View style={Styles.flexCenter}>
248
+ <ActivityIndicator color={getLoadingColor()} />
249
+ </View>
250
+ </View>
251
+ );
252
+ }
253
+ if (trailing) {
254
+ const iconSize = getIconSize();
255
+ return (
256
+ <View
257
+ style={[
258
+ styles.trailing,
259
+ {width: iconSize, height: iconSize, marginLeft},
260
+ ]}>
261
+ {trailing}
262
+ </View>
263
+ );
264
+ }
265
+ };
266
+
267
+ const buttonStyle = StyleSheet.flatten([
268
+ getSizeStyle(),
269
+ getTypeStyle(),
270
+ full && {width: '100%'},
271
+ style,
272
+ ]);
273
+
274
+ return (
275
+ <TouchableOpacity {...props} style={buttonStyle}>
276
+ {renderLeading()}
277
+ {renderText()}
278
+ {renderTrailing()}
279
+ </TouchableOpacity>
280
+ );
281
+ };
282
+
283
+ // Index.propTypes = {
284
+ // textStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
285
+ // type: PropTypes.oneOf(['primary', 'secondary','' ,'outline', 'text']),
286
+ // size: PropTypes.oneOf(['large', 'medium', 'small']),
287
+ // full: PropTypes.bool,
288
+ // disabled: PropTypes.bool,
289
+ // leading: PropTypes.element,
290
+ // trailing: PropTypes.element,
291
+ // loading: PropTypes.bool,
292
+ // children: PropTypes.string,
293
+ // };
294
+
295
+ Index.defaultProps = {
296
+ textStyle: {},
297
+ type: 'primary',
298
+ size: 'large',
299
+ full: true,
300
+ disabled: false,
301
+ leading: null,
302
+ trailing: null,
303
+ loading: false,
304
+ children: 'Button',
305
+ };
306
+
307
+ export default Index;
@@ -0,0 +1,41 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ large: {
5
+ height: 48,
6
+ borderRadius: 8,
7
+ flexDirection: 'row',
8
+ justifyContent: 'center',
9
+ alignItems: 'center',
10
+ paddingHorizontal: 16,
11
+ minWidth: 128,
12
+ },
13
+ medium: {
14
+ height: 36,
15
+ borderRadius: 8,
16
+ flexDirection: 'row',
17
+ justifyContent: 'center',
18
+ alignItems: 'center',
19
+ paddingHorizontal: 12,
20
+ minWidth: 80,
21
+ },
22
+ small: {
23
+ height: 28,
24
+ borderRadius: 6,
25
+ flexDirection: 'row',
26
+ justifyContent: 'center',
27
+ alignItems: 'center',
28
+ paddingHorizontal: 8,
29
+ minWidth: 60,
30
+ },
31
+ leading: {
32
+ overflow: 'hidden',
33
+ alignItems: 'center',
34
+ justifyContent: 'center',
35
+ },
36
+ trailing: {
37
+ overflow: 'hidden',
38
+ alignItems: 'center',
39
+ justifyContent: 'center',
40
+ },
41
+ });
@@ -0,0 +1,18 @@
1
+ import {
2
+ TouchableNativeFeedbackProps,
3
+ TouchableOpacityProps,
4
+ } from 'react-native';
5
+
6
+ export type ButtonType =
7
+ | 'primary'
8
+ | 'secondary'
9
+ | 'tonal'
10
+ | 'outline'
11
+ | 'disable'
12
+ | 'text';
13
+
14
+ export type ButtonSize = 'large' | 'medium' | 'small';
15
+
16
+ export interface ButtonProps
17
+ extends TouchableOpacityProps,
18
+ TouchableNativeFeedbackProps {}
@@ -0,0 +1,74 @@
1
+ import React, {useContext} from 'react';
2
+ import {TouchableOpacity} from 'react-native';
3
+ import PropTypes from 'prop-types';
4
+ import {ApplicationContext, Index} from '@components';
5
+
6
+ const Index = props => {
7
+ const {theme} = useContext(ApplicationContext);
8
+ const {style, value, disabled, size, shape, onPress} = props;
9
+
10
+ /**
11
+ * export icon name
12
+ */
13
+ const getIconName = () => {
14
+ switch (shape) {
15
+ case 'circle':
16
+ if (value) {
17
+ return 'checkbox-marked-circle';
18
+ }
19
+ return 'checkbox-blank-circle-outline';
20
+ case 'rectangle':
21
+ if (value) {
22
+ return 'checkbox-marked';
23
+ }
24
+ return 'checkbox-blank-outline';
25
+
26
+ default:
27
+ return 'checkbox-blank-outline';
28
+ }
29
+ };
30
+
31
+ /**
32
+ * export icon color
33
+ */
34
+ const getIconColor = () => {
35
+ if (disabled) {
36
+ return theme.colors.textSecondary;
37
+ }
38
+ if (value) {
39
+ return theme.colors.primary;
40
+ }
41
+ return theme.colors.text;
42
+ };
43
+
44
+ return (
45
+ <TouchableOpacity disabled={disabled} onPress={onPress}>
46
+ <Index
47
+ name={getIconName()}
48
+ size={size}
49
+ color={getIconColor()}
50
+ style={style}
51
+ />
52
+ </TouchableOpacity>
53
+ );
54
+ };
55
+
56
+ Index.propTypes = {
57
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
58
+ value: PropTypes.bool,
59
+ disabled: PropTypes.bool,
60
+ size: PropTypes.number,
61
+ onPress: PropTypes.func,
62
+ shape: PropTypes.oneOf(['circle', 'rectangle']),
63
+ };
64
+
65
+ Index.defaultProps = {
66
+ style: {},
67
+ value: false,
68
+ disabled: false,
69
+ size: 24,
70
+ onPress: () => {},
71
+ shape: 'circle',
72
+ };
73
+
74
+ export default Index;
@@ -0,0 +1,3 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ export default StyleSheet.create({});
@@ -0,0 +1,162 @@
1
+ const Colors = {
2
+ black_01: '#ffffff',
3
+ black_02: '#f9f9f9',
4
+ black_03: '#f0f0f0',
5
+ black_04: '#e8e8e8',
6
+ black_05: '#e5e5e5',
7
+ black_06: '#d8d8d8',
8
+ black_07: '#cccccc',
9
+ black_08: '#c6c6c6',
10
+ black_09: '#b9b9b9',
11
+ black_10: '#a0a0a0',
12
+ black_11: '#878787',
13
+ black_12: '#727272',
14
+ black_13: '#646464',
15
+ black_14: '#565656',
16
+ black_15: '#484848',
17
+ black_16: '#404040',
18
+ black_17: '#303233',
19
+ black_18: '#242424',
20
+ black_19: '#18191a',
21
+ black_20: '#000000',
22
+ pink_01: '#bc2678',
23
+ pink_02: '#d42a87',
24
+ pink_03: '#eb2f96',
25
+ pink_04: '#ed43a0',
26
+ pink_05: '#ef59ab',
27
+ pink_06: '#f382c0',
28
+ pink_07: '#f7acd5',
29
+ pink_08: '#fbd5ea',
30
+ pink_09: '#fdeaf4',
31
+ pink_10: '#fef4fa',
32
+ pink_11: '#fef8fc',
33
+ pink_MoMo_Branding: '#a50064',
34
+ violet_01: '#7822c0',
35
+ violet_02: '#8726d8',
36
+ violet_03: '#962af0',
37
+ violet_04: '#a03ff1',
38
+ violet_05: '#ab55f3',
39
+ violet_06: '#c07ff6',
40
+ violet_07: '#d5aaf9',
41
+ violet_08: '#ead4fc',
42
+ violet_09: '#f4e9fd',
43
+ violet_10: '#faf4fe',
44
+ violet_11: '#fcf8fe',
45
+ violet_11_stroke: '#dfe1e5',
46
+ indigo_01: '#3e3ccc',
47
+ indigo_02: '#4644e6',
48
+ indigo_03: '#4e4bff',
49
+ indigo_04: '#5f5dff',
50
+ indigo_05: '#716fff',
51
+ indigo_06: '#9593ff',
52
+ indigo_07: '#b8b7ff',
53
+ indigo_08: '#dcdbff',
54
+ indigo_09: '#ededff',
55
+ indigo_10: '#f6f6ff',
56
+ indigo_11: '#f9f9ff',
57
+ blue_01: '#0062cc',
58
+ blue_02: '#006ee6',
59
+ blue_03: '#007aff',
60
+ blue_04: '#1987ff',
61
+ blue_05: '#3395ff',
62
+ blue_06: '#66afff',
63
+ blue_07: '#99caff',
64
+ blue_08: '#cce4ff',
65
+ blue_09: '#e5f1ff',
66
+ blue_10: '#f2f8ff',
67
+ blue_11: '#f7fbff',
68
+ mint_01: '#0f9b9b',
69
+ mint_02: '#11afaf',
70
+ mint_03: '#13c2c2',
71
+ mint_04: '#2ac8c8',
72
+ mint_05: '#42cece',
73
+ mint_06: '#71dada',
74
+ mint_07: '#a1e7e7',
75
+ mint_08: '#d0f3f3',
76
+ mint_09: '#e7f8f8',
77
+ mint_10: '#f3fcfc',
78
+ mint_11: '#f8fdfd',
79
+ green_01: '#2a9f47',
80
+ green_02: '#2fb350',
81
+ green_03: '#34c759',
82
+ green_04: '#48cc69',
83
+ green_05: '#5dd27a',
84
+ green_06: '#85dd9b',
85
+ green_07: '#aee9bd',
86
+ green_08: '#d6f4de',
87
+ green_09: '#eaf9ee',
88
+ green_10: '#f5fcf6',
89
+ green_11: '#f9fdfa',
90
+ lime_01: '#80ae0e',
91
+ lime_02: '#90c30f',
92
+ lime_03: '#a0d911',
93
+ lime_04: '#a9dc28',
94
+ lime_05: '#b3e141',
95
+ lime_06: '#c6e870',
96
+ lime_07: '#d9f0a0',
97
+ lime_08: '#ecf7cf',
98
+ lime_09: '#f5fbe7',
99
+ lime_10: '#fafdf3',
100
+ lime_11: '#fcfef8',
101
+ yellow_01: '#cca300',
102
+ yellow_02: '#e6b800',
103
+ yellow_03: '#ffcc00',
104
+ yellow_04: '#ffd119',
105
+ yellow_05: '#ffd633',
106
+ yellow_06: '#ffe066',
107
+ yellow_07: '#ffeb99',
108
+ yellow_08: '#fff5cc',
109
+ yellow_09: '#fff9e5',
110
+ yellow_10: '#fffcf2',
111
+ yellow_11: '#fffdf7',
112
+ gold_01: '#c87012',
113
+ gold_02: '#e17e14',
114
+ gold_03: '#fa8c16',
115
+ gold_04: '#fa972d',
116
+ gold_05: '#fba345',
117
+ gold_06: '#fcba73',
118
+ gold_07: '#fdd1a2',
119
+ gold_08: '#fee8d0',
120
+ gold_09: '#fef3e7',
121
+ gold_10: '#fff9f3',
122
+ gold_11: '#fefbf8',
123
+ orange_01: '#c84316',
124
+ orange_02: '#e14c19',
125
+ orange_03: '#fa541c',
126
+ orange_04: '#fa6532',
127
+ orange_05: '#fb7649',
128
+ orange_06: '#fc9877',
129
+ orange_07: '#fdbba4',
130
+ orange_08: '#feddd2',
131
+ orange_09: '#feede8',
132
+ orange_10: '#fff6f3',
133
+ orange_11: '#fefaf8',
134
+ red_01: '#c41b24',
135
+ red_02: '#dd1f29',
136
+ red_03: '#f5222d',
137
+ red_04: '#f63842',
138
+ red_05: '#f74e57',
139
+ red_06: '#f97a81',
140
+ red_07: '#fba7ab',
141
+ red_08: '#fdd3d5',
142
+ red_09: '#fee8ea',
143
+ red_10: '#fef4f4',
144
+ red_11: '#fef8f8',
145
+ };
146
+ const Spacing = {
147
+ XS: 2,
148
+ S: 4,
149
+ M: 12,
150
+ L: 16,
151
+ XL: 24,
152
+ };
153
+
154
+ const Radius = {
155
+ XS: 2,
156
+ S: 4,
157
+ M: 12,
158
+ L: 16,
159
+ XL: 24,
160
+ };
161
+
162
+ export {Colors, Spacing, Radius};
@@ -0,0 +1,76 @@
1
+ import {Context, Theme} from '../Navigation/types';
2
+
3
+ const defaultTheme: Theme = {
4
+ dark: false,
5
+ colors: {
6
+ background_default: '',
7
+ background_surface: '',
8
+ background_pressed: '',
9
+ background_selected: '',
10
+ background_disable: '',
11
+ background_primary: '',
12
+ background_tonal: '',
13
+ text_default: '',
14
+ text_secondary: '',
15
+ text_hint: '',
16
+ text_disable: '',
17
+ text_white: '',
18
+ text_primary: '',
19
+ text_interactive: '',
20
+ text_highlight: '',
21
+ text_success: '',
22
+ text_warning: '',
23
+ text_error: '',
24
+ border_default: '',
25
+ border_disable: '',
26
+ border_primary: '',
27
+ border_primary_disable: '',
28
+ border_error: '',
29
+ border_error_disable: '',
30
+ border_success: '',
31
+ border_success_disable: '',
32
+ },
33
+ font: 'SFProText',
34
+ };
35
+
36
+ const defaultDarkTheme: Theme = {
37
+ dark: true,
38
+ colors: {
39
+ background_default: '',
40
+ background_surface: '',
41
+ background_pressed: '',
42
+ background_selected: '',
43
+ background_disable: '',
44
+ background_primary: '',
45
+ background_tonal: '',
46
+ text_default: '',
47
+ text_secondary: '',
48
+ text_hint: '',
49
+ text_disable: '',
50
+ text_white: '',
51
+ text_primary: '',
52
+ text_interactive: '',
53
+ text_highlight: '',
54
+ text_success: '',
55
+ text_warning: '',
56
+ text_error: '',
57
+ border_default: '',
58
+ border_disable: '',
59
+ border_primary: '',
60
+ border_primary_disable: '',
61
+ border_error: '',
62
+ border_error_disable: '',
63
+ border_success: '',
64
+ border_success_disable: '',
65
+ },
66
+ font: 'Raleway',
67
+ };
68
+
69
+ const defaultContext: Context = {
70
+ theme: defaultTheme,
71
+ navigator: undefined,
72
+ };
73
+
74
+ export {defaultContext, defaultTheme, defaultDarkTheme};
75
+ export * from './colors+spacing+radius';
76
+ export * from './styles';