cdslibrary 1.0.48 → 1.0.50
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 +7 -17
- package/package.json +1 -1
package/components/CDSButton.jsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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
|
+
const { width } = Dimensions.get("window");
|
|
9
|
+
const isMobile = width <= 768
|
|
10
|
+
|
|
8
11
|
export const CDSButton = ({
|
|
9
12
|
label,
|
|
10
13
|
type = "primary",
|
|
@@ -21,7 +24,7 @@ export const CDSButton = ({
|
|
|
21
24
|
? theme.surface.action.disabled
|
|
22
25
|
: type === "secondary" || type === "ghost" || type === "link"
|
|
23
26
|
? "transparent"
|
|
24
|
-
: theme.surface.
|
|
27
|
+
: theme.surface.special.progress;
|
|
25
28
|
|
|
26
29
|
const textColor =
|
|
27
30
|
type === "secondary" || type === "ghost" || type === "link"
|
|
@@ -30,19 +33,6 @@ export const CDSButton = ({
|
|
|
30
33
|
? theme.text.neutral.disabled
|
|
31
34
|
: theme.text.neutral.contrast;
|
|
32
35
|
|
|
33
|
-
const { width } = Dimensions.get("window");
|
|
34
|
-
const [isMobile, setIsMobile] = useState(width <= 768);
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const handleResize = () => {
|
|
38
|
-
const { width } = Dimensions.get("window");
|
|
39
|
-
setIsMobile(width <= 768);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const subscription = Dimensions.addEventListener("change", handleResize);
|
|
43
|
-
return () => subscription?.remove(); // Limpia el listener
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
36
|
return (
|
|
47
37
|
<TouchableOpacity
|
|
48
38
|
onPress={type !== "disabled" ? onPress : null}
|
|
@@ -53,7 +43,7 @@ export const CDSButton = ({
|
|
|
53
43
|
flexend && { justifyContent: "flex-end", paddingHorizontal: 0 },
|
|
54
44
|
{
|
|
55
45
|
paddingHorizontal: type === "icon" ? 12 : 24,
|
|
56
|
-
...(isMobile && { width: "100%" })
|
|
46
|
+
...(isMobile && { width: "100%" })
|
|
57
47
|
},
|
|
58
48
|
type === "secondary" && {
|
|
59
49
|
borderColor: theme.outline.action.primary,
|
|
@@ -100,7 +90,7 @@ const styles = StyleSheet.create({
|
|
|
100
90
|
justifyContent: "center",
|
|
101
91
|
paddingVertical: 12,
|
|
102
92
|
paddingHorizontal: 24,
|
|
103
|
-
borderRadius:
|
|
93
|
+
borderRadius: 8,
|
|
104
94
|
gap: 8,
|
|
105
95
|
},
|
|
106
96
|
});
|