@momo-kits/foundation 0.162.2-beta.18 → 0.162.2-beta.19
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/IconButton/index.tsx +22 -22
- package/IconButton/styles.ts +19 -1
- package/package.json +1 -1
package/IconButton/index.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ComponentContext,
|
|
10
10
|
MiniAppContext,
|
|
11
11
|
} from '../Context';
|
|
12
|
-
import { Colors
|
|
12
|
+
import { Colors } from '../Consts';
|
|
13
13
|
import { Icon } from '../Icon';
|
|
14
14
|
import styles from './styles';
|
|
15
15
|
|
|
@@ -28,12 +28,12 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
28
28
|
/**
|
|
29
29
|
* Optional. Defines the size of the IconButton.
|
|
30
30
|
*/
|
|
31
|
-
size?: 'large' | 'small';
|
|
31
|
+
size?: 'large' | 'medium' | 'small';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Optional. Defines the shape of the IconButton.
|
|
34
|
+
* Optional. Defines the shape of the IconButton.
|
|
35
35
|
*/
|
|
36
|
-
shape?: 'circle' | 'square'
|
|
36
|
+
shape?: 'circle' | 'square';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Optional. Params auto tracking component.
|
|
@@ -55,27 +55,26 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
55
55
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* get
|
|
59
|
-
* circle keeps the fully-rounded default; square/rectangle use Radius.S.
|
|
60
|
-
* rectangle is wider than tall.
|
|
58
|
+
* get size icon button
|
|
61
59
|
*/
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
width: size === 'small' ? 48 : 56,
|
|
70
|
-
height: box,
|
|
71
|
-
borderRadius: Radius.S,
|
|
72
|
-
};
|
|
73
|
-
case 'circle':
|
|
60
|
+
const getSizeStyle = () => {
|
|
61
|
+
switch (size) {
|
|
62
|
+
case 'small':
|
|
63
|
+
return styles.small;
|
|
64
|
+
case 'medium':
|
|
65
|
+
return styles.medium;
|
|
74
66
|
default:
|
|
75
|
-
return
|
|
67
|
+
return styles.large;
|
|
76
68
|
}
|
|
77
69
|
};
|
|
78
70
|
|
|
71
|
+
/**
|
|
72
|
+
* get shape icon button
|
|
73
|
+
*/
|
|
74
|
+
const getShapeStyle = () => {
|
|
75
|
+
return shape === 'square' ? styles.square : styles.circle;
|
|
76
|
+
};
|
|
77
|
+
|
|
79
78
|
/**
|
|
80
79
|
* get style for icon button by type
|
|
81
80
|
*/
|
|
@@ -137,10 +136,11 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
137
136
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
138
137
|
const buttonStyle = StyleSheet.flatten([
|
|
139
138
|
getTypeStyle(),
|
|
140
|
-
getShapeStyle(),
|
|
141
139
|
styles.base,
|
|
140
|
+
getSizeStyle(),
|
|
141
|
+
getShapeStyle(),
|
|
142
142
|
]);
|
|
143
|
-
const iconSize = size === 'small' ? 16 : 24;
|
|
143
|
+
const iconSize = size === 'small' || size === 'medium' ? 16 : 24;
|
|
144
144
|
|
|
145
145
|
return (
|
|
146
146
|
<ComponentContext.Provider
|
package/IconButton/styles.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../Consts';
|
|
2
|
+
import { Radius, Colors } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
base: {
|
|
6
6
|
justifyContent: 'center',
|
|
7
7
|
alignItems: 'center',
|
|
8
8
|
},
|
|
9
|
+
large: {
|
|
10
|
+
width: 48,
|
|
11
|
+
height: 48,
|
|
12
|
+
},
|
|
13
|
+
medium: {
|
|
14
|
+
width: 36,
|
|
15
|
+
height: 36,
|
|
16
|
+
},
|
|
17
|
+
small: {
|
|
18
|
+
width: 28,
|
|
19
|
+
height: 28,
|
|
20
|
+
},
|
|
21
|
+
circle: {
|
|
22
|
+
borderRadius: Radius.XL,
|
|
23
|
+
},
|
|
24
|
+
square: {
|
|
25
|
+
borderRadius: Radius.S,
|
|
26
|
+
},
|
|
9
27
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
10
28
|
});
|