responsive-system 1.3.0 → 1.4.0
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 +23 -364
- package/package.json +2 -4
- package/scripts/postinstall.js +293 -84
- package/ARCHITECTURE.md +0 -195
- package/INSTALLATION.md +0 -403
package/INSTALLATION.md
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
# 📦 Instalación en Proyecto Existente
|
|
2
|
-
|
|
3
|
-
## ¿Es invasivo este sistema?
|
|
4
|
-
|
|
5
|
-
**RESPUESTA CORTA: NO, es completamente modular y no invasivo.**
|
|
6
|
-
|
|
7
|
-
El sistema se divide en **2 partes independientes**:
|
|
8
|
-
|
|
9
|
-
1. **Sistema de Auto-Scaling** (Plugin de Tailwind) - ⚠️ Requiere configuración
|
|
10
|
-
2. **Sistema de Layouts** (Componentes React) - ✅ Completamente opcional
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 🎯 Nivel de Invasividad
|
|
15
|
-
|
|
16
|
-
### ✅ **BAJO IMPACTO** - Solo Auto-Scaling
|
|
17
|
-
|
|
18
|
-
Si **solo quieres el auto-scaling** (sin layouts):
|
|
19
|
-
|
|
20
|
-
**Archivos a copiar:** `1 archivo`
|
|
21
|
-
```
|
|
22
|
-
src/plugin/responsiveScalePlugin.js
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Archivos a modificar:** `1 archivo`
|
|
26
|
-
```
|
|
27
|
-
tailwind.config.js (agregar plugin)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**¿Rompe código existente?** **NO**
|
|
31
|
-
- El plugin solo agrega CSS variables nuevas
|
|
32
|
-
- No modifica clases existentes de Tailwind
|
|
33
|
-
- Tu código actual sigue funcionando igual
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
### ⚠️ **MEDIO IMPACTO** - Con Providers
|
|
38
|
-
|
|
39
|
-
Si quieres usar **hooks** (`useResponsive`, etc.):
|
|
40
|
-
|
|
41
|
-
**Archivos a copiar:** `~10 archivos`
|
|
42
|
-
```
|
|
43
|
-
src/plugin/responsiveScalePlugin.js
|
|
44
|
-
src/providers/ResponsiveProvider.tsx
|
|
45
|
-
src/hooks/useResponsive.ts
|
|
46
|
-
src/constants/breakpoints.ts
|
|
47
|
-
src/types/responsive.ts
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Archivos a modificar:** `2 archivos`
|
|
51
|
-
```
|
|
52
|
-
tailwind.config.js (agregar plugin)
|
|
53
|
-
App.tsx (envolver con provider)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**¿Rompe código existente?** **NO**
|
|
57
|
-
- Solo necesitas agregar `<ResponsiveProvider>` en tu App
|
|
58
|
-
- No afecta componentes existentes
|
|
59
|
-
- Puedes usar solo en componentes nuevos
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
### 🔧 **ALTO IMPACTO** - Sistema Completo + Layouts
|
|
64
|
-
|
|
65
|
-
Si quieres **todo el sistema** (auto-scaling + layouts + hooks):
|
|
66
|
-
|
|
67
|
-
**Archivos a copiar:** `~30 archivos`
|
|
68
|
-
|
|
69
|
-
**Archivos a modificar:** `2-3 archivos`
|
|
70
|
-
```
|
|
71
|
-
tailwind.config.js
|
|
72
|
-
App.tsx
|
|
73
|
-
package.json (si faltan dependencias)
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**¿Rompe código existente?** **DEPENDE**
|
|
77
|
-
- Si usas `MainLayout`, necesitas adaptar tu estructura
|
|
78
|
-
- Tus componentes existentes **NO se rompen**
|
|
79
|
-
- Puedes migrar progresivamente
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## 📋 Guía de Instalación Paso a Paso
|
|
84
|
-
|
|
85
|
-
### **OPCIÓN 1: Solo Auto-Scaling** ⭐ **RECOMENDADA PARA EMPEZAR**
|
|
86
|
-
|
|
87
|
-
#### 1. Copiar el plugin
|
|
88
|
-
```bash
|
|
89
|
-
# Crear carpeta
|
|
90
|
-
mkdir -p src/plugin
|
|
91
|
-
|
|
92
|
-
# Copiar archivo
|
|
93
|
-
cp responsiveScalePlugin.js src/plugin/
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
#### 2. Modificar `tailwind.config.js`
|
|
97
|
-
```js
|
|
98
|
-
import responsiveScalePlugin from './src/plugin/responsiveScalePlugin.js'
|
|
99
|
-
|
|
100
|
-
export default {
|
|
101
|
-
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
|
102
|
-
theme: {
|
|
103
|
-
extend: {
|
|
104
|
-
screens: {
|
|
105
|
-
'xs': '475px',
|
|
106
|
-
'sm': '640px',
|
|
107
|
-
'md': '768px',
|
|
108
|
-
'lg': '1024px',
|
|
109
|
-
'xl': '1280px',
|
|
110
|
-
'2xl': '1536px',
|
|
111
|
-
'3xl': '1920px', // 👈 Nuevo
|
|
112
|
-
'4xl': '2560px', // 👈 Nuevo
|
|
113
|
-
'5xl': '3840px', // 👈 Nuevo (4K)
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
plugins: [
|
|
118
|
-
responsiveScalePlugin({
|
|
119
|
-
scaleProperties: {
|
|
120
|
-
typography: true, // font-size se escala
|
|
121
|
-
spacing: true, // padding, margin, gap se escalan
|
|
122
|
-
lineHeight: true, // line-height se escala
|
|
123
|
-
letterSpacing: true, // letter-spacing se escala
|
|
124
|
-
shadows: true, // box-shadow se escala
|
|
125
|
-
borderWidth: false, // border-width NO se escala (puede romper)
|
|
126
|
-
sizing: false, // width, height NO se escalan (puede romper)
|
|
127
|
-
borderRadius: false // rounded-* NO se escala (mantener fijo)
|
|
128
|
-
},
|
|
129
|
-
scales: {
|
|
130
|
-
xs: 1.0,
|
|
131
|
-
sm: 1.0,
|
|
132
|
-
md: 1.0,
|
|
133
|
-
lg: 1.0,
|
|
134
|
-
xl: 1.0,
|
|
135
|
-
'2xl': 1.05, // +5% en 1536px
|
|
136
|
-
'3xl': 1.15, // +15% en 1920px (Full HD)
|
|
137
|
-
'4xl': 1.25, // +25% en 2560px (2K)
|
|
138
|
-
'5xl': 1.35 // +35% en 3840px (4K)
|
|
139
|
-
},
|
|
140
|
-
breakpoints: {
|
|
141
|
-
xs: '475px',
|
|
142
|
-
sm: '640px',
|
|
143
|
-
md: '768px',
|
|
144
|
-
lg: '1024px',
|
|
145
|
-
xl: '1280px',
|
|
146
|
-
'2xl': '1536px',
|
|
147
|
-
'3xl': '1920px',
|
|
148
|
-
'4xl': '2560px',
|
|
149
|
-
'5xl': '3840px'
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
],
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
#### 3. ¡Listo! 🎉
|
|
157
|
-
|
|
158
|
-
**Ya funciona.** Ahora puedes usar:
|
|
159
|
-
|
|
160
|
-
```tsx
|
|
161
|
-
// Componente existente
|
|
162
|
-
function MyButton() {
|
|
163
|
-
return (
|
|
164
|
-
<button className="px-4 py-2 text-base">
|
|
165
|
-
Click me
|
|
166
|
-
</button>
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// En móvil: px-4 = 16px
|
|
171
|
-
// En 4K: px-4 = 21.6px (escalado automáticamente)
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**✅ Ventajas:**
|
|
175
|
-
- Cero cambios en tu código
|
|
176
|
-
- Compatible con cualquier proyecto Tailwind
|
|
177
|
-
- No rompe nada existente
|
|
178
|
-
- Puedes ajustar `scales` a tu gusto
|
|
179
|
-
|
|
180
|
-
**❌ Limitaciones:**
|
|
181
|
-
- No tienes acceso a hooks (`useResponsive`, `isMobile`, etc.)
|
|
182
|
-
- No puedes detectar breakpoints en JavaScript
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
### **OPCIÓN 2: Con Hooks** (Detección de Breakpoints)
|
|
187
|
-
|
|
188
|
-
Si necesitas **detectar breakpoints en JavaScript** (ej: `isMobile`, `isTablet`):
|
|
189
|
-
|
|
190
|
-
#### 1. Instalar OPCIÓN 1 primero
|
|
191
|
-
|
|
192
|
-
#### 2. Copiar archivos adicionales
|
|
193
|
-
```bash
|
|
194
|
-
mkdir -p src/providers src/hooks src/constants src/types
|
|
195
|
-
|
|
196
|
-
# Copiar archivos core
|
|
197
|
-
cp ResponsiveProvider.tsx src/providers/
|
|
198
|
-
cp useResponsive.ts src/hooks/
|
|
199
|
-
cp breakpoints.ts src/constants/
|
|
200
|
-
cp responsive.ts src/types/
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
#### 3. Envolver tu App
|
|
204
|
-
```tsx
|
|
205
|
-
// App.tsx (ANTES)
|
|
206
|
-
function App() {
|
|
207
|
-
return <YourExistingApp />
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// App.tsx (DESPUÉS)
|
|
211
|
-
import { ResponsiveProvider } from './providers/ResponsiveProvider'
|
|
212
|
-
|
|
213
|
-
function App() {
|
|
214
|
-
return (
|
|
215
|
-
<ResponsiveProvider>
|
|
216
|
-
<YourExistingApp />
|
|
217
|
-
</ResponsiveProvider>
|
|
218
|
-
)
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
#### 4. Usar en componentes
|
|
223
|
-
```tsx
|
|
224
|
-
import { useResponsive } from './hooks/useResponsive'
|
|
225
|
-
|
|
226
|
-
function MyComponent() {
|
|
227
|
-
const { isMobile, isTablet, currentBreakpoint } = useResponsive()
|
|
228
|
-
|
|
229
|
-
return (
|
|
230
|
-
<div>
|
|
231
|
-
{isMobile && <MobileMenu />}
|
|
232
|
-
{isTablet && <TabletView />}
|
|
233
|
-
<p>Breakpoint actual: {currentBreakpoint}</p>
|
|
234
|
-
</div>
|
|
235
|
-
)
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
**✅ Ventajas adicionales:**
|
|
240
|
-
- Detección de breakpoints en JS
|
|
241
|
-
- Helpers booleanos (isMobile, isTablet, etc.)
|
|
242
|
-
- Condicionales responsive sin CSS
|
|
243
|
-
|
|
244
|
-
**⚠️ Consideración:**
|
|
245
|
-
- Agrega 1 provider a tu App
|
|
246
|
-
- Agrega ~50KB al bundle (hooks + context)
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
### **OPCIÓN 3: Sistema Completo** (Con Layouts)
|
|
251
|
-
|
|
252
|
-
Si quieres **layouts preconfigurados** (tipo Ant Design):
|
|
253
|
-
|
|
254
|
-
#### 1. Instalar OPCIÓN 2 primero
|
|
255
|
-
|
|
256
|
-
#### 2. Copiar carpetas adicionales
|
|
257
|
-
```bash
|
|
258
|
-
mkdir -p src/layouts src/components/layout src/context
|
|
259
|
-
|
|
260
|
-
# Copiar todo el sistema de layouts
|
|
261
|
-
cp -r layouts/* src/layouts/
|
|
262
|
-
cp -r components/layout/* src/components/layout/
|
|
263
|
-
cp -r context/* src/context/
|
|
264
|
-
cp ResponsiveLayoutProvider.tsx src/providers/
|
|
265
|
-
cp useResponsiveLayout.ts src/hooks/
|
|
266
|
-
cp useLayout.ts src/hooks/
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
#### 3. Modificar App.tsx
|
|
270
|
-
```tsx
|
|
271
|
-
// App.tsx
|
|
272
|
-
import { ResponsiveLayoutProvider, MainLayout } from './index'
|
|
273
|
-
|
|
274
|
-
function App() {
|
|
275
|
-
return (
|
|
276
|
-
<ResponsiveLayoutProvider defaultLayout="default">
|
|
277
|
-
<MainLayout>
|
|
278
|
-
<YourExistingApp />
|
|
279
|
-
</MainLayout>
|
|
280
|
-
</ResponsiveLayoutProvider>
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
#### 4. Usar layouts
|
|
286
|
-
```tsx
|
|
287
|
-
import { useResponsiveLayout } from './hooks'
|
|
288
|
-
|
|
289
|
-
function MyPage() {
|
|
290
|
-
const { layout } = useResponsiveLayout()
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<div>
|
|
294
|
-
<h1>Mi Página</h1>
|
|
295
|
-
<p>Layout actual: {layout.current}</p>
|
|
296
|
-
|
|
297
|
-
<button onClick={() => layout.setLayout('sidebar')}>
|
|
298
|
-
Cambiar a Sidebar
|
|
299
|
-
</button>
|
|
300
|
-
</div>
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
**✅ Ventajas adicionales:**
|
|
306
|
-
- Layouts listos para usar (Default, Sidebar, Dashboard, Minimal)
|
|
307
|
-
- Navbar, Sidebar, Footer incluidos
|
|
308
|
-
- Cambio dinámico de layout
|
|
309
|
-
|
|
310
|
-
**⚠️ Consideraciones:**
|
|
311
|
-
- Sistema más complejo (~30 archivos)
|
|
312
|
-
- Puede requerir adaptar tu estructura actual
|
|
313
|
-
- Si ya tienes un layout, puede generar conflictos
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## 🔍 Comparación de Opciones
|
|
318
|
-
|
|
319
|
-
| Característica | Solo Plugin | Con Hooks | Completo |
|
|
320
|
-
|---|---|---|---|
|
|
321
|
-
| **Archivos a copiar** | 1 | ~8 | ~30 |
|
|
322
|
-
| **Archivos a modificar** | 1 | 2 | 2-3 |
|
|
323
|
-
| **Auto-scaling CSS** | ✅ | ✅ | ✅ |
|
|
324
|
-
| **Detección de breakpoints** | ❌ | ✅ | ✅ |
|
|
325
|
-
| **Helpers booleanos** | ❌ | ✅ | ✅ |
|
|
326
|
-
| **Layouts preconfigurados** | ❌ | ❌ | ✅ |
|
|
327
|
-
| **Cambio dinámico de layout** | ❌ | ❌ | ✅ |
|
|
328
|
-
| **Invasividad** | ⬇️ Baja | ⬇️ Media | ⬆️ Alta |
|
|
329
|
-
| **Bundle size** | +5KB | +50KB | +150KB |
|
|
330
|
-
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
## ⚡ Recomendación
|
|
334
|
-
|
|
335
|
-
### Para un **proyecto nuevo**:
|
|
336
|
-
👉 **OPCIÓN 3** (Sistema completo) - Aprovecha todo
|
|
337
|
-
|
|
338
|
-
### Para un **proyecto existente pequeño**:
|
|
339
|
-
👉 **OPCIÓN 2** (Con hooks) - Buen balance
|
|
340
|
-
|
|
341
|
-
### Para un **proyecto existente grande/complejo**:
|
|
342
|
-
👉 **OPCIÓN 1** (Solo plugin) - Mínima invasión
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
## 🚨 ¿Puede romper algo?
|
|
347
|
-
|
|
348
|
-
### **NO romperá:**
|
|
349
|
-
- ✅ Componentes existentes
|
|
350
|
-
- ✅ Estilos actuales de Tailwind
|
|
351
|
-
- ✅ Otras librerías CSS
|
|
352
|
-
- ✅ Funcionalidad de la app
|
|
353
|
-
|
|
354
|
-
### **PUEDE conflictuar con:**
|
|
355
|
-
- ⚠️ Otros plugins de Tailwind que modifiquen las mismas propiedades
|
|
356
|
-
- ⚠️ Sistemas de layout existentes (si usas OPCIÓN 3)
|
|
357
|
-
- ⚠️ CSS custom que dependa de valores fijos de Tailwind
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
## 🧪 Modo de Prueba
|
|
362
|
-
|
|
363
|
-
**Recomendación:** Prueba primero en una **rama separada**
|
|
364
|
-
|
|
365
|
-
```bash
|
|
366
|
-
# Crear rama de prueba
|
|
367
|
-
git checkout -b test-responsive-system
|
|
368
|
-
|
|
369
|
-
# Instalar OPCIÓN 1
|
|
370
|
-
# ... copiar archivo y modificar config
|
|
371
|
-
|
|
372
|
-
# Probar en desarrollo
|
|
373
|
-
npm run dev
|
|
374
|
-
|
|
375
|
-
# Si funciona bien, mergear
|
|
376
|
-
git checkout main
|
|
377
|
-
git merge test-responsive-system
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
---
|
|
381
|
-
|
|
382
|
-
## 📞 Soporte
|
|
383
|
-
|
|
384
|
-
Si encuentras problemas:
|
|
385
|
-
|
|
386
|
-
1. Verifica que Tailwind CSS v4+ esté instalado
|
|
387
|
-
2. Revisa que el plugin se esté importando correctamente
|
|
388
|
-
3. Verifica que los breakpoints coincidan en `theme.extend.screens` y en el plugin
|
|
389
|
-
4. Abre un issue en GitHub
|
|
390
|
-
|
|
391
|
-
---
|
|
392
|
-
|
|
393
|
-
## 🎯 Conclusión
|
|
394
|
-
|
|
395
|
-
**El sistema NO es invasivo** si usas solo el plugin (OPCIÓN 1).
|
|
396
|
-
|
|
397
|
-
**Es progresivamente más invasivo** si agregas hooks y layouts, pero siempre:
|
|
398
|
-
- ✅ Sin romper código existente
|
|
399
|
-
- ✅ Modular (usa solo lo que necesites)
|
|
400
|
-
- ✅ Fácil de remover si no te gusta
|
|
401
|
-
|
|
402
|
-
**Empieza con OPCIÓN 1, y escala según necesites.** 🚀
|
|
403
|
-
|