@momo-kits/foundation 0.77.3 → 0.77.5
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/BottomTab.tsx +3 -3
- package/Application/types.ts +1 -1
- package/Application/utils.tsx +8 -0
- package/Layout/Card.tsx +21 -17
- package/Layout/GridSystem.tsx +27 -17
- package/Layout/Item.tsx +3 -20
- package/Layout/Section.tsx +2 -14
- package/Layout/styles.ts +68 -0
- package/Layout/types.ts +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
2
3
|
import {BottomTabProps} from './types';
|
|
3
4
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
4
5
|
import {Icon} from '../Icon';
|
|
5
6
|
import {Text} from '../Text';
|
|
6
7
|
import {ApplicationContext} from './index';
|
|
7
|
-
import {View} from 'react-native';
|
|
8
8
|
|
|
9
9
|
const Tab = createBottomTabNavigator();
|
|
10
10
|
|
|
11
|
-
const BottomTab: FC<BottomTabProps> = ({tabs, listeners}) => {
|
|
11
|
+
const BottomTab: React.FC<BottomTabProps> = ({tabs, listeners}) => {
|
|
12
12
|
const {theme} = useContext(ApplicationContext);
|
|
13
13
|
return (
|
|
14
14
|
<Tab.Navigator>
|
package/Application/types.ts
CHANGED
package/Application/utils.tsx
CHANGED
|
@@ -84,6 +84,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
84
84
|
),
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
if (params.surface == true) {
|
|
88
89
|
options = {
|
|
89
90
|
...options,
|
|
@@ -125,6 +126,13 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
if (params?.headerRight == undefined) {
|
|
130
|
+
options = {
|
|
131
|
+
...options,
|
|
132
|
+
headerRight: (props: any) => <HeaderToolkitAction {...props} />,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
128
136
|
return {
|
|
129
137
|
...params,
|
|
130
138
|
...options,
|
package/Layout/Card.tsx
CHANGED
|
@@ -2,11 +2,14 @@ import React, {useContext} from 'react';
|
|
|
2
2
|
import {Dimensions, View} from 'react-native';
|
|
3
3
|
import {useGridSystem, validateChildren} from './utils';
|
|
4
4
|
import {CardProps, GridContextProps} from './types';
|
|
5
|
-
import {GridContext} from './index';
|
|
5
|
+
import {GridContext, GridSystem} from './index';
|
|
6
6
|
import Item from './Item';
|
|
7
|
+
import {Image} from '../Image';
|
|
7
8
|
import {ApplicationContext} from '../Application';
|
|
9
|
+
import styles from './styles';
|
|
10
|
+
import {Colors, Spacing} from '../Consts';
|
|
8
11
|
|
|
9
|
-
const Card: React.FC<CardProps> = ({children, style}) => {
|
|
12
|
+
const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
10
13
|
const {showGrid} = useContext(ApplicationContext);
|
|
11
14
|
const {numberOfColumns} = useGridSystem();
|
|
12
15
|
|
|
@@ -31,18 +34,15 @@ const Card: React.FC<CardProps> = ({children, style}) => {
|
|
|
31
34
|
*/
|
|
32
35
|
const renderOverlay = () => {
|
|
33
36
|
return (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
borderWidth: 1,
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
37
|
+
<>
|
|
38
|
+
<GridSystem
|
|
39
|
+
width={widthSection}
|
|
40
|
+
gutterSize={Spacing.S}
|
|
41
|
+
screenGrid={false}
|
|
42
|
+
gridColor={Colors.red_01}
|
|
43
|
+
/>
|
|
44
|
+
<View pointerEvents={'none'} style={styles.boxGridCard} />
|
|
45
|
+
</>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -123,14 +123,18 @@ const Card: React.FC<CardProps> = ({children, style}) => {
|
|
|
123
123
|
accessibilityLabel={`Card`}
|
|
124
124
|
style={[
|
|
125
125
|
style,
|
|
126
|
+
styles.card,
|
|
126
127
|
{
|
|
127
128
|
width: widthSection,
|
|
128
129
|
marginHorizontal: gridContext.margin,
|
|
129
|
-
padding: 12,
|
|
130
|
-
flexDirection: 'row',
|
|
131
|
-
flexWrap: 'wrap',
|
|
132
130
|
},
|
|
133
131
|
]}>
|
|
132
|
+
{!!backgroundImage && (
|
|
133
|
+
<Image
|
|
134
|
+
source={{uri: backgroundImage}}
|
|
135
|
+
style={[style, styles.cardImage]}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
134
138
|
{renderView(validateChildren(children, [Item]))}
|
|
135
139
|
{showGrid && renderOverlay()}
|
|
136
140
|
</View>
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -6,13 +6,18 @@ import {Colors, Spacing} from '../Consts';
|
|
|
6
6
|
import {GridContextProps} from './types';
|
|
7
7
|
import {useGridSystem} from './utils';
|
|
8
8
|
|
|
9
|
-
const GridSystem: React.FC = (
|
|
9
|
+
const GridSystem: React.FC<any> = ({
|
|
10
|
+
width = Dimensions.get('window').width,
|
|
11
|
+
useMargin = true,
|
|
12
|
+
gutterSize = Spacing.M,
|
|
13
|
+
screenGrid = true,
|
|
14
|
+
gridColor = Colors.blue_07,
|
|
15
|
+
}) => {
|
|
10
16
|
const {theme} = useContext(ApplicationContext);
|
|
11
17
|
const {numberOfColumns} = useGridSystem();
|
|
12
18
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const widthSection = Dimensions.get('window').width - margin * 2;
|
|
19
|
+
const margin = useMargin ? Spacing.M : 0;
|
|
20
|
+
const widthSection = width - margin * 2;
|
|
16
21
|
const totalGutterSize = gutterSize * (numberOfColumns - 1);
|
|
17
22
|
const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
|
|
18
23
|
|
|
@@ -38,11 +43,12 @@ const GridSystem: React.FC = () => {
|
|
|
38
43
|
pointerEvents="none"
|
|
39
44
|
style={[
|
|
40
45
|
styles.gridContainer,
|
|
41
|
-
insets,
|
|
46
|
+
screenGrid && insets,
|
|
42
47
|
{
|
|
43
48
|
borderColor: theme.colors.error.primary,
|
|
44
49
|
marginHorizontal: grid.margin,
|
|
45
50
|
top: Spacing.M,
|
|
51
|
+
bottom: Spacing.M,
|
|
46
52
|
},
|
|
47
53
|
]}>
|
|
48
54
|
{list.map((i, index) => {
|
|
@@ -50,12 +56,13 @@ const GridSystem: React.FC = () => {
|
|
|
50
56
|
<View style={{flexDirection: 'row'}} key={index.toString()}>
|
|
51
57
|
{index != -0 && <View style={{width: grid.gutterSize}} />}
|
|
52
58
|
<View
|
|
53
|
-
key={index.toString()}
|
|
59
|
+
key={`Grid${index.toString()}`}
|
|
54
60
|
pointerEvents="none"
|
|
55
61
|
style={[
|
|
56
62
|
styles.gridColumn,
|
|
57
63
|
{
|
|
58
64
|
width: grid.sizePerSpan,
|
|
65
|
+
backgroundColor: gridColor,
|
|
59
66
|
},
|
|
60
67
|
]}
|
|
61
68
|
/>
|
|
@@ -63,16 +70,20 @@ const GridSystem: React.FC = () => {
|
|
|
63
70
|
);
|
|
64
71
|
})}
|
|
65
72
|
</View>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
{screenGrid && (
|
|
74
|
+
<>
|
|
75
|
+
<View pointerEvents="none" style={styles.dangerLeftContainer} />
|
|
76
|
+
<View pointerEvents="none" style={styles.dangerRightContainer} />
|
|
77
|
+
<View
|
|
78
|
+
pointerEvents="none"
|
|
79
|
+
style={[styles.dangerTopContainer, {height: Spacing.M}]}
|
|
80
|
+
/>
|
|
81
|
+
<View
|
|
82
|
+
pointerEvents="none"
|
|
83
|
+
style={[styles.dangerBottomContainer, {height: insets.bottom}]}
|
|
84
|
+
/>
|
|
85
|
+
</>
|
|
86
|
+
)}
|
|
76
87
|
</>
|
|
77
88
|
);
|
|
78
89
|
};
|
|
@@ -90,7 +101,6 @@ const styles = StyleSheet.create({
|
|
|
90
101
|
gridColumn: {
|
|
91
102
|
height: '100%',
|
|
92
103
|
opacity: 0.2,
|
|
93
|
-
backgroundColor: Colors.blue_07,
|
|
94
104
|
},
|
|
95
105
|
dangerTopContainer: {
|
|
96
106
|
opacity: 0.2,
|
package/Layout/Item.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {View} from 'react-native';
|
|
|
4
4
|
import {ItemProps} from './types';
|
|
5
5
|
import {GridContext} from './index';
|
|
6
6
|
import {ApplicationContext} from '../Application';
|
|
7
|
+
import styles from './styles';
|
|
7
8
|
|
|
8
9
|
const Item: React.FC<ItemProps> = ({
|
|
9
10
|
widthSpan,
|
|
@@ -18,20 +19,7 @@ const Item: React.FC<ItemProps> = ({
|
|
|
18
19
|
* render overlay view only dev mode
|
|
19
20
|
*/
|
|
20
21
|
const renderOverlay = () => {
|
|
21
|
-
return
|
|
22
|
-
<View
|
|
23
|
-
pointerEvents={'none'}
|
|
24
|
-
style={{
|
|
25
|
-
position: 'absolute',
|
|
26
|
-
top: 0,
|
|
27
|
-
bottom: 0,
|
|
28
|
-
left: 0,
|
|
29
|
-
right: 0,
|
|
30
|
-
borderColor: 'red',
|
|
31
|
-
borderWidth: 1,
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
22
|
+
return <View pointerEvents={'none'} style={styles.boxGrid} />;
|
|
35
23
|
};
|
|
36
24
|
|
|
37
25
|
return (
|
|
@@ -39,15 +27,10 @@ const Item: React.FC<ItemProps> = ({
|
|
|
39
27
|
accessibilityLabel={`Item`}
|
|
40
28
|
style={[
|
|
41
29
|
style,
|
|
30
|
+
styles.item,
|
|
42
31
|
{
|
|
43
32
|
width: grid.getSizeSpan(widthSpan ?? grid.numberOfColumns),
|
|
44
33
|
height: heightSpan ? grid.getSizeSpan(heightSpan) : undefined,
|
|
45
|
-
overflow: 'hidden',
|
|
46
|
-
margin: undefined,
|
|
47
|
-
marginTop: undefined,
|
|
48
|
-
marginBottom: undefined,
|
|
49
|
-
marginLeft: undefined,
|
|
50
|
-
marginRight: undefined,
|
|
51
34
|
},
|
|
52
35
|
]}>
|
|
53
36
|
{children}
|
package/Layout/Section.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import {GridContextProps, SectionProps} from './types';
|
|
|
5
5
|
import {GridContext} from './index';
|
|
6
6
|
import Item from './Item';
|
|
7
7
|
import {ApplicationContext} from '../Application';
|
|
8
|
+
import styles from './styles';
|
|
8
9
|
|
|
9
10
|
const Section: React.FC<SectionProps> = ({
|
|
10
11
|
children,
|
|
@@ -38,20 +39,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
38
39
|
* render overlay only dev mode
|
|
39
40
|
*/
|
|
40
41
|
const renderOverlay = () => {
|
|
41
|
-
return
|
|
42
|
-
<View
|
|
43
|
-
pointerEvents={'none'}
|
|
44
|
-
style={{
|
|
45
|
-
position: 'absolute',
|
|
46
|
-
top: 0,
|
|
47
|
-
bottom: 0,
|
|
48
|
-
left: 0,
|
|
49
|
-
right: 0,
|
|
50
|
-
borderColor: 'red',
|
|
51
|
-
borderWidth: 1,
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
42
|
+
return <View pointerEvents={'none'} style={styles.boxGridSection} />;
|
|
55
43
|
};
|
|
56
44
|
|
|
57
45
|
/**
|
package/Layout/styles.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
boxGrid: {
|
|
5
|
+
position: 'absolute',
|
|
6
|
+
top: 0,
|
|
7
|
+
bottom: 0,
|
|
8
|
+
left: 0,
|
|
9
|
+
right: 0,
|
|
10
|
+
borderColor: 'red',
|
|
11
|
+
borderWidth: 1,
|
|
12
|
+
zIndex: 99,
|
|
13
|
+
},
|
|
14
|
+
boxGridSection: {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
borderColor: 'blue',
|
|
21
|
+
borderWidth: 2,
|
|
22
|
+
zIndex: 100,
|
|
23
|
+
},
|
|
24
|
+
boxGridCard: {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
left: 0,
|
|
29
|
+
right: 0,
|
|
30
|
+
borderColor: 'green',
|
|
31
|
+
borderWidth: 2,
|
|
32
|
+
zIndex: 100,
|
|
33
|
+
},
|
|
34
|
+
card: {
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
flexWrap: 'wrap',
|
|
37
|
+
paddingTop: undefined,
|
|
38
|
+
paddingBottom: undefined,
|
|
39
|
+
paddingLeft: undefined,
|
|
40
|
+
paddingRight: undefined,
|
|
41
|
+
paddingVertical: undefined,
|
|
42
|
+
paddingHorizontal: undefined,
|
|
43
|
+
padding: 12,
|
|
44
|
+
margin: undefined,
|
|
45
|
+
marginTop: undefined,
|
|
46
|
+
marginBottom: undefined,
|
|
47
|
+
marginLeft: undefined,
|
|
48
|
+
marginRight: undefined,
|
|
49
|
+
marginVertical: undefined,
|
|
50
|
+
},
|
|
51
|
+
item: {
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
margin: undefined,
|
|
54
|
+
marginTop: undefined,
|
|
55
|
+
marginBottom: undefined,
|
|
56
|
+
marginLeft: undefined,
|
|
57
|
+
marginRight: undefined,
|
|
58
|
+
marginVertical: undefined,
|
|
59
|
+
marginHorizontal: undefined,
|
|
60
|
+
},
|
|
61
|
+
cardImage: {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
top: 0,
|
|
64
|
+
bottom: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
right: 0,
|
|
67
|
+
},
|
|
68
|
+
});
|
package/Layout/types.ts
CHANGED