@dropi/react-native-design-system 0.2.29 → 0.2.31
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/README.md
CHANGED
|
@@ -31,6 +31,8 @@ El **Design System de Dropi** para aplicaciones **React Native**. Este paquete r
|
|
|
31
31
|
- [Default Button](#default-button)
|
|
32
32
|
- [Feedback Button](#feedback-button)
|
|
33
33
|
- [Text Button](#text-button)
|
|
34
|
+
- [Imágenes](#imágenes)
|
|
35
|
+
- [Custom Image](#custom-image)
|
|
34
36
|
|
|
35
37
|
- [🧪 Moléculas](#moléculas)
|
|
36
38
|
- [Alert](#alert)
|
|
@@ -58,22 +60,63 @@ Tu proyecto debe tener instaladas estas dependencias mínimas:
|
|
|
58
60
|
```JSON
|
|
59
61
|
"react": ">=19.0.0",
|
|
60
62
|
"react-native": ">=0.79.5",
|
|
61
|
-
"dropi-lib-icons": ">=1.
|
|
62
|
-
"expo-image": ">=2.4.0"
|
|
63
|
+
"dropi-lib-icons": ">=1.3.4",
|
|
64
|
+
"expo-image": ">=2.4.0",
|
|
65
|
+
"expo-constants": ">=17.1.7",
|
|
66
|
+
"lottie-react-native": ">=7.2.2",
|
|
67
|
+
"react-native-gesture-handler": ">=2.24.0",
|
|
68
|
+
"react-native-reanimated": ">=3.19.1",
|
|
69
|
+
"@gorhom/bottom-sheet": ">=5.2.6"
|
|
63
70
|
```
|
|
64
71
|
|
|
72
|
+
### 📦 Instalación de dependencias base
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
Instala las dependencias principales:
|
|
67
75
|
|
|
68
76
|
```sh
|
|
69
|
-
npm install
|
|
70
|
-
npm install dropi-lib-icons expo-image
|
|
77
|
+
npm install dropi-lib-icons expo-image expo-constants lottie-react-native
|
|
71
78
|
```
|
|
72
79
|
|
|
80
|
+
O con yarn:
|
|
81
|
+
```sh
|
|
82
|
+
yarn add dropi-lib-icons expo-image expo-constants lottie-react-native
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### ⚙️ Instalación de dependencias de animación e interacción
|
|
86
|
+
|
|
87
|
+
Estas dependencias son necesarias para componentes como **Bottom Sheet**, **animaciones Lottie** y **gestos interactivos**:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm install react-native-reanimated react-native-gesture-handler @gorhom/bottom-sheet
|
|
91
|
+
```
|
|
73
92
|
|
|
74
93
|
O con yarn:
|
|
75
94
|
```sh
|
|
76
|
-
yarn add
|
|
95
|
+
yarn add react-native-reanimated react-native-gesture-handler @gorhom/bottom-sheet
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### 🔧 Configuración de react-native-reanimated
|
|
99
|
+
|
|
100
|
+
Añade el plugin de Reanimated en tu `babel.config.js`:
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
module.exports = {
|
|
104
|
+
presets: ['module:@react-native/babel-preset'],
|
|
105
|
+
plugins: [
|
|
106
|
+
'react-native-reanimated/plugin', // Debe ser el último plugin
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### 🔧 Configuración de react-native-gesture-handler
|
|
112
|
+
|
|
113
|
+
En tu archivo de entrada principal (usualmente `App.tsx` o `index.js`), importa gesture-handler al inicio:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import 'react-native-gesture-handler';
|
|
117
|
+
import { AppRegistry } from 'react-native';
|
|
118
|
+
import App from './App';
|
|
119
|
+
// ...
|
|
77
120
|
```
|
|
78
121
|
|
|
79
122
|
## 2️⃣ Instalación del Design System
|
|
@@ -88,23 +131,69 @@ yarn add @dropi/react-native-design-system
|
|
|
88
131
|
```
|
|
89
132
|
|
|
90
133
|
## 3️⃣ Configuración adicional según tu entorno
|
|
134
|
+
|
|
91
135
|
### 🔹 Si usas Expo
|
|
92
136
|
|
|
93
|
-
|
|
137
|
+
La mayoría de las dependencias ya están incluidas en Expo. Solo asegúrate de tener las versiones mínimas:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
npx expo install expo-image expo-constants lottie-react-native react-native-reanimated react-native-gesture-handler @gorhom/bottom-sheet
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Importante:** Aunque Expo incluye muchas de estas librerías, debes añadir el plugin de Reanimated en tu `babel.config.js` como se explicó anteriormente.
|
|
94
144
|
|
|
95
145
|
### 🔹 Si usas React Native CLI
|
|
96
146
|
|
|
97
|
-
Debes
|
|
147
|
+
Debes instalar y configurar todas las dependencias manualmente:
|
|
148
|
+
|
|
149
|
+
#### 1. Instala las dependencias nativas:
|
|
150
|
+
```sh
|
|
151
|
+
npm install expo-image expo-constants lottie-react-native react-native-reanimated react-native-gesture-handler @gorhom/bottom-sheet
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### 2. Para iOS, instala los pods:
|
|
155
|
+
```sh
|
|
156
|
+
cd ios && pod install && cd ..
|
|
157
|
+
```
|
|
98
158
|
|
|
99
|
-
|
|
159
|
+
#### 3. Configura react-native-reanimated:
|
|
160
|
+
Añade el plugin en tu `babel.config.js` (debe ser el último plugin):
|
|
161
|
+
```javascript
|
|
162
|
+
module.exports = {
|
|
163
|
+
presets: ['module:@react-native/babel-preset'],
|
|
164
|
+
plugins: ['react-native-reanimated/plugin'],
|
|
165
|
+
};
|
|
166
|
+
```
|
|
100
167
|
|
|
101
|
-
|
|
168
|
+
#### 4. Configura react-native-gesture-handler:
|
|
169
|
+
En tu archivo de entrada (`index.js` o `App.tsx`), importa al inicio:
|
|
170
|
+
```typescript
|
|
171
|
+
import 'react-native-gesture-handler';
|
|
172
|
+
```
|
|
102
173
|
|
|
103
|
-
|
|
174
|
+
#### 5. Limpia y reconstruye:
|
|
104
175
|
```sh
|
|
105
|
-
|
|
176
|
+
# Android
|
|
177
|
+
npx react-native start --reset-cache
|
|
178
|
+
npx react-native run-android
|
|
179
|
+
|
|
180
|
+
# iOS
|
|
181
|
+
npx react-native start --reset-cache
|
|
182
|
+
npx react-native run-ios
|
|
106
183
|
```
|
|
107
184
|
|
|
185
|
+
### 📚 Información adicional sobre las dependencias
|
|
186
|
+
|
|
187
|
+
| Dependencia | Propósito | Componentes que la usan |
|
|
188
|
+
| :---------- | :-------- | :---------------------- |
|
|
189
|
+
| **dropi-lib-icons** | Sistema de íconos de Dropi | Todos los componentes con íconos |
|
|
190
|
+
| **expo-image** | Carga optimizada de imágenes | CustomImage |
|
|
191
|
+
| **expo-constants** | Información del dispositivo | Tokens de spacing y sizes |
|
|
192
|
+
| **lottie-react-native** | Animaciones Lottie | EmptyState, componentes con animaciones |
|
|
193
|
+
| **react-native-reanimated** | Animaciones fluidas de alto rendimiento | BottomSheet, transiciones |
|
|
194
|
+
| **react-native-gesture-handler** | Gestos táctiles avanzados | BottomSheet, componentes interactivos |
|
|
195
|
+
| **@gorhom/bottom-sheet** | Modales deslizables desde abajo | BottomSheetComponent, Select |
|
|
196
|
+
|
|
108
197
|
# Tokens
|
|
109
198
|
|
|
110
199
|
## Radius
|
|
@@ -412,6 +501,70 @@ import { TextButton } from "@dropi/react-native-design-system";
|
|
|
412
501
|
|
|
413
502
|
```
|
|
414
503
|
|
|
504
|
+
## Imágenes
|
|
505
|
+
|
|
506
|
+
## Custom Image
|
|
507
|
+
|
|
508
|
+
El componente `CustomImage` es un wrapper optimizado del componente `Image` de `expo-image` que agrega **soporte automático para imágenes de respaldo (fallback)** en caso de error de carga. Está diseñado para manejar elegantemente errores de carga de imágenes, mostrando una imagen alternativa cuando la fuente principal falla o no está disponible. Incluye transiciones suaves, soporte para placeholders, y manejo inteligente de fuentes locales y remotas.
|
|
509
|
+
|
|
510
|
+
### 📦 Importación:
|
|
511
|
+
```Typescript
|
|
512
|
+
import { CustomImage } from '@dropi/react-native-design-system';
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### ⚙️ Props:
|
|
516
|
+
| Prop | Tipo | Descripción |
|
|
517
|
+
| :-------------- | :------------------------ | :------------------------------------------------------------------------------------------- |
|
|
518
|
+
| source | string \| number | Fuente principal de la imagen. Puede ser una URI (string) o un recurso local (require). |
|
|
519
|
+
| fallbackSource | string \| number | *(Opcional)* Imagen de respaldo mostrada si `source` falla o está vacía. |
|
|
520
|
+
| contentFit | ContentFit | *(Opcional)* Modo de ajuste de la imagen. Por defecto: `'cover'`. |
|
|
521
|
+
| ...rest | ImageProps (expo-image) | Todas las props nativas del componente Image de expo-image. |
|
|
522
|
+
|
|
523
|
+
### 🔧 Características:
|
|
524
|
+
- **Fallback automático**: Si la imagen principal no carga o falla, muestra automáticamente `fallbackSource`.
|
|
525
|
+
- **Placeholder inteligente**: Usa `fallbackSource` como placeholder mientras carga la imagen principal.
|
|
526
|
+
- **Transición suave**: Incluye una transición de 200ms entre estados de carga.
|
|
527
|
+
- **Manejo de errores**: Detecta errores de carga mediante el evento `onError` y cambia a la imagen de respaldo.
|
|
528
|
+
- **Normalización de fuentes**: Maneja tanto URIs (strings) como recursos locales (require) de forma transparente.
|
|
529
|
+
- **Renderizado condicional**: No renderiza nada si no hay fuente válida disponible.
|
|
530
|
+
|
|
531
|
+
### 🧩 Ejemplos de uso:
|
|
532
|
+
```Typescript
|
|
533
|
+
// Imagen con fallback remoto
|
|
534
|
+
<CustomImage
|
|
535
|
+
source="https://example.com/product.jpg"
|
|
536
|
+
fallbackSource="https://example.com/placeholder.jpg"
|
|
537
|
+
style={{ width: 200, height: 200 }}
|
|
538
|
+
contentFit="cover"
|
|
539
|
+
/>
|
|
540
|
+
|
|
541
|
+
// Imagen con fallback local
|
|
542
|
+
<CustomImage
|
|
543
|
+
source={{ uri: profileImageUrl }}
|
|
544
|
+
fallbackSource={require('./assets/default-avatar.png')}
|
|
545
|
+
style={{ width: 100, height: 100, borderRadius: 50 }}
|
|
546
|
+
contentFit="cover"
|
|
547
|
+
/>
|
|
548
|
+
|
|
549
|
+
// Imagen que solo usa fallback si source está vacío
|
|
550
|
+
<CustomImage
|
|
551
|
+
source={product.imageUrl || ''}
|
|
552
|
+
fallbackSource={require('./assets/no-image.png')}
|
|
553
|
+
style={{ width: 300, height: 200 }}
|
|
554
|
+
contentFit="contain"
|
|
555
|
+
/>
|
|
556
|
+
|
|
557
|
+
// Con todas las props de expo-image
|
|
558
|
+
<CustomImage
|
|
559
|
+
source="https://api.example.com/image.jpg"
|
|
560
|
+
fallbackSource="https://example.com/fallback.jpg"
|
|
561
|
+
style={{ width: '100%', height: 400 }}
|
|
562
|
+
contentFit="cover"
|
|
563
|
+
transition={500}
|
|
564
|
+
cachePolicy="memory-disk"
|
|
565
|
+
/>
|
|
566
|
+
```
|
|
567
|
+
|
|
415
568
|
## Moléculas
|
|
416
569
|
|
|
417
570
|
## Alert
|
|
@@ -6,13 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.InputLabel = void 0;
|
|
7
7
|
var _atoms = require("../../../atoms");
|
|
8
8
|
var _constants = require("../../../constants");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
9
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
11
|
const InputLabel = ({
|
|
11
12
|
text
|
|
12
13
|
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_atoms.Body, {
|
|
13
14
|
type: "m-regular",
|
|
14
15
|
style: {
|
|
15
|
-
color: _constants.colors["Gray-600"].light
|
|
16
|
+
color: _constants.colors["Gray-600"].light,
|
|
17
|
+
marginBottom: _constants.spacing["size-1"],
|
|
18
|
+
...(_reactNative.Platform.OS === 'android' && {
|
|
19
|
+
includeFontPadding: false
|
|
20
|
+
})
|
|
16
21
|
},
|
|
17
22
|
children: text
|
|
18
23
|
});
|
|
@@ -17,7 +17,6 @@ var _default = exports.default = _reactNative.StyleSheet.create({
|
|
|
17
17
|
borderWidth: 1,
|
|
18
18
|
justifyContent: "space-between",
|
|
19
19
|
flexDirection: "row",
|
|
20
|
-
marginTop: _constants.spacing["size-2"],
|
|
21
20
|
height: 48,
|
|
22
21
|
paddingHorizontal: _constants.spacing["size-3"],
|
|
23
22
|
paddingVertical: _constants.spacing["size-2"]
|