cdslibrary 1.0.42 → 1.0.44
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/components/CDSButton.jsx +27 -44
- package/package.json +1 -1
package/components/CDSButton.jsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { Text, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
3
|
import { Dimensions, Platform } from "react-native";
|
|
4
4
|
import { MaterialIcons } from "@expo/vector-icons";
|
|
5
5
|
import { useTheme } from "../context/CDSThemeContext";
|
|
6
6
|
import { getSemanticTextStyles } from "../tokens/CDSsemanticTextStyles";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const { width } = Dimensions.get("window");
|
|
9
|
+
const isMobile = width <= 768
|
|
10
10
|
|
|
11
11
|
export const CDSButton = ({
|
|
12
12
|
label,
|
|
@@ -33,46 +33,30 @@ export const CDSButton = ({
|
|
|
33
33
|
? theme.text.neutral.disabled
|
|
34
34
|
: theme.text.neutral.contrast;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
paddingHorizontal: type === "icon" ? 12 : 24,
|
|
62
|
-
// ...(isMobile && { width: "100%" })
|
|
63
|
-
},
|
|
64
|
-
type === "secondary" && {
|
|
65
|
-
borderColor: theme.outline.action.primary,
|
|
66
|
-
borderWidth: 1,
|
|
67
|
-
},
|
|
68
|
-
type === 'link' && {
|
|
69
|
-
paddingHorizontal: 0,
|
|
70
|
-
paddingVertical: 0,
|
|
71
|
-
width: 'auto',
|
|
72
|
-
minWidth: 1,
|
|
73
|
-
}
|
|
74
|
-
]}
|
|
75
|
-
>
|
|
36
|
+
return (
|
|
37
|
+
<TouchableOpacity
|
|
38
|
+
onPress={type !== "disabled" ? onPress : null}
|
|
39
|
+
activeOpacity={0.7}
|
|
40
|
+
style={[
|
|
41
|
+
styles.container,
|
|
42
|
+
{ backgroundColor },
|
|
43
|
+
flexend && { justifyContent: "flex-end", paddingHorizontal: 0 },
|
|
44
|
+
{
|
|
45
|
+
paddingHorizontal: type === "icon" ? 12 : 24,
|
|
46
|
+
...(isMobile && { width: "100%" })
|
|
47
|
+
},
|
|
48
|
+
type === "secondary" && {
|
|
49
|
+
borderColor: theme.outline.action.primary,
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
},
|
|
52
|
+
type === 'link' && {
|
|
53
|
+
paddingHorizontal: 0,
|
|
54
|
+
paddingVertical: 0,
|
|
55
|
+
width: 'auto',
|
|
56
|
+
minWidth: 1,
|
|
57
|
+
}
|
|
58
|
+
]}
|
|
59
|
+
>
|
|
76
60
|
{type !== "icon" && (
|
|
77
61
|
<Text
|
|
78
62
|
style={[
|
|
@@ -108,7 +92,6 @@ const styles = StyleSheet.create({
|
|
|
108
92
|
paddingHorizontal: 24,
|
|
109
93
|
borderRadius: 100,
|
|
110
94
|
gap: 8,
|
|
111
|
-
flexShrink: 1,
|
|
112
95
|
},
|
|
113
96
|
});
|
|
114
97
|
|