@momo-kits/foundation 0.75.1-beta.3

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 (76) hide show
  1. package/Assets/header-background.png +0 -0
  2. package/Assets/icon.json +3947 -0
  3. package/Button/index.tsx +247 -0
  4. package/Button/styles.ts +41 -0
  5. package/CheckBox/index.tsx +61 -0
  6. package/CheckBox/styles.ts +15 -0
  7. package/CheckBox/types.ts +10 -0
  8. package/Consts/colors+spacing+radius.ts +214 -0
  9. package/Consts/index.ts +3 -0
  10. package/Consts/styles.ts +78 -0
  11. package/Consts/theme.ts +121 -0
  12. package/Divider/index.tsx +19 -0
  13. package/Icon/index.tsx +37 -0
  14. package/Icon/types.ts +8 -0
  15. package/IconButton/index.tsx +128 -0
  16. package/IconButton/styles.ts +19 -0
  17. package/Image/index.tsx +80 -0
  18. package/Image/styles.ts +13 -0
  19. package/Image/types.ts +3 -0
  20. package/Input/Input.tsx +142 -0
  21. package/Input/InputMoney.tsx +132 -0
  22. package/Input/InputSearch.tsx +161 -0
  23. package/Input/InputTextArea.tsx +152 -0
  24. package/Input/common.tsx +125 -0
  25. package/Input/index.tsx +41 -0
  26. package/Input/styles.ts +122 -0
  27. package/Input/utils.ts +63 -0
  28. package/Layout/Card.tsx +87 -0
  29. package/Layout/GridSystem.tsx +124 -0
  30. package/Layout/ScreenContainer.tsx +122 -0
  31. package/Layout/Section.tsx +143 -0
  32. package/Layout/index.ts +16 -0
  33. package/Layout/types.ts +21 -0
  34. package/Layout/utils.ts +50 -0
  35. package/Navigation/BottomTab.tsx +39 -0
  36. package/Navigation/Components.tsx +329 -0
  37. package/Navigation/ModalScreen.tsx +207 -0
  38. package/Navigation/Navigation.ts +38 -0
  39. package/Navigation/NavigationButton.tsx +54 -0
  40. package/Navigation/NavigationContainer.tsx +82 -0
  41. package/Navigation/Navigator.ts +66 -0
  42. package/Navigation/Observer.ts +79 -0
  43. package/Navigation/StackScreen.tsx +40 -0
  44. package/Navigation/index.ts +14 -0
  45. package/Navigation/types.ts +149 -0
  46. package/Navigation/utils.tsx +167 -0
  47. package/Pagination/Dot.tsx +16 -0
  48. package/Pagination/PaginationDot.tsx +33 -0
  49. package/Pagination/PaginationNumber.tsx +23 -0
  50. package/Pagination/PaginationScroll.tsx +88 -0
  51. package/Pagination/PaginationWhiteDot.tsx +32 -0
  52. package/Pagination/index.tsx +25 -0
  53. package/Pagination/styles.ts +47 -0
  54. package/Pagination/types.ts +19 -0
  55. package/Popup/PopupNotify.tsx +215 -0
  56. package/Popup/PopupPromotion.tsx +77 -0
  57. package/Popup/index.tsx +4 -0
  58. package/Popup/types.ts +22 -0
  59. package/Radio/index.tsx +65 -0
  60. package/Radio/styles.ts +11 -0
  61. package/Radio/types.ts +10 -0
  62. package/Skeleton/index.tsx +72 -0
  63. package/Skeleton/styles.ts +5 -0
  64. package/Skeleton/types.ts +3 -0
  65. package/Switch/index.tsx +40 -0
  66. package/Switch/styles.ts +23 -0
  67. package/Switch/types.ts +8 -0
  68. package/Tag/index.tsx +79 -0
  69. package/Tag/styles.ts +24 -0
  70. package/Tag/types.ts +10 -0
  71. package/Text/index.tsx +110 -0
  72. package/Text/styles.ts +35 -0
  73. package/Text/types.ts +40 -0
  74. package/index.ts +38 -0
  75. package/package.json +41 -0
  76. package/publish.sh +26 -0
package/Tag/index.tsx ADDED
@@ -0,0 +1,79 @@
1
+ import React, {FC} from 'react';
2
+ import {View} from 'react-native';
3
+ import {TagProps} from './types';
4
+ import styles from './styles';
5
+ import {Colors} from '../Consts';
6
+ import {Icon} from '../Icon';
7
+ import {Text} from '../Text';
8
+
9
+ const backgroundColor = {
10
+ default: Colors.black_04,
11
+ orange: Colors.orange_08,
12
+ green: Colors.green_08,
13
+ red: Colors.red_08,
14
+ blue: Colors.blue_08,
15
+ grey: Colors.black_04,
16
+ };
17
+
18
+ const textColor = {
19
+ default: Colors.black_17,
20
+ orange: Colors.orange_03,
21
+ green: Colors.green_03,
22
+ red: Colors.red_03,
23
+ blue: Colors.blue_03,
24
+ grey: Colors.black_12,
25
+ };
26
+
27
+ const Tag: FC<TagProps> = ({
28
+ label = 'Label',
29
+ icon,
30
+ color = 'default',
31
+ size = 'large',
32
+ style,
33
+ customColor,
34
+ }) => {
35
+ let labelColor = textColor[color];
36
+ let tagColor = backgroundColor[color];
37
+ let sizeStyle = styles.mediumContainer;
38
+ //Check if custom color is [color]_03 (only check in dev mode)
39
+ const validateCustomColor = (color: string) => {
40
+ if (__DEV__) {
41
+ const colorCore: {[key: string]: string} = Colors;
42
+ const primaryColors = Object.keys(Colors)
43
+ .map(i => {
44
+ if (i.includes('_03')) {
45
+ return colorCore[i];
46
+ }
47
+ })
48
+ .filter(color => color);
49
+ return primaryColors.includes(color);
50
+ }
51
+ return true;
52
+ };
53
+
54
+ if (size === 'large') {
55
+ sizeStyle = styles.container;
56
+ }
57
+ if (customColor && validateCustomColor(customColor)) {
58
+ labelColor = Colors.black_01;
59
+ tagColor = customColor;
60
+ }
61
+
62
+ return (
63
+ <View style={[style, sizeStyle, {backgroundColor: tagColor}]}>
64
+ {!!icon && (
65
+ <Icon
66
+ style={styles.icon}
67
+ size={16}
68
+ source={icon as string}
69
+ color={labelColor}
70
+ />
71
+ )}
72
+ <Text color={labelColor} typography={'label_s'}>
73
+ {label}
74
+ </Text>
75
+ </View>
76
+ );
77
+ };
78
+
79
+ export {Tag};
package/Tag/styles.ts ADDED
@@ -0,0 +1,24 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {Radius, Spacing} from '../Consts';
3
+
4
+ export default StyleSheet.create({
5
+ container: {
6
+ paddingHorizontal: Spacing.S,
7
+ borderRadius: Radius.S,
8
+ flexDirection: 'row',
9
+ height: 24,
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ },
13
+ mediumContainer: {
14
+ paddingHorizontal: Spacing.S,
15
+ borderRadius: Radius.S,
16
+ height: 18,
17
+ alignItems: 'center',
18
+ flexDirection: 'row',
19
+ justifyContent: 'center',
20
+ },
21
+ icon: {
22
+ marginRight: Spacing.XS,
23
+ },
24
+ });
package/Tag/types.ts ADDED
@@ -0,0 +1,10 @@
1
+ import {ViewStyle} from 'react-native';
2
+
3
+ export type TagProps = {
4
+ label: string;
5
+ size?: 'medium' | 'large';
6
+ icon?: string;
7
+ color?: 'default' | 'orange' | 'green' | 'red' | 'blue' | 'grey';
8
+ style?: ViewStyle;
9
+ customColor?: string;
10
+ };
package/Text/index.tsx ADDED
@@ -0,0 +1,110 @@
1
+ import React, {useContext} from 'react';
2
+ import {Text as RNText, TextProps as RNTextProps} from 'react-native';
3
+ import styles from './styles';
4
+ import {Typography, TypographyWeight} from './types';
5
+ import {ApplicationContext} from '../Navigation';
6
+ import {GridContext} from '../Layout';
7
+
8
+ const SFProText: TypographyWeight = {
9
+ 100: 'Thin',
10
+ 200: 'Ultralight',
11
+ 300: 'Light',
12
+ 400: 'Regular',
13
+ 500: 'Medium',
14
+ 600: 'Semibold',
15
+ 700: 'Bold',
16
+ 800: 'Heavy',
17
+ 900: 'Black',
18
+ normal: 'Regular',
19
+ bold: 'Bold',
20
+ };
21
+
22
+ const AlegreyaSans: TypographyWeight = {
23
+ 100: 'Thin',
24
+ 200: 'Thin',
25
+ 300: 'Thin',
26
+ 400: 'Regular',
27
+ 500: 'Medium',
28
+ 600: 'Medium',
29
+ 700: 'Bold',
30
+ 800: 'Black',
31
+ 900: 'Black',
32
+ normal: 'Regular',
33
+ bold: 'Bold',
34
+ };
35
+
36
+ const FontStyle: {[key: string]: string} = {
37
+ italic: 'Italic',
38
+ normal: '',
39
+ };
40
+
41
+ export interface TextProps extends RNTextProps {
42
+ typography: Typography;
43
+ color?: string;
44
+ widthSpan?: number;
45
+ }
46
+
47
+ const Text: React.FC<TextProps> = ({
48
+ typography,
49
+ color,
50
+ children,
51
+ style,
52
+ widthSpan,
53
+ ...rest
54
+ }) => {
55
+ const grid = useContext(GridContext);
56
+ const {theme} = useContext(ApplicationContext);
57
+
58
+ const getTypoStyle = (typo: Typography) => {
59
+ const styleSheet: {
60
+ [key: string]: any;
61
+ } = styles;
62
+ const typoStyle = styleSheet[typo] ?? styleSheet.paragraph_default;
63
+ const {fontWeight, fontSize, fontStyle, lineHeight} = typoStyle;
64
+ const style = FontStyle[fontStyle ?? 'normal'];
65
+ let fontFamily: string;
66
+
67
+ switch (theme.font) {
68
+ case 'SFProText': {
69
+ fontFamily = `${theme.font}-${SFProText[fontWeight]}${style}`;
70
+ break;
71
+ }
72
+ case 'AlegreyaSans': {
73
+ fontFamily = `${theme.font}-${AlegreyaSans[fontWeight]}${style}`;
74
+ break;
75
+ }
76
+ default: {
77
+ fontFamily = `SFProText-${SFProText[fontWeight]}${style}`;
78
+ }
79
+ }
80
+
81
+ return {
82
+ fontFamily,
83
+ fontSize,
84
+ lineHeight,
85
+ fontStyle,
86
+ };
87
+ };
88
+
89
+ const textStyle = getTypoStyle(typography);
90
+ const spanStyle = widthSpan ? {width: grid.getSizeSpan(widthSpan)} : {};
91
+ return (
92
+ <RNText
93
+ {...rest}
94
+ accessibilityLabel={`Text/${children}`}
95
+ style={[
96
+ style,
97
+ textStyle,
98
+ spanStyle,
99
+ {color: color ?? theme.colors.text.default},
100
+ ]}>
101
+ {children ?? ''}
102
+ </RNText>
103
+ );
104
+ };
105
+
106
+ Text.defaultProps = {
107
+ typography: 'paragraph_default',
108
+ };
109
+
110
+ export {Text};
package/Text/styles.ts ADDED
@@ -0,0 +1,35 @@
1
+ export default {
2
+ headline_default: {
3
+ fontSize: 28,
4
+ lineHeight: 34,
5
+ fontWeight: '600',
6
+ },
7
+ headline_s: {fontSize: 24, lineHeight: 32, fontWeight: '600'},
8
+ headline_l: {fontSize: 32, lineHeight: 36, fontWeight: '600'},
9
+ headline_xl: {fontSize: 36, lineHeight: 44, fontWeight: '600'},
10
+ title_default: {fontSize: 20, lineHeight: 28, fontWeight: '700'},
11
+ title_xs: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
12
+ title_s: {fontSize: 18, lineHeight: 28, fontWeight: '700'},
13
+ header_default: {fontSize: 15, lineHeight: 22, fontWeight: '600'},
14
+ header_xs: {fontSize: 12, lineHeight: 16, fontWeight: '600'},
15
+ header_s: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
16
+ paragraph_default: {fontSize: 15, lineHeight: 22, fontWeight: '400'},
17
+ paragraph_bold: {fontSize: 15, lineHeight: 22, fontWeight: '700'},
18
+ paragraph_italic: {
19
+ fontSize: 15,
20
+ lineHeight: 22,
21
+ fontWeight: '400',
22
+ fontStyle: 'italic',
23
+ },
24
+ description_default: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
25
+ description_xs: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_s: {fontSize: 12, lineHeight: 16, fontWeight: '400'},
27
+ label_default: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
28
+ label_xxs: {fontSize: 8, lineHeight: 12, fontWeight: '500'},
29
+ label_xs: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
30
+ label_s: {fontSize: 12, lineHeight: 16, fontWeight: '500'},
31
+ action_default: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
32
+ action_xxs: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
33
+ action_xs: {fontSize: 12, lineHeight: 16, fontWeight: '700'},
34
+ action_s: {fontSize: 15, lineHeight: 22, fontWeight: '700'},
35
+ };
package/Text/types.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type TypographyWeight = {
2
+ [key: string]: string;
3
+ 100: string;
4
+ 200: string;
5
+ 300: string;
6
+ 400: string;
7
+ 500: string;
8
+ 600: string;
9
+ 700: string;
10
+ 800: string;
11
+ 900: string;
12
+ normal: string;
13
+ bold: string;
14
+ };
15
+
16
+ export type Typography =
17
+ | 'headline_default'
18
+ | 'headline_s'
19
+ | 'headline_l'
20
+ | 'headline_xl'
21
+ | 'title_default'
22
+ | 'title_xs'
23
+ | 'title_s'
24
+ | 'header_default'
25
+ | 'header_xs'
26
+ | 'header_s'
27
+ | 'paragraph_default'
28
+ | 'paragraph_bold'
29
+ | 'paragraph_italic'
30
+ | 'description_default'
31
+ | 'description_xs'
32
+ | 'description_s'
33
+ | 'label_default'
34
+ | 'label_xxs'
35
+ | 'label_xs'
36
+ | 'label_s'
37
+ | 'action_default'
38
+ | 'action_xxs'
39
+ | 'action_xs'
40
+ | 'action_s';
package/index.ts ADDED
@@ -0,0 +1,38 @@
1
+ import {
2
+ SafeAreaProvider,
3
+ SafeAreaView,
4
+ useSafeAreaInsets,
5
+ } from 'react-native-safe-area-context';
6
+ import LinearGradient from 'react-native-linear-gradient';
7
+
8
+ export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
9
+
10
+ export * from './Consts';
11
+ export * from './Layout';
12
+ export * from './Layout/types';
13
+ export * from './Popup';
14
+ export * from './Popup/types';
15
+ export * from './Text';
16
+ export * from './Text/types';
17
+ export * from './Button';
18
+ export * from './Navigation';
19
+ export * from './Navigation/types';
20
+ export * from './Icon';
21
+ export * from './Icon/types';
22
+ export * from './IconButton';
23
+ export * from './Image';
24
+ export * from './Image/types';
25
+ export * from './Skeleton';
26
+ export * from './Skeleton/types';
27
+ export * from './CheckBox';
28
+ export * from './CheckBox/types';
29
+ export * from './Radio';
30
+ export * from './Radio/types';
31
+ export * from './Switch';
32
+ export * from './Switch/types';
33
+ export * from './Input';
34
+ export * from './Divider';
35
+ export * from './Tag';
36
+ export * from './Tag/types';
37
+ export * from './Pagination';
38
+ export * from './Pagination/types';
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.75.1-beta.3",
4
+ "description": "React Native Component Kits",
5
+ "main": "index.ts",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "@momo-kits/foundation"
11
+ ],
12
+ "dependencies": {
13
+ "react-native-safe-area-context": "3.1.4",
14
+ "react-native-linear-gradient": "2.5.6",
15
+ "@react-navigation/bottom-tabs": "git+https://gitlab.com/dung.huynh1/react-navigation-bottom-tabs.git#main",
16
+ "@react-navigation/core": "5.16.1",
17
+ "@react-navigation/native": "5.9.8",
18
+ "@react-navigation/routers": "5.7.4",
19
+ "@react-navigation/stack": "git+https://gitlab.com/dung.huynh1/react-navigation-stack.git#main",
20
+ "@gorhom/bottom-sheet": "2.4.1"
21
+ },
22
+ "peerDependencies": {
23
+ "react-native": "*"
24
+ },
25
+ "devDependencies": {
26
+ "@babel/core": "^7.12.9",
27
+ "@babel/runtime": "^7.12.5",
28
+ "@react-native-community/eslint-config": "^2.0.0",
29
+ "@types/jest": "26.0.23",
30
+ "@types/react-native": "0.64.4",
31
+ "@types/react-test-renderer": "16.9.2",
32
+ "babel-jest": "^26.6.3",
33
+ "eslint": "^7.14.0",
34
+ "jest": "^26.6.3",
35
+ "metro-react-native-babel-preset": "^0.64.0",
36
+ "react-test-renderer": "17.0.1",
37
+ "typescript": "^4.0.3"
38
+ },
39
+ "author": "@momo-kits/foundation",
40
+ "license": "ISC"
41
+ }
package/publish.sh ADDED
@@ -0,0 +1,26 @@
1
+ #!/bin/bash
2
+ rm -rf dist
3
+ mkdir dist
4
+
5
+ cp . ./dist
6
+
7
+
8
+ # GET VERSION from mck_package.json
9
+ VERSIONSTRING=( v$(jq .version package.json) )
10
+ VERSION=(${VERSIONSTRING//[\"]/})
11
+ echo VERSION: $VERSION
12
+
13
+ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
14
+
15
+ #babel component to dist
16
+ #babel ./dist -d dist --copy-files
17
+
18
+ cd dist
19
+ npm publish --tag beta --access=public
20
+
21
+ #clear dist and package json
22
+ cd ..
23
+ rm -rf dist
24
+
25
+
26
+ #curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/core new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/core"}'