@onehat/ui 0.3.71 → 0.3.72
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/package.json
CHANGED
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
Pressable,
|
|
5
5
|
Text,
|
|
6
6
|
} from 'native-base';
|
|
7
|
+
import IconButton from './IconButton.js';
|
|
7
8
|
import UiGlobals from '../../UiGlobals.js';
|
|
8
9
|
|
|
9
10
|
export default function SquareButton(props) {
|
|
10
11
|
const {
|
|
11
12
|
text,
|
|
12
13
|
isActive = false,
|
|
14
|
+
showText = true,
|
|
13
15
|
activeColor,
|
|
14
16
|
invertColorWhenActive = false,
|
|
15
17
|
disableInteractions = false,
|
|
@@ -17,7 +19,9 @@ export default function SquareButton(props) {
|
|
|
17
19
|
...propsToPass
|
|
18
20
|
} = props,
|
|
19
21
|
styles = UiGlobals.styles,
|
|
22
|
+
bg = isActive ? activeColor || '#56a6f8' : '#fff',
|
|
20
23
|
color = invertColorWhenActive && isActive ? '#fff' : '#000';
|
|
24
|
+
|
|
21
25
|
const propsIcon = props._icon || {};
|
|
22
26
|
let icon = props.icon;
|
|
23
27
|
if (!icon) {
|
|
@@ -26,14 +30,6 @@ export default function SquareButton(props) {
|
|
|
26
30
|
if (!text) {
|
|
27
31
|
throw Error('text missing');
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
if (React.isValidElement(icon)) {
|
|
31
|
-
if (!_.isEmpty(propsIcon)) {
|
|
32
|
-
icon = React.cloneElement(icon, {...propsIcon});
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
icon = <Icon as={icon} {...propsIcon} />;
|
|
36
|
-
}
|
|
37
33
|
|
|
38
34
|
const
|
|
39
35
|
hoverProps = {},
|
|
@@ -42,7 +38,29 @@ export default function SquareButton(props) {
|
|
|
42
38
|
hoverProps.bg = styles.ICON_BUTTON_BG_HOVER;
|
|
43
39
|
pressedProps.bg = styles.ICON_BUTTON_BG_PRESSED;
|
|
44
40
|
}
|
|
45
|
-
|
|
41
|
+
|
|
42
|
+
if (!showText) {
|
|
43
|
+
return <IconButton
|
|
44
|
+
icon={icon}
|
|
45
|
+
borderRadius="md"
|
|
46
|
+
p={2}
|
|
47
|
+
_icon={{
|
|
48
|
+
size: '20px',
|
|
49
|
+
color,
|
|
50
|
+
}}
|
|
51
|
+
{...propsToPass}
|
|
52
|
+
bg={bg}
|
|
53
|
+
/>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (React.isValidElement(icon)) {
|
|
57
|
+
if (!_.isEmpty(propsIcon)) {
|
|
58
|
+
icon = React.cloneElement(icon, {...propsIcon});
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
icon = <Icon as={icon} {...propsIcon} />;
|
|
62
|
+
}
|
|
63
|
+
|
|
46
64
|
return <Pressable
|
|
47
65
|
borderRadius="md"
|
|
48
66
|
flexDirection="column"
|
|
@@ -50,7 +68,7 @@ export default function SquareButton(props) {
|
|
|
50
68
|
alignItems="center"
|
|
51
69
|
p={2}
|
|
52
70
|
{...propsToPass}
|
|
53
|
-
bg={
|
|
71
|
+
bg={bg}
|
|
54
72
|
// _hover={hoverProps}
|
|
55
73
|
// _pressed={pressedProps}
|
|
56
74
|
>
|