@momo-kits/foundation 0.162.2-beta.16 → 0.162.2-beta.18
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 +29 -7
- package/IconButton/styles.ts +2 -12
- 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 } from '../Consts';
|
|
12
|
+
import { Colors, Radius } from '../Consts';
|
|
13
13
|
import { Icon } from '../Icon';
|
|
14
14
|
import styles from './styles';
|
|
15
15
|
|
|
@@ -30,6 +30,11 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
30
30
|
*/
|
|
31
31
|
size?: 'large' | 'small';
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Optional. Defines the shape of the IconButton. Defaults to 'circle'.
|
|
35
|
+
*/
|
|
36
|
+
shape?: 'circle' | 'square' | 'rectangle';
|
|
37
|
+
|
|
33
38
|
/**
|
|
34
39
|
* Optional. Params auto tracking component.
|
|
35
40
|
*/
|
|
@@ -40,6 +45,7 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
40
45
|
type = 'primary',
|
|
41
46
|
icon,
|
|
42
47
|
size,
|
|
48
|
+
shape = 'circle',
|
|
43
49
|
params,
|
|
44
50
|
...rest
|
|
45
51
|
}) => {
|
|
@@ -49,13 +55,25 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
49
55
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
50
56
|
|
|
51
57
|
/**
|
|
52
|
-
* get size icon button
|
|
58
|
+
* get box size + border radius for icon button by size and shape.
|
|
59
|
+
* circle keeps the fully-rounded default; square/rectangle use Radius.S.
|
|
60
|
+
* rectangle is wider than tall.
|
|
53
61
|
*/
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const getShapeStyle = () => {
|
|
63
|
+
const box = size === 'small' ? 40 : 48;
|
|
64
|
+
switch (shape) {
|
|
65
|
+
case 'square':
|
|
66
|
+
return { width: box, height: box, borderRadius: Radius.S };
|
|
67
|
+
case 'rectangle':
|
|
68
|
+
return {
|
|
69
|
+
width: size === 'small' ? 48 : 56,
|
|
70
|
+
height: box,
|
|
71
|
+
borderRadius: Radius.S,
|
|
72
|
+
};
|
|
73
|
+
case 'circle':
|
|
74
|
+
default:
|
|
75
|
+
return { width: box, height: box, borderRadius: Radius.XL };
|
|
57
76
|
}
|
|
58
|
-
return styles.large;
|
|
59
77
|
};
|
|
60
78
|
|
|
61
79
|
/**
|
|
@@ -117,7 +135,11 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
117
135
|
};
|
|
118
136
|
|
|
119
137
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
120
|
-
const buttonStyle = StyleSheet.flatten([
|
|
138
|
+
const buttonStyle = StyleSheet.flatten([
|
|
139
|
+
getTypeStyle(),
|
|
140
|
+
getShapeStyle(),
|
|
141
|
+
styles.base,
|
|
142
|
+
]);
|
|
121
143
|
const iconSize = size === 'small' ? 16 : 24;
|
|
122
144
|
|
|
123
145
|
return (
|
package/IconButton/styles.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { Colors } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
-
|
|
6
|
-
width: 48,
|
|
7
|
-
height: 48,
|
|
8
|
-
borderRadius: Radius.XL,
|
|
9
|
-
justifyContent: 'center',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
},
|
|
12
|
-
small: {
|
|
13
|
-
width: 40,
|
|
14
|
-
height: 40,
|
|
15
|
-
borderRadius: Radius.XL,
|
|
5
|
+
base: {
|
|
16
6
|
justifyContent: 'center',
|
|
17
7
|
alignItems: 'center',
|
|
18
8
|
},
|