responsive-system 1.3.0 → 1.3.2
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/package.json +1 -1
- package/scripts/postinstall.js +394 -84
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -31,6 +31,9 @@ console.log('')
|
|
|
31
31
|
console.log('📦 responsive-system: Iniciando configuración...')
|
|
32
32
|
console.log(` Directorio: ${projectRoot}`)
|
|
33
33
|
console.log('')
|
|
34
|
+
console.log('💡 Si este es tu primer uso, este script configurará todo automáticamente.')
|
|
35
|
+
console.log(' Si ya tienes el proyecto configurado, puedes cancelar (Ctrl+C)')
|
|
36
|
+
console.log('')
|
|
34
37
|
|
|
35
38
|
// Verificar si package.json existe
|
|
36
39
|
if (!fs.existsSync(packageJsonPath)) {
|
|
@@ -146,8 +149,8 @@ function copyFileFromPackage(relativePath, targetPath, isComponent = false) {
|
|
|
146
149
|
return true
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
// Función para
|
|
150
|
-
function
|
|
152
|
+
// Función para generar componentes genéricos según el layout seleccionado
|
|
153
|
+
function generateLayoutComponents(selectedLayout) {
|
|
151
154
|
const componentsDir = path.join(projectRoot, 'src', 'components', 'layout')
|
|
152
155
|
|
|
153
156
|
// Crear directorio si no existe
|
|
@@ -155,29 +158,199 @@ function copyLayoutComponents(selectedLayout) {
|
|
|
155
158
|
fs.mkdirSync(componentsDir, { recursive: true })
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
const
|
|
161
|
+
const componentsToGenerate = {
|
|
159
162
|
default: ['Navigation', 'Footer'],
|
|
160
163
|
sidebar: ['Sidebar'],
|
|
161
164
|
dashboard: ['Sidebar', 'Footer'],
|
|
162
165
|
minimal: []
|
|
163
166
|
}
|
|
164
167
|
|
|
165
|
-
const components =
|
|
168
|
+
const components = componentsToGenerate[selectedLayout] || []
|
|
166
169
|
|
|
167
170
|
if (components.length === 0) {
|
|
168
|
-
console.log(' ✅ Layout minimal: No se
|
|
171
|
+
console.log(' ✅ Layout minimal: No se generan componentes')
|
|
169
172
|
return
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
console.log(` 📦
|
|
175
|
+
console.log(` 📦 Generando componentes genéricos para layout "${selectedLayout}":`)
|
|
173
176
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
// Generar Navigation genérico
|
|
178
|
+
if (components.includes('Navigation')) {
|
|
179
|
+
const navigationContent = `import { useResponsiveLayout } from 'responsive-system'
|
|
180
|
+
|
|
181
|
+
const Navigation = () => {
|
|
182
|
+
const { isMobile, breakpoint } = useResponsiveLayout()
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<nav className="sticky top-0 z-50 bg-gray-900 border-b border-gray-800">
|
|
186
|
+
<div className="px-4 py-4">
|
|
187
|
+
<div className="flex items-center justify-between">
|
|
188
|
+
<div className="flex items-center space-x-3">
|
|
189
|
+
<div className="w-8 h-8 bg-blue-500 rounded-lg flex items-center justify-center">
|
|
190
|
+
<span className="text-white font-bold text-sm">LO</span>
|
|
191
|
+
</div>
|
|
192
|
+
<h1 className="text-white font-semibold text-lg">Tu Aplicación</h1>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
{isMobile && (
|
|
196
|
+
<button className="p-2 text-gray-400 hover:text-white">
|
|
197
|
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
198
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
|
|
199
|
+
</svg>
|
|
200
|
+
</button>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
</nav>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export default Navigation
|
|
209
|
+
`
|
|
210
|
+
fs.writeFileSync(path.join(componentsDir, 'Navigation.tsx'), navigationContent)
|
|
211
|
+
console.log(' ✅ Navigation.tsx (genérico)')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Generar Footer genérico
|
|
215
|
+
if (components.includes('Footer')) {
|
|
216
|
+
const footerContent = `import { useResponsiveLayout } from 'responsive-system'
|
|
217
|
+
|
|
218
|
+
const Footer = () => {
|
|
219
|
+
const { breakpoint } = useResponsiveLayout()
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<footer className="bg-gray-900 border-t border-gray-800">
|
|
223
|
+
<div className="px-4 py-6">
|
|
224
|
+
<div className="max-w-7xl mx-auto">
|
|
225
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
226
|
+
<div>
|
|
227
|
+
<h3 className="text-white font-semibold mb-2">Tu Aplicación</h3>
|
|
228
|
+
<p className="text-gray-400 text-sm">
|
|
229
|
+
Descripción de tu aplicación aquí.
|
|
230
|
+
</p>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div>
|
|
234
|
+
<h3 className="text-white font-semibold mb-2">Enlaces</h3>
|
|
235
|
+
<ul className="space-y-1 text-gray-400 text-sm">
|
|
236
|
+
<li><a href="#" className="hover:text-white">Inicio</a></li>
|
|
237
|
+
<li><a href="#" className="hover:text-white">Acerca</a></li>
|
|
238
|
+
<li><a href="#" className="hover:text-white">Contacto</a></li>
|
|
239
|
+
</ul>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div>
|
|
243
|
+
<h3 className="text-white font-semibold mb-2">Info</h3>
|
|
244
|
+
<p className="text-gray-400 text-xs">
|
|
245
|
+
Breakpoint: <span className="text-blue-400">{breakpoint.toUpperCase()}</span>
|
|
246
|
+
</p>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div className="border-t border-gray-800 mt-6 pt-4 text-center">
|
|
251
|
+
<p className="text-gray-500 text-xs">
|
|
252
|
+
© {new Date().getFullYear()} Tu Aplicación. Todos los derechos reservados.
|
|
253
|
+
</p>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</footer>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export default Footer
|
|
262
|
+
`
|
|
263
|
+
fs.writeFileSync(path.join(componentsDir, 'Footer.tsx'), footerContent)
|
|
264
|
+
console.log(' ✅ Footer.tsx (genérico)')
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Generar Sidebar genérico
|
|
268
|
+
if (components.includes('Sidebar')) {
|
|
269
|
+
const sidebarContent = `import { useResponsiveLayout } from 'responsive-system'
|
|
270
|
+
import { useSidebar } from 'responsive-system'
|
|
271
|
+
|
|
272
|
+
const Sidebar = () => {
|
|
273
|
+
const { isMobile, isTablet } = useResponsiveLayout()
|
|
274
|
+
const { sidebarOpen, setSidebarOpen } = useSidebar()
|
|
275
|
+
|
|
276
|
+
const menuItems = [
|
|
277
|
+
{ id: 'home', label: 'Inicio' },
|
|
278
|
+
{ id: 'about', label: 'Acerca' },
|
|
279
|
+
{ id: 'contact', label: 'Contacto' },
|
|
280
|
+
]
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<>
|
|
284
|
+
{/* Hamburger button para móvil */}
|
|
285
|
+
{isMobile && (
|
|
286
|
+
<button
|
|
287
|
+
onClick={() => setSidebarOpen(true)}
|
|
288
|
+
className="fixed top-4 left-4 z-50 p-2 rounded-lg text-gray-300 hover:text-white hover:bg-gray-800 bg-gray-900 border border-gray-700"
|
|
289
|
+
>
|
|
290
|
+
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
291
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
|
|
292
|
+
</svg>
|
|
293
|
+
</button>
|
|
294
|
+
)}
|
|
295
|
+
|
|
296
|
+
{/* Sidebar desktop */}
|
|
297
|
+
<aside className={\`bg-gray-900 border-r border-gray-800 \${isMobile ? 'hidden' : 'w-64 flex-shrink-0'} \${isTablet ? 'w-56' : 'w-64'}\`}>
|
|
298
|
+
<div className="p-6 flex flex-col h-full">
|
|
299
|
+
<div className="flex items-center space-x-3 mb-8">
|
|
300
|
+
<div className="w-8 h-8 bg-blue-500 rounded-lg flex items-center justify-center">
|
|
301
|
+
<span className="text-white font-bold text-sm">LO</span>
|
|
302
|
+
</div>
|
|
303
|
+
<span className="text-white font-bold text-lg">Tu Aplicación</span>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
<nav className="space-y-2">
|
|
307
|
+
{menuItems.map((item) => (
|
|
308
|
+
<button
|
|
309
|
+
key={item.id}
|
|
310
|
+
className="w-full flex items-center px-4 py-3 rounded-lg transition-all text-left text-gray-300 hover:text-white hover:bg-gray-800"
|
|
311
|
+
>
|
|
312
|
+
<span className="font-medium">{item.label}</span>
|
|
313
|
+
</button>
|
|
314
|
+
))}
|
|
315
|
+
</nav>
|
|
316
|
+
</div>
|
|
317
|
+
</aside>
|
|
318
|
+
|
|
319
|
+
{/* Sidebar móvil desplegable */}
|
|
320
|
+
{isMobile && sidebarOpen && (
|
|
321
|
+
<div className="fixed inset-0 z-40 bg-black/50" onClick={() => setSidebarOpen(false)}>
|
|
322
|
+
<div className="fixed top-0 left-0 w-64 h-full bg-gray-900 border-r border-gray-800">
|
|
323
|
+
<div className="p-6 flex flex-col h-full pt-20">
|
|
324
|
+
<div className="flex items-center space-x-3 mb-8">
|
|
325
|
+
<div className="w-8 h-8 bg-blue-500 rounded-lg flex items-center justify-center">
|
|
326
|
+
<span className="text-white font-bold text-sm">LO</span>
|
|
327
|
+
</div>
|
|
328
|
+
<span className="text-white font-bold text-lg">Tu Aplicación</span>
|
|
329
|
+
</div>
|
|
330
|
+
|
|
331
|
+
<nav className="space-y-2">
|
|
332
|
+
{menuItems.map((item) => (
|
|
333
|
+
<button
|
|
334
|
+
key={item.id}
|
|
335
|
+
onClick={() => setSidebarOpen(false)}
|
|
336
|
+
className="w-full flex items-center px-4 py-3 rounded-lg transition-all text-left text-gray-300 hover:text-white hover:bg-gray-800"
|
|
337
|
+
>
|
|
338
|
+
<span className="font-medium">{item.label}</span>
|
|
339
|
+
</button>
|
|
340
|
+
))}
|
|
341
|
+
</nav>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
)}
|
|
346
|
+
</>
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export default Sidebar
|
|
351
|
+
`
|
|
352
|
+
fs.writeFileSync(path.join(componentsDir, 'Sidebar.tsx'), sidebarContent)
|
|
353
|
+
console.log(' ✅ Sidebar.tsx (genérico)')
|
|
181
354
|
}
|
|
182
355
|
|
|
183
356
|
// Crear index.ts para exportar los componentes
|
|
@@ -307,10 +480,50 @@ if (needsUpdate) {
|
|
|
307
480
|
console.log('✅ responsive-system: Todas las dependencias ya están en package.json')
|
|
308
481
|
}
|
|
309
482
|
|
|
310
|
-
// Si el proyecto está vacío, crear
|
|
483
|
+
// Si el proyecto está vacío, crear README básico PRIMERO
|
|
311
484
|
if (isProjectEmpty) {
|
|
485
|
+
// Crear README básico INMEDIATAMENTE para que el usuario sepa qué hacer
|
|
486
|
+
const readmePath = path.join(projectRoot, 'README.md')
|
|
487
|
+
if (!fs.existsSync(readmePath)) {
|
|
488
|
+
const basicReadme = `# Tu Aplicación
|
|
489
|
+
|
|
490
|
+
## 🚀 Configuración Inicial
|
|
491
|
+
|
|
492
|
+
Acabas de instalar **responsive-system**. Para completar la configuración, ejecuta:
|
|
493
|
+
|
|
494
|
+
\`\`\`bash
|
|
495
|
+
npx responsive-system-setup
|
|
496
|
+
\`\`\`
|
|
497
|
+
|
|
498
|
+
Este comando:
|
|
499
|
+
- ✅ Instalará React, TypeScript, Tailwind y Vite automáticamente
|
|
500
|
+
- ✅ Te permitirá seleccionar el layout que prefieras
|
|
501
|
+
- ✅ Creará la estructura base del proyecto
|
|
502
|
+
- ✅ Generará componentes genéricos y página de ejemplo
|
|
503
|
+
|
|
504
|
+
## 📦 ¿Qué es responsive-system?
|
|
505
|
+
|
|
506
|
+
Sistema completo de layout responsive con auto-scaling para React + Tailwind CSS.
|
|
507
|
+
|
|
508
|
+
- Auto-scaling automático (texto, espaciado, sombras)
|
|
509
|
+
- Layouts pre-configurados (default, sidebar, dashboard, minimal)
|
|
510
|
+
- Hook \`useResponsive\` para configuración manual
|
|
511
|
+
- Sin media queries necesarias
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
**Siguiente paso:** Ejecuta \`npx responsive-system-setup\` para comenzar 🚀
|
|
516
|
+
`
|
|
517
|
+
fs.writeFileSync(readmePath, basicReadme)
|
|
518
|
+
console.log(' ✅ README.md básico creado con instrucciones')
|
|
519
|
+
}
|
|
520
|
+
|
|
312
521
|
console.log('')
|
|
313
522
|
console.log('📦 responsive-system: Proyecto vacío detectado, creando estructura base...')
|
|
523
|
+
console.log('')
|
|
524
|
+
console.log('💡 IMPORTANTE: Si este es tu primer uso, este script configurará todo automáticamente.')
|
|
525
|
+
console.log(' Si ya tienes el proyecto configurado, puedes cancelar (Ctrl+C)')
|
|
526
|
+
console.log('')
|
|
314
527
|
|
|
315
528
|
// Preguntar qué layout quiere
|
|
316
529
|
const selectedLayout = await askLayout()
|
|
@@ -326,8 +539,8 @@ if (isProjectEmpty) {
|
|
|
326
539
|
}
|
|
327
540
|
})
|
|
328
541
|
|
|
329
|
-
//
|
|
330
|
-
|
|
542
|
+
// Generar componentes genéricos según layout seleccionado
|
|
543
|
+
generateLayoutComponents(selectedLayout)
|
|
331
544
|
console.log('')
|
|
332
545
|
|
|
333
546
|
// Copiar hook useResponsive
|
|
@@ -504,93 +717,84 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
504
717
|
console.log(' ✅ Creado: src/index.css')
|
|
505
718
|
}
|
|
506
719
|
|
|
507
|
-
// Crear src/pages/HomePage.tsx con página de ejemplo
|
|
720
|
+
// Crear src/pages/HomePage.tsx con página de ejemplo simple
|
|
508
721
|
const homePagePath = path.join(projectRoot, 'src', 'pages', 'HomePage.tsx')
|
|
509
722
|
if (!fs.existsSync(homePagePath)) {
|
|
510
|
-
const homePage = `import { useResponsiveLayout
|
|
723
|
+
const homePage = `import { useResponsiveLayout } from 'responsive-system'
|
|
511
724
|
import { useResponsive } from '../hooks'
|
|
512
725
|
|
|
513
726
|
function HomePage() {
|
|
514
|
-
const { breakpoint, isMobile
|
|
727
|
+
const { breakpoint, isMobile } = useResponsiveLayout()
|
|
515
728
|
const responsive = useResponsive()
|
|
516
729
|
|
|
517
730
|
return (
|
|
518
|
-
<div className="min-h-screen bg-gray-50
|
|
519
|
-
<div className="max-w-7xl mx-auto space-y-
|
|
520
|
-
{/*
|
|
521
|
-
<div className="bg-white rounded-lg shadow-
|
|
522
|
-
<h1 className="text-4xl font-bold mb-4">
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
<p className="text-sm text-gray-600">Layout actual</p>
|
|
530
|
-
<p className="text-2xl font-bold capitalize">{layout.current}</p>
|
|
531
|
-
</div>
|
|
532
|
-
<div className="p-4 bg-purple-50 rounded">
|
|
533
|
-
<p className="text-sm text-gray-600">Dispositivo</p>
|
|
534
|
-
<p className="text-2xl font-bold">{isMobile ? 'Móvil' : 'Desktop'}</p>
|
|
535
|
-
</div>
|
|
536
|
-
</div>
|
|
731
|
+
<div className="min-h-screen bg-gray-50 py-8 px-4">
|
|
732
|
+
<div className="max-w-7xl mx-auto space-y-8">
|
|
733
|
+
{/* Hero Section */}
|
|
734
|
+
<div className="bg-white rounded-lg shadow-md p-8 text-center">
|
|
735
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">
|
|
736
|
+
Bienvenido a tu Aplicación
|
|
737
|
+
</h1>
|
|
738
|
+
<p className="text-lg text-gray-600 max-w-2xl mx-auto">
|
|
739
|
+
Esta es una página de ejemplo que demuestra el sistema responsive con auto-scaling.
|
|
740
|
+
Todo el contenido se ajusta automáticamente según el tamaño de pantalla.
|
|
741
|
+
</p>
|
|
537
742
|
</div>
|
|
538
743
|
|
|
539
|
-
{/*
|
|
540
|
-
<div className="
|
|
541
|
-
<
|
|
542
|
-
|
|
744
|
+
{/* Info Cards */}
|
|
745
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
746
|
+
<div className="bg-blue-50 rounded-lg p-6 border border-blue-200">
|
|
747
|
+
<h3 className="text-sm font-semibold text-blue-900 mb-2">Breakpoint</h3>
|
|
748
|
+
<p className="text-2xl font-bold text-blue-700">{breakpoint.toUpperCase()}</p>
|
|
749
|
+
</div>
|
|
750
|
+
<div className="bg-green-50 rounded-lg p-6 border border-green-200">
|
|
751
|
+
<h3 className="text-sm font-semibold text-green-900 mb-2">Dispositivo</h3>
|
|
752
|
+
<p className="text-2xl font-bold text-green-700">{isMobile ? 'Móvil' : 'Desktop'}</p>
|
|
753
|
+
</div>
|
|
754
|
+
<div className="bg-purple-50 rounded-lg p-6 border border-purple-200">
|
|
755
|
+
<h3 className="text-sm font-semibold text-purple-900 mb-2">Ancho</h3>
|
|
756
|
+
<p className="text-2xl font-bold text-purple-700">{responsive.width}px</p>
|
|
757
|
+
</div>
|
|
758
|
+
<div className="bg-orange-50 rounded-lg p-6 border border-orange-200">
|
|
759
|
+
<h3 className="text-sm font-semibold text-orange-900 mb-2">Alto</h3>
|
|
760
|
+
<p className="text-2xl font-bold text-orange-700">{responsive.height}px</p>
|
|
761
|
+
</div>
|
|
543
762
|
</div>
|
|
544
763
|
|
|
545
|
-
{/* Cards
|
|
764
|
+
{/* Content Cards */}
|
|
546
765
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
547
766
|
{[1, 2, 3, 4, 5, 6].map((i) => (
|
|
548
|
-
<div key={i} className="bg-white rounded-lg shadow-
|
|
549
|
-
<
|
|
767
|
+
<div key={i} className="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow">
|
|
768
|
+
<div className="w-12 h-12 bg-blue-500 rounded-lg flex items-center justify-center mb-4">
|
|
769
|
+
<span className="text-white font-bold text-xl">{i}</span>
|
|
770
|
+
</div>
|
|
771
|
+
<h3 className="text-xl font-bold text-gray-900 mb-2">Card {i}</h3>
|
|
550
772
|
<p className="text-gray-600">
|
|
551
|
-
Este es un ejemplo de card
|
|
552
|
-
|
|
773
|
+
Este es un ejemplo de card. El texto, espaciado y sombras se ajustan automáticamente
|
|
774
|
+
según el tamaño de pantalla gracias al sistema de auto-scaling.
|
|
553
775
|
</p>
|
|
554
776
|
</div>
|
|
555
777
|
))}
|
|
556
778
|
</div>
|
|
557
779
|
|
|
558
|
-
{/*
|
|
559
|
-
<div className="bg-white rounded-lg shadow-
|
|
560
|
-
<h2 className="text-2xl font-bold mb-4">
|
|
561
|
-
<
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
<
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
<p className="text-xs text-gray-600">Orientación</p>
|
|
575
|
-
<p className="text-lg font-bold capitalize">{responsive.orientation}</p>
|
|
576
|
-
</div>
|
|
577
|
-
<div className="p-3 bg-gray-50 rounded">
|
|
578
|
-
<p className="text-xs text-gray-600">Desktop</p>
|
|
579
|
-
<p className="text-lg font-bold">{responsive.isDesktop ? 'Sí' : 'No'}</p>
|
|
580
|
-
</div>
|
|
780
|
+
{/* Info Section */}
|
|
781
|
+
<div className="bg-white rounded-lg shadow-md p-8">
|
|
782
|
+
<h2 className="text-2xl font-bold text-gray-900 mb-4">Sistema Responsive</h2>
|
|
783
|
+
<div className="space-y-3 text-gray-700">
|
|
784
|
+
<p>
|
|
785
|
+
<strong className="text-gray-900">Auto-scaling activo:</strong> Todo el contenido escala
|
|
786
|
+
automáticamente según el breakpoint actual (texto, espaciado, sombras).
|
|
787
|
+
</p>
|
|
788
|
+
<p>
|
|
789
|
+
<strong className="text-gray-900">Hook useResponsive:</strong> Disponible en{' '}
|
|
790
|
+
<code className="bg-gray-100 px-2 py-1 rounded text-sm">src/hooks/useResponsive.ts</code>{' '}
|
|
791
|
+
para configuración manual cuando lo necesites.
|
|
792
|
+
</p>
|
|
793
|
+
<p>
|
|
794
|
+
<strong className="text-gray-900">Layout actual:</strong> <span className="capitalize">{selectedLayout}</span>
|
|
795
|
+
</p>
|
|
581
796
|
</div>
|
|
582
797
|
</div>
|
|
583
|
-
|
|
584
|
-
{/* Información */}
|
|
585
|
-
<div className="bg-white rounded-lg shadow-lg p-6">
|
|
586
|
-
<h2 className="text-2xl font-bold mb-4">Cómo funciona</h2>
|
|
587
|
-
<ul className="space-y-2 text-gray-700">
|
|
588
|
-
<li>✅ <strong>Auto-scaling:</strong> Todo escala automáticamente (texto, espaciado, sombras)</li>
|
|
589
|
-
<li>✅ <strong>Layouts:</strong> Cambia entre default, sidebar, dashboard y minimal</li>
|
|
590
|
-
<li>✅ <strong>Responsive:</strong> Se adapta automáticamente a todos los tamaños de pantalla</li>
|
|
591
|
-
<li>✅ <strong>Hook useResponsive:</strong> Disponible localmente para configuración manual</li>
|
|
592
|
-
</ul>
|
|
593
|
-
</div>
|
|
594
798
|
</div>
|
|
595
799
|
</div>
|
|
596
800
|
)
|
|
@@ -599,7 +803,7 @@ function HomePage() {
|
|
|
599
803
|
export default HomePage
|
|
600
804
|
`
|
|
601
805
|
fs.writeFileSync(homePagePath, homePage)
|
|
602
|
-
console.log(' ✅ Creado: src/pages/HomePage.tsx')
|
|
806
|
+
console.log(' ✅ Creado: src/pages/HomePage.tsx (página de ejemplo simple)')
|
|
603
807
|
}
|
|
604
808
|
|
|
605
809
|
// Crear src/App.tsx que importa la página
|
|
@@ -634,6 +838,106 @@ export default App
|
|
|
634
838
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
|
|
635
839
|
console.log(' ✅ Actualizado: package.json con scripts')
|
|
636
840
|
|
|
841
|
+
// Actualizar README.md con información completa
|
|
842
|
+
// Si ya existe (el básico), lo reemplazamos con el completo
|
|
843
|
+
if (fs.existsSync(readmePath)) {
|
|
844
|
+
const readmeContent = `# Tu Aplicación
|
|
845
|
+
|
|
846
|
+
Proyecto inicializado con **responsive-system**.
|
|
847
|
+
|
|
848
|
+
## 🚀 Inicio Rápido
|
|
849
|
+
|
|
850
|
+
Después de instalar el paquete, ejecuta el script de configuración:
|
|
851
|
+
|
|
852
|
+
\`\`\`bash
|
|
853
|
+
npx responsive-system-setup
|
|
854
|
+
\`\`\`
|
|
855
|
+
|
|
856
|
+
O si prefieres ejecutarlo directamente:
|
|
857
|
+
|
|
858
|
+
\`\`\`bash
|
|
859
|
+
node node_modules/responsive-system/scripts/postinstall.js
|
|
860
|
+
\`\`\`
|
|
861
|
+
|
|
862
|
+
Luego inicia el servidor de desarrollo:
|
|
863
|
+
|
|
864
|
+
\`\`\`bash
|
|
865
|
+
npm run dev
|
|
866
|
+
\`\`\`
|
|
867
|
+
|
|
868
|
+
Abre http://localhost:5173 en tu navegador.
|
|
869
|
+
|
|
870
|
+
## 📁 Estructura del Proyecto
|
|
871
|
+
|
|
872
|
+
- \`src/pages/\` - Páginas de tu aplicación
|
|
873
|
+
- \`src/components/layout/\` - Componentes de layout (Navigation, Footer, Sidebar)
|
|
874
|
+
- \`src/hooks/useResponsive.ts\` - Hook para configuración responsive manual
|
|
875
|
+
- \`src/App.tsx\` - Componente principal
|
|
876
|
+
- \`src/main.tsx\` - Punto de entrada
|
|
877
|
+
|
|
878
|
+
## 🎨 Layout Actual
|
|
879
|
+
|
|
880
|
+
Layout seleccionado: **${selectedLayout}**
|
|
881
|
+
|
|
882
|
+
- **default**: Navigation + Footer
|
|
883
|
+
- **sidebar**: Sidebar lateral
|
|
884
|
+
- **dashboard**: Sidebar + Footer
|
|
885
|
+
- **minimal**: Sin componentes (solo contenido)
|
|
886
|
+
|
|
887
|
+
## 🔧 Personalización
|
|
888
|
+
|
|
889
|
+
### Cambiar el Layout
|
|
890
|
+
|
|
891
|
+
Si quieres cambiar el layout después de la instalación:
|
|
892
|
+
|
|
893
|
+
\`\`\`bash
|
|
894
|
+
npx responsive-system-setup
|
|
895
|
+
\`\`\`
|
|
896
|
+
|
|
897
|
+
### Usar el Hook useResponsive
|
|
898
|
+
|
|
899
|
+
El hook \`useResponsive\` está disponible localmente en \`src/hooks/useResponsive.ts\`:
|
|
900
|
+
|
|
901
|
+
\`\`\`typescript
|
|
902
|
+
import { useResponsive } from '../hooks'
|
|
903
|
+
|
|
904
|
+
function MyComponent() {
|
|
905
|
+
const { breakpoint, isMobile, isDesktop, width, height } = useResponsive()
|
|
906
|
+
|
|
907
|
+
// Tu lógica aquí
|
|
908
|
+
}
|
|
909
|
+
\`\`\`
|
|
910
|
+
|
|
911
|
+
### Personalizar Componentes
|
|
912
|
+
|
|
913
|
+
Los componentes de layout están en \`src/components/layout/\` y puedes modificarlos según tus necesidades.
|
|
914
|
+
|
|
915
|
+
## 📚 Documentación
|
|
916
|
+
|
|
917
|
+
- [responsive-system en npm](https://www.npmjs.com/package/responsive-system)
|
|
918
|
+
- Hook \`useResponsive\`: \`src/hooks/useResponsive.ts\`
|
|
919
|
+
- Tipos TypeScript: \`src/types/responsive.ts\`
|
|
920
|
+
|
|
921
|
+
## ✅ Características
|
|
922
|
+
|
|
923
|
+
- ✅ Auto-scaling automático (texto, espaciado, sombras)
|
|
924
|
+
- ✅ Layout responsive que se adapta a todos los tamaños
|
|
925
|
+
- ✅ Hook \`useResponsive\` para configuración manual
|
|
926
|
+
- ✅ Componentes de layout personalizables
|
|
927
|
+
- ✅ Sin media queries necesarias
|
|
928
|
+
|
|
929
|
+
---
|
|
930
|
+
|
|
931
|
+
**¡Listo para empezar a desarrollar!** 🎉
|
|
932
|
+
`
|
|
933
|
+
fs.writeFileSync(readmePath, readmeContent)
|
|
934
|
+
console.log(' ✅ Actualizado: README.md con instrucciones completas')
|
|
935
|
+
} else {
|
|
936
|
+
// Si no existe, crearlo completo
|
|
937
|
+
fs.writeFileSync(readmePath, readmeContent)
|
|
938
|
+
console.log(' ✅ Creado: README.md con instrucciones completas')
|
|
939
|
+
}
|
|
940
|
+
|
|
637
941
|
console.log('')
|
|
638
942
|
console.log('🎉 responsive-system: Proyecto inicializado correctamente!')
|
|
639
943
|
console.log('')
|
|
@@ -642,11 +946,12 @@ export default App
|
|
|
642
946
|
console.log(' 2. Abre http://localhost:5173')
|
|
643
947
|
console.log('')
|
|
644
948
|
console.log(`Layout seleccionado: "${selectedLayout}"`)
|
|
645
|
-
console.log(' - Componentes
|
|
949
|
+
console.log(' - Componentes generados en src/components/layout/')
|
|
646
950
|
console.log(' - Hook useResponsive disponible en src/hooks/useResponsive.ts')
|
|
647
951
|
console.log(' - Página de ejemplo en src/pages/HomePage.tsx')
|
|
952
|
+
console.log(' - README.md creado con instrucciones')
|
|
648
953
|
console.log('')
|
|
649
|
-
console.log('💡 Para cambiar el layout, ejecuta: npx responsive-system-setup')
|
|
954
|
+
console.log('💡 Para cambiar el layout después, ejecuta: npx responsive-system-setup')
|
|
650
955
|
console.log('')
|
|
651
956
|
} else {
|
|
652
957
|
console.log('✅ responsive-system: Proyecto ya inicializado')
|
|
@@ -655,3 +960,8 @@ export default App
|
|
|
655
960
|
console.log('')
|
|
656
961
|
console.log('✅ responsive-system: postinstall completado')
|
|
657
962
|
console.log('')
|
|
963
|
+
console.log('📝 NOTA: Si instalaste el paquete pero este script no se ejecutó automáticamente,')
|
|
964
|
+
console.log(' ejecuta uno de estos comandos:')
|
|
965
|
+
console.log(' - npx responsive-system-setup')
|
|
966
|
+
console.log(' - node node_modules/responsive-system/scripts/postinstall.js')
|
|
967
|
+
console.log('')
|