cdslibrary 1.0.34 → 1.0.36

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.
@@ -1,12 +1,12 @@
1
- import React from "react";
1
+ import React, { useEffect, useState } 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
8
+ // const { width } = Dimensions.get("window");
9
+ // const isMobile = width <= 768
10
10
 
11
11
  export const CDSButton = ({
12
12
  label,
@@ -33,30 +33,49 @@ export const CDSButton = ({
33
33
  ? theme.text.neutral.disabled
34
34
  : theme.text.neutral.contrast;
35
35
 
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
- >
36
+ const { width } = Dimensions.get("window");
37
+
38
+ // Estado para manejar el ancho del dispositivo
39
+ const [isMobile, setIsMobile] = useState(width <= 768);
40
+
41
+ // Efecto para detectar cambios en el tamaño de la ventana en la web
42
+ useEffect(() => {
43
+ const handleResize = () => {
44
+ setIsMobile(window.innerWidth <= 768); // Ajusta el umbral según lo necesites
45
+ };
46
+
47
+ if (Platform.OS === 'web') {
48
+ window.addEventListener('resize', handleResize);
49
+ return () => {
50
+ window.removeEventListener('resize', handleResize);
51
+ };
52
+ }
53
+ }, []);
54
+
55
+ return (
56
+ <TouchableOpacity
57
+ onPress={type !== "disabled" ? onPress : null}
58
+ activeOpacity={0.7}
59
+ style={[
60
+ styles.container,
61
+ { backgroundColor },
62
+ flexend && { justifyContent: "flex-end", paddingHorizontal: 0 },
63
+ {
64
+ paddingHorizontal: type === "icon" ? 12 : 24,
65
+ ...(isMobile && { width: "100%" }) // Se aplica full width si es móvil o en la web en modo móvil
66
+ },
67
+ type === "secondary" && {
68
+ borderColor: theme.outline.action.primary,
69
+ borderWidth: 1,
70
+ },
71
+ type === 'link' && {
72
+ paddingHorizontal: 0,
73
+ paddingVertical: 0,
74
+ width: 'auto',
75
+ minWidth: 1,
76
+ }
77
+ ]}
78
+ >
60
79
  {type !== "icon" && (
61
80
  <Text
62
81
  style={[
@@ -90,7 +109,7 @@ const styles = StyleSheet.create({
90
109
  justifyContent: "center",
91
110
  paddingVertical: 12,
92
111
  paddingHorizontal: 24,
93
- borderRadius: 1,
112
+ borderRadius: 100,
94
113
  gap: 8,
95
114
  },
96
115
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.0.34",
4
+ "version": "1.0.36",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",