holygrail5 1.0.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/README.md +631 -0
- package/config.json +365 -0
- package/generator.js +58 -0
- package/package.json +48 -0
- package/src/cli-variables.js +147 -0
- package/src/config.js +62 -0
- package/src/dev.js +47 -0
- package/src/guide.js +1798 -0
- package/src/parser.js +624 -0
- package/src/utils.js +74 -0
- package/src/variables-manager.js +248 -0
- package/src/watch.js +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
# HolyGrail5
|
|
2
|
+
|
|
3
|
+
Framework CSS generator con Node.js que genera CSS optimizado con variables CSS compartidas desde un archivo JSON de configuración.
|
|
4
|
+
|
|
5
|
+
## ⚖️ En resumen
|
|
6
|
+
|
|
7
|
+
| Aspecto | Solo Tailwind | Híbrido |
|
|
8
|
+
|--------------------------|-------------------------------------------------------------------------------|---------------------------------------------------------------------|
|
|
9
|
+
| Velocidad de desarrollo | 🔥 Muy alta | 🔥 Alta |
|
|
10
|
+
| Consistencia visual | ⚠️ Difícil mantener si hay muchas utilidades | ✅ Mantienes branding y coherencia |
|
|
11
|
+
| Escalabilidad | ⚠️ Costoso en proyectos grandes | ✅ Fácil de mantener |
|
|
12
|
+
| Curva de aprendizaje | Media | Baja si ya vienes de BEM/SCSS |
|
|
13
|
+
| Control sobre design system | ❌ Limitado | ✅ Total |
|
|
14
|
+
| Performance CSS final | ✅ Muy buena | ✅ Muy buena |
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## ✨ Características
|
|
19
|
+
|
|
20
|
+
- 🎨 **CSS optimizado** con variables CSS compartidas (mínimas y eficientes)
|
|
21
|
+
- 📱 **Soporte responsive** con breakpoints personalizables (mobile/desktop)
|
|
22
|
+
- 🔧 **Configuración simple** mediante JSON
|
|
23
|
+
- 📊 **Guía HTML interactiva** generada automáticamente con detección de cambios
|
|
24
|
+
- 🎯 **Variables compartidas** basadas en valores únicos
|
|
25
|
+
- 🔄 **Conversión automática** de px a rem
|
|
26
|
+
- 🛠️ **Helpers de spacing** (padding y margin) estilo Tailwind con propiedades lógicas (RTL)
|
|
27
|
+
- 🎨 **Sistema de colores** con variables CSS
|
|
28
|
+
- 📐 **Helpers de layout** (display, flexbox, alignment, gap)
|
|
29
|
+
- 👀 **Modo watch** para desarrollo con regeneración automática
|
|
30
|
+
- ✅ **Validación robusta** de configuración
|
|
31
|
+
- 🧪 **Suite de tests** incluida
|
|
32
|
+
- 🔍 **Gestión de variables CSS** con historial persistente
|
|
33
|
+
|
|
34
|
+
## 📦 Instalación
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Instalación global
|
|
38
|
+
npm install -g holygrail5
|
|
39
|
+
|
|
40
|
+
# Instalación local
|
|
41
|
+
npm install holygrail5
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 🚀 Uso
|
|
45
|
+
|
|
46
|
+
### CLI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Uso básico (genera en dist/)
|
|
50
|
+
npx holygrail5
|
|
51
|
+
# o
|
|
52
|
+
npm run generate
|
|
53
|
+
|
|
54
|
+
# Con argumentos personalizados
|
|
55
|
+
npx holygrail5 --config=./config.json --output=./dist/output.css --html=./dist/index.html
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Módulo Node.js
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const { generateCSS, generateHTML } = require('holygrail5');
|
|
62
|
+
const config = require('./config.json');
|
|
63
|
+
|
|
64
|
+
const css = generateCSS(config);
|
|
65
|
+
const html = generateHTML(config);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Desarrollo
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Modo watch (regenera automáticamente al cambiar config.json)
|
|
72
|
+
npm run watch
|
|
73
|
+
|
|
74
|
+
# Desarrollo completo (watch + servidor HTTP en localhost:3000)
|
|
75
|
+
npm run dev
|
|
76
|
+
|
|
77
|
+
# Solo servidor HTTP (sirve desde dist/ como raíz)
|
|
78
|
+
npm run serve
|
|
79
|
+
|
|
80
|
+
# Generar y abrir servidor
|
|
81
|
+
npm run start
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Nota:** El servidor sirve desde `dist/` como raíz, así que la URL será `http://localhost:3000/index.html` (sin mostrar "dist" en la URL).
|
|
85
|
+
|
|
86
|
+
## ⚙️ Configuración
|
|
87
|
+
|
|
88
|
+
### Estructura del `config.json`
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"prefix": "hg",
|
|
93
|
+
"category": "typo",
|
|
94
|
+
"baseFontSize": 16,
|
|
95
|
+
"fontFamilyMap": {
|
|
96
|
+
"primary": "arial, sans-serif",
|
|
97
|
+
"secondary": "\"ms-serif\", serif"
|
|
98
|
+
},
|
|
99
|
+
"breakpoints": {
|
|
100
|
+
"mobile": "0px",
|
|
101
|
+
"desktop": "992px"
|
|
102
|
+
},
|
|
103
|
+
"spacingMap": {
|
|
104
|
+
"0": "0",
|
|
105
|
+
"4": "4px",
|
|
106
|
+
"8": "8px",
|
|
107
|
+
"16": "16px",
|
|
108
|
+
"24": "24px",
|
|
109
|
+
"32": "32px"
|
|
110
|
+
},
|
|
111
|
+
"spacingImportant": ["0"],
|
|
112
|
+
"colors": {
|
|
113
|
+
"white": "#ffffff",
|
|
114
|
+
"black": "#000000",
|
|
115
|
+
"primary": "#000000",
|
|
116
|
+
"error": "#b40016"
|
|
117
|
+
},
|
|
118
|
+
"helpers": {
|
|
119
|
+
"display": {
|
|
120
|
+
"property": "display",
|
|
121
|
+
"class": "d",
|
|
122
|
+
"responsive": true,
|
|
123
|
+
"description": "Tipo de caja de renderizado",
|
|
124
|
+
"values": ["contents", "inline", "inline-block", "block", "flex", "inline-flex", "none"]
|
|
125
|
+
},
|
|
126
|
+
"flex-direction": {
|
|
127
|
+
"property": "flex-direction",
|
|
128
|
+
"class": "flex",
|
|
129
|
+
"responsive": true,
|
|
130
|
+
"description": "Dirección del eje principal",
|
|
131
|
+
"values": {
|
|
132
|
+
"row": "row",
|
|
133
|
+
"column": "column"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"classes": {
|
|
138
|
+
"h2": {
|
|
139
|
+
"fontFamily": "arial, sans-serif",
|
|
140
|
+
"fontWeight": "900",
|
|
141
|
+
"letterSpacing": "0rem",
|
|
142
|
+
"textTransform": "none",
|
|
143
|
+
"mobile": {
|
|
144
|
+
"fontSize": "18px",
|
|
145
|
+
"lineHeight": "1.2"
|
|
146
|
+
},
|
|
147
|
+
"desktop": {
|
|
148
|
+
"fontSize": "24px",
|
|
149
|
+
"lineHeight": "1.2"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Propiedades globales
|
|
157
|
+
|
|
158
|
+
| Propiedad | Tipo | Default | Descripción |
|
|
159
|
+
|-----------|------|---------|-------------|
|
|
160
|
+
| `prefix` | string | `"hg"` | Prefijo para variables CSS (ej: `--hg-typo-...`) |
|
|
161
|
+
| `category` | string | `"typo"` | Categoría para variables CSS |
|
|
162
|
+
| `baseFontSize` | number | `16` | Tamaño base para conversión px→rem |
|
|
163
|
+
| `fontFamilyMap` | object | - | Mapeo de nombres a fuentes CSS |
|
|
164
|
+
| `breakpoints` | object | **Requerido** | Breakpoints mobile/desktop |
|
|
165
|
+
| `spacingMap` | object | - | Valores de spacing para helpers (px o %) |
|
|
166
|
+
| `spacingImportant` | array | - | Valores de spacing que usan `!important` |
|
|
167
|
+
| `colors` | object | - | Paleta de colores (nombre → hex) |
|
|
168
|
+
| `helpers` | object | - | Helpers de layout (display, flexbox, etc.) |
|
|
169
|
+
| `classes` | object | **Requerido** | Clases CSS de tipografía a generar |
|
|
170
|
+
|
|
171
|
+
### Propiedades de clases
|
|
172
|
+
|
|
173
|
+
**Base (aplicadas a todos los breakpoints):**
|
|
174
|
+
|
|
175
|
+
- `fontFamily`: Familia de fuente
|
|
176
|
+
- `fontWeight`: Peso de fuente (100, 400, 700, 900)
|
|
177
|
+
- `letterSpacing`: Espaciado entre letras (ej: "0rem")
|
|
178
|
+
- `textTransform`: Transformación (none, uppercase, lowercase)
|
|
179
|
+
|
|
180
|
+
**Responsive (por breakpoint):**
|
|
181
|
+
- `mobile`: `{ fontSize: "18px", lineHeight: "1.2" }`
|
|
182
|
+
- `desktop`: `{ fontSize: "24px", lineHeight: "1.5" }`
|
|
183
|
+
|
|
184
|
+
## 📄 Salida
|
|
185
|
+
|
|
186
|
+
### `dist/output.css`
|
|
187
|
+
|
|
188
|
+
CSS generado con estructura organizada:
|
|
189
|
+
|
|
190
|
+
1. **Reset CSS Mínimo** - Normalización básica
|
|
191
|
+
2. **Variables CSS Compartidas** (`:root`) - Variables para:
|
|
192
|
+
|
|
193
|
+
- Font families
|
|
194
|
+
- Font sizes
|
|
195
|
+
- Line heights
|
|
196
|
+
- Font weights
|
|
197
|
+
- Letter spacing
|
|
198
|
+
- Text transform
|
|
199
|
+
- Spacing values
|
|
200
|
+
- Colors
|
|
201
|
+
3. **Helpers de Spacing (Mobile)** - Padding y margin con propiedades lógicas
|
|
202
|
+
4. **Helpers de Spacing (Desktop)** - Versiones `md:` con media queries
|
|
203
|
+
5. **Layout Helpers** - Display, flexbox, alignment, gap
|
|
204
|
+
6. **Tipografías (Mobile)** - Clases responsive para mobile
|
|
205
|
+
7. **Tipografías (Desktop)** - Clases responsive para desktop
|
|
206
|
+
- Font families
|
|
207
|
+
- Font sizes
|
|
208
|
+
- Line heights
|
|
209
|
+
- Font weights
|
|
210
|
+
- Letter spacing
|
|
211
|
+
- Text transform
|
|
212
|
+
- Spacing values
|
|
213
|
+
- Colors
|
|
214
|
+
3. **Helpers de Spacing (Mobile)** - Padding y margin con propiedades lógicas
|
|
215
|
+
4. **Helpers de Spacing (Desktop)** - Versiones `md:` con media queries
|
|
216
|
+
5. **Layout Helpers** - Display, flexbox, alignment, gap
|
|
217
|
+
6. **Tipografías (Mobile)** - Clases responsive para mobile
|
|
218
|
+
7. **Tipografías (Desktop)** - Clases responsive para desktop
|
|
219
|
+
|
|
220
|
+
### `dist/index.html`
|
|
221
|
+
|
|
222
|
+
Guía HTML interactiva generada en la carpeta `dist/` con:
|
|
223
|
+
|
|
224
|
+
- 🎨 **Sección de Colores** - Grid visual con preview de colores
|
|
225
|
+
- 🔤 **Font Families** - Tabla con preview de fuentes
|
|
226
|
+
- 📝 **Clases de Tipografía** - Tabla completa con preview y valores responsive
|
|
227
|
+
- 🔗 **Variables CSS Compartidas** - Todas las variables generadas
|
|
228
|
+
- 📏 **Helpers de Spacing** - Tabla con clases y variables
|
|
229
|
+
- 📐 **Helpers de Layout** - Tabla con clases base y responsive (`md:`)
|
|
230
|
+
- 📱 **Breakpoints** - Configuración de breakpoints
|
|
231
|
+
- 🔍 **Búsqueda en tiempo real** - Filtra y resalta contenido
|
|
232
|
+
- 🎯 **Detección de cambios** - Valores modificados se resaltan en verde
|
|
233
|
+
- 📌 **Header sticky** - Navegación siempre visible
|
|
234
|
+
- 📋 **Menú lateral** - Navegación rápida entre secciones
|
|
235
|
+
- 📊 **Metadata** - Último commit y versión del package
|
|
236
|
+
|
|
237
|
+
## 🎯 Helpers de Spacing
|
|
238
|
+
|
|
239
|
+
Genera clases estilo Tailwind para padding y margin con **propiedades lógicas** para soporte RTL automático:
|
|
240
|
+
|
|
241
|
+
```css
|
|
242
|
+
/* Mobile - Propiedades lógicas */
|
|
243
|
+
.p-4 { padding: var(--hg-spacing-4); }
|
|
244
|
+
.pr-4 { padding-inline-end: var(--hg-spacing-4); }
|
|
245
|
+
.pl-4 { padding-inline-start: var(--hg-spacing-4); }
|
|
246
|
+
.m-8 { margin: var(--hg-spacing-8); }
|
|
247
|
+
.mr-8 { margin-inline-end: var(--hg-spacing-8); }
|
|
248
|
+
.ml-8 { margin-inline-start: var(--hg-spacing-8); }
|
|
249
|
+
|
|
250
|
+
/* Desktop (md:) - Con media query */
|
|
251
|
+
@media (min-width: 62rem) {
|
|
252
|
+
.md\:p-4 { padding: var(--hg-spacing-4); }
|
|
253
|
+
.md\:pr-8 { padding-inline-end: var(--hg-spacing-8); }
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
> **Nota:** Las propiedades `pr`/`pl` y `mr`/`ml` usan `padding-inline-end/start` y `margin-inline-end/start` para soporte RTL automático.
|
|
258
|
+
|
|
259
|
+
## 🎨 Sistema de Colores
|
|
260
|
+
|
|
261
|
+
Define colores en `config.json` y se generan como variables CSS:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"colors": {
|
|
266
|
+
"white": "#ffffff",
|
|
267
|
+
"black": "#000000",
|
|
268
|
+
"primary": "#000000",
|
|
269
|
+
"error": "#b40016",
|
|
270
|
+
"success": "#76ae4a"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**CSS generado:**
|
|
276
|
+
|
|
277
|
+
```css
|
|
278
|
+
:root {
|
|
279
|
+
--hg-color-white: #ffffff;
|
|
280
|
+
--hg-color-black: #000000;
|
|
281
|
+
--hg-color-primary: #000000;
|
|
282
|
+
--hg-color-error: #b40016;
|
|
283
|
+
--hg-color-success: #76ae4a;
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Uso:**
|
|
288
|
+
|
|
289
|
+
```css
|
|
290
|
+
.my-element {
|
|
291
|
+
background-color: var(--hg-color-primary);
|
|
292
|
+
color: var(--hg-color-white);
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## 📐 Helpers de Layout
|
|
297
|
+
|
|
298
|
+
Genera helpers para display, flexbox, alignment y gap:
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"helpers": {
|
|
303
|
+
"display": {
|
|
304
|
+
"property": "display",
|
|
305
|
+
"class": "d",
|
|
306
|
+
"responsive": true,
|
|
307
|
+
"description": "Tipo de caja de renderizado",
|
|
308
|
+
"values": ["flex", "block", "none"]
|
|
309
|
+
},
|
|
310
|
+
"flex-direction": {
|
|
311
|
+
"property": "flex-direction",
|
|
312
|
+
"class": "flex",
|
|
313
|
+
"responsive": true,
|
|
314
|
+
"description": "Dirección del eje principal",
|
|
315
|
+
"values": {
|
|
316
|
+
"row": "row",
|
|
317
|
+
"column": "column"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**CSS generado:**
|
|
325
|
+
|
|
326
|
+
```css
|
|
327
|
+
.hg-d-flex { display: flex; }
|
|
328
|
+
.hg-d-block { display: block; }
|
|
329
|
+
.hg-flex-row { flex-direction: row; }
|
|
330
|
+
.hg-flex-column { flex-direction: column; }
|
|
331
|
+
|
|
332
|
+
@media (min-width: 992px) {
|
|
333
|
+
.md\:hg-d-flex { display: flex; }
|
|
334
|
+
.md\:hg-flex-row { flex-direction: row; }
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## 🔍 Gestión de Variables CSS
|
|
339
|
+
|
|
340
|
+
El generador mantiene un historial de todas las variables CSS generadas en `.data/.historical-variables.json` para que nunca se eliminen automáticamente, incluso si se borran las clases que las usaban.
|
|
341
|
+
|
|
342
|
+
### Comandos disponibles
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Listar variables no usadas
|
|
346
|
+
npm run vars:list
|
|
347
|
+
# o
|
|
348
|
+
node src/cli-variables.js list
|
|
349
|
+
|
|
350
|
+
# Ver reporte completo de variables
|
|
351
|
+
npm run vars:report
|
|
352
|
+
# o
|
|
353
|
+
node src/cli-variables.js report
|
|
354
|
+
|
|
355
|
+
# Eliminar una variable específica del historial
|
|
356
|
+
npm run vars:remove -- --hg-typo-font-size-18
|
|
357
|
+
# o
|
|
358
|
+
node src/cli-variables.js remove --hg-typo-font-size-18
|
|
359
|
+
|
|
360
|
+
# Eliminar todas las variables no usadas del historial
|
|
361
|
+
npm run vars:remove-all-unused
|
|
362
|
+
# o
|
|
363
|
+
node src/cli-variables.js remove-all-unused
|
|
364
|
+
|
|
365
|
+
# Mostrar todas las variables históricas almacenadas
|
|
366
|
+
npm run vars:show-all
|
|
367
|
+
# o
|
|
368
|
+
node src/cli-variables.js show-all
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Ejemplo de uso
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
# 1. Generar CSS
|
|
375
|
+
npm run generate
|
|
376
|
+
|
|
377
|
+
# 2. Ver qué variables no se están usando
|
|
378
|
+
npm run vars:list
|
|
379
|
+
|
|
380
|
+
# 3. Eliminar variables no usadas
|
|
381
|
+
npm run vars:remove-all-unused
|
|
382
|
+
|
|
383
|
+
# 4. Regenerar CSS sin las variables eliminadas
|
|
384
|
+
npm run generate
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Opciones avanzadas
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Especificar ruta personalizada del CSS
|
|
391
|
+
node src/cli-variables.js report --css=./dist/output.css
|
|
392
|
+
|
|
393
|
+
# Especificar ruta personalizada del historial
|
|
394
|
+
node src/cli-variables.js list --history=./.data/.custom-variables.json
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## 🔧 Scripts NPM
|
|
398
|
+
|
|
399
|
+
| Script | Descripción |
|
|
400
|
+
|--------|-------------|
|
|
401
|
+
| `npm run generate` | Genera CSS y HTML en `dist/` |
|
|
402
|
+
| `npm run watch` | Modo watch (regenera al cambiar config.json) |
|
|
403
|
+
| `npm run dev` | Watch + servidor HTTP en localhost:3000 |
|
|
404
|
+
| `npm run serve` | Solo servidor HTTP (sirve desde dist/) |
|
|
405
|
+
| `npm run start` | Genera y abre servidor HTTP |
|
|
406
|
+
| `npm run test` | Ejecuta la suite de tests |
|
|
407
|
+
| `npm run vars:list` | Lista variables CSS no usadas |
|
|
408
|
+
| `npm run vars:report` | Reporte completo de variables |
|
|
409
|
+
| `npm run vars:remove` | Elimina una variable del historial |
|
|
410
|
+
| `npm run vars:remove-all-unused` | Elimina todas las variables no usadas |
|
|
411
|
+
| `npm run vars:show-all` | Muestra todas las variables históricas |
|
|
412
|
+
|
|
413
|
+
## 🏗️ Estructura del proyecto
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
holygrail5/
|
|
417
|
+
├── generator.js # Orquestador principal
|
|
418
|
+
├── config.json # Configuración del proyecto
|
|
419
|
+
├── package.json # Dependencias y scripts
|
|
420
|
+
├── README.md # Este archivo
|
|
421
|
+
├── .data/ # Archivos de estado (gitignored)
|
|
422
|
+
│ ├── .previous-values.json # Valores previos para detección de cambios
|
|
423
|
+
│ └── .historical-variables.json # Historial de variables CSS
|
|
424
|
+
├── dist/ # Archivos generados (gitignored)
|
|
425
|
+
│ ├── output.css # CSS generado
|
|
426
|
+
│ └── index.html # Guía HTML interactiva
|
|
427
|
+
├── src/
|
|
428
|
+
│ ├── config.js # Carga y validación de configuración
|
|
429
|
+
│ ├── parser.js # Generación de CSS desde JSON
|
|
430
|
+
│ ├── guide.js # Generación de guía HTML interactiva
|
|
431
|
+
│ ├── utils.js # Utilidades compartidas (px→rem, etc.)
|
|
432
|
+
│ ├── variables-manager.js # Gestión de variables CSS históricas
|
|
433
|
+
│ ├── cli-variables.js # CLI para gestión de variables
|
|
434
|
+
│ ├── watch.js # Modo watch para desarrollo
|
|
435
|
+
│ └── dev.js # Script de desarrollo (watch + servidor)
|
|
436
|
+
└── tests/
|
|
437
|
+
├── run-all.js # Ejecutor de todos los tests
|
|
438
|
+
├── config.test.js # Tests de configuración
|
|
439
|
+
├── parser.test.js # Tests del parseador
|
|
440
|
+
├── guide.test.js # Tests de la guía HTML
|
|
441
|
+
└── utils.test.js # Tests de utilidades
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## 🎨 Ejemplo de CSS generado
|
|
445
|
+
|
|
446
|
+
```css
|
|
447
|
+
/* Reset CSS Mínimo */
|
|
448
|
+
html {
|
|
449
|
+
box-sizing: border-box;
|
|
450
|
+
font-size: 16px;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/* Variables CSS Compartidas */
|
|
454
|
+
:root {
|
|
455
|
+
--hg-typo-font-family-primary: arial, sans-serif;
|
|
456
|
+
--hg-typo-font-size-18: 1.125rem;
|
|
457
|
+
--hg-typo-font-size-24: 1.5rem;
|
|
458
|
+
--hg-typo-line-height-1-2: 1.2;
|
|
459
|
+
--hg-spacing-4: 0.25rem;
|
|
460
|
+
--hg-spacing-8: 0.5rem;
|
|
461
|
+
--hg-color-white: #ffffff;
|
|
462
|
+
--hg-color-primary: #000000;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/* Helpers de Spacing - Mobile */
|
|
466
|
+
.p-4 { padding: var(--hg-spacing-4); }
|
|
467
|
+
.pr-4 { padding-inline-end: var(--hg-spacing-4); }
|
|
468
|
+
.pl-4 { padding-inline-start: var(--hg-spacing-4); }
|
|
469
|
+
.m-8 { margin: var(--hg-spacing-8); }
|
|
470
|
+
|
|
471
|
+
/* Helpers de Spacing - Desktop (md:) */
|
|
472
|
+
@media (min-width: 62rem) {
|
|
473
|
+
.md\:p-4 { padding: var(--hg-spacing-4); }
|
|
474
|
+
.md\:pr-8 { padding-inline-end: var(--hg-spacing-8); }
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/* Layout Helpers */
|
|
478
|
+
.hg-d-flex { display: flex; }
|
|
479
|
+
.hg-flex-row { flex-direction: row; }
|
|
480
|
+
.hg-justify-center { justify-content: center; }
|
|
481
|
+
.hg-items-center { align-items: center; }
|
|
482
|
+
.hg-gap-16 { gap: 1rem; }
|
|
483
|
+
|
|
484
|
+
@media (min-width: 992px) {
|
|
485
|
+
.md\:hg-d-flex { display: flex; }
|
|
486
|
+
.md\:hg-flex-row { flex-direction: row; }
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/* Tipografías - Mobile */
|
|
490
|
+
@media (min-width: 0rem) {
|
|
491
|
+
.h2 {
|
|
492
|
+
font-family: var(--hg-typo-font-family-primary);
|
|
493
|
+
font-size: var(--hg-typo-font-size-18);
|
|
494
|
+
line-height: var(--hg-typo-line-height-1-2);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/* Tipografías - Desktop */
|
|
499
|
+
@media (min-width: 62rem) {
|
|
500
|
+
.h2 {
|
|
501
|
+
font-size: var(--hg-typo-font-size-24);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## 🔑 Características técnicas
|
|
507
|
+
|
|
508
|
+
#### Variables compartidas
|
|
509
|
+
|
|
510
|
+
Las variables se generan basándose en **valores únicos**, no en clases:
|
|
511
|
+
|
|
512
|
+
- Múltiples clases con `fontWeight: "900"` → una sola variable `--hg-typo-font-weight-900`
|
|
513
|
+
- Optimiza el CSS eliminando duplicados
|
|
514
|
+
- Historial persistente en `.data/.historical-variables.json`
|
|
515
|
+
|
|
516
|
+
#### Conversión px → rem
|
|
517
|
+
|
|
518
|
+
- `fontSize` en JSON: `"18px"` → CSS: `1.125rem` (usando `baseFontSize: 16`)
|
|
519
|
+
- Nombre de variable mantiene el valor original: `--hg-typo-font-size-18`
|
|
520
|
+
- Conversión automática para todos los valores en píxeles
|
|
521
|
+
|
|
522
|
+
#### Nombres de variables
|
|
523
|
+
|
|
524
|
+
Patrón: `--{prefix}-{category}-{propiedad}-{valor}`
|
|
525
|
+
|
|
526
|
+
Ejemplos:
|
|
527
|
+
|
|
528
|
+
- `--hg-typo-font-family-primary`
|
|
529
|
+
- `--hg-typo-font-size-18`
|
|
530
|
+
- `--hg-spacing-4`
|
|
531
|
+
- `--hg-color-white`
|
|
532
|
+
|
|
533
|
+
#### Propiedades lógicas (RTL)
|
|
534
|
+
|
|
535
|
+
Los helpers de spacing usan propiedades lógicas para soporte RTL automático:
|
|
536
|
+
|
|
537
|
+
- `pr-4` → `padding-inline-end` (no `padding-right`)
|
|
538
|
+
- `pl-4` → `padding-inline-start` (no `padding-left`)
|
|
539
|
+
- `mr-8` → `margin-inline-end` (no `margin-right`)
|
|
540
|
+
- `ml-8` → `margin-inline-start` (no `margin-left`)
|
|
541
|
+
|
|
542
|
+
## 📊 Guía HTML Interactiva
|
|
543
|
+
|
|
544
|
+
La guía HTML generada en `dist/index.html` incluye:
|
|
545
|
+
|
|
546
|
+
#### Características
|
|
547
|
+
|
|
548
|
+
- 🎨 **Grid de colores** - Visualización de la paleta de colores con preview
|
|
549
|
+
- 🔤 **Font Families** - Tabla con preview de fuentes
|
|
550
|
+
- 📝 **Tipografía** - Tabla completa con preview y valores mobile/desktop
|
|
551
|
+
- 🔗 **Variables CSS** - Todas las variables generadas con valores
|
|
552
|
+
- 📏 **Helpers de Spacing** - Clases y variables de padding/margin
|
|
553
|
+
- 📐 **Helpers de Layout** - Display, flexbox, alignment, gap
|
|
554
|
+
- 📱 **Breakpoints** - Configuración de breakpoints
|
|
555
|
+
|
|
556
|
+
#### Funcionalidades interactivas
|
|
557
|
+
|
|
558
|
+
- 🔍 **Búsqueda en tiempo real** - Filtra y resalta contenido en todas las tablas
|
|
559
|
+
- 🎯 **Detección de cambios** - Valores modificados se resaltan en verde
|
|
560
|
+
- 📌 **Header sticky** - Navegación y búsqueda siempre visibles
|
|
561
|
+
- 📋 **Menú lateral** - Navegación rápida con scroll suave
|
|
562
|
+
- 📊 **Metadata** - Último commit de Git y versión del package
|
|
563
|
+
- 🔄 **Cache busting** - Timestamp en CSS para forzar recarga
|
|
564
|
+
|
|
565
|
+
## 🐛 Solución de problemas
|
|
566
|
+
|
|
567
|
+
**Error: "Archivo de configuración no encontrado"**
|
|
568
|
+
|
|
569
|
+
```bash
|
|
570
|
+
npx holygrail5 --config=./ruta/config.json
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
**Error: "La configuración debe tener un objeto 'classes'"**
|
|
574
|
+
|
|
575
|
+
Verifica que `config.json` tenga la propiedad `classes` con al menos una clase.
|
|
576
|
+
|
|
577
|
+
**Error: "La clase debe tener al menos un breakpoint"**
|
|
578
|
+
|
|
579
|
+
Cada clase debe tener al menos `mobile` o `desktop`.
|
|
580
|
+
|
|
581
|
+
**El servidor no muestra los cambios**
|
|
582
|
+
|
|
583
|
+
- Recarga con `Cmd+Shift+R` (Mac) o `Ctrl+Shift+R` (Windows/Linux)
|
|
584
|
+
- Verifica que el modo watch esté activo si usas `npm run dev`
|
|
585
|
+
|
|
586
|
+
**Variables no se detectan como no usadas**
|
|
587
|
+
|
|
588
|
+
Ejecuta `npm run generate` primero para actualizar el historial de variables.
|
|
589
|
+
|
|
590
|
+
## 🌐 GitHub Pages
|
|
591
|
+
|
|
592
|
+
Para desplegar en GitHub Pages, puedes:
|
|
593
|
+
|
|
594
|
+
1. Configurar GitHub Pages para usar la carpeta `dist/` como fuente
|
|
595
|
+
2. O crear un workflow de GitHub Actions que genere los archivos en `docs/` automáticamente
|
|
596
|
+
|
|
597
|
+
**Opción 1 - Usar dist/ directamente:**
|
|
598
|
+
- En Settings → Pages, selecciona la rama y carpeta `dist/`
|
|
599
|
+
|
|
600
|
+
**Opción 2 - Workflow automático:**
|
|
601
|
+
- Crea `.github/workflows/deploy.yml` que ejecute `npm run generate` y copie archivos a `docs/`
|
|
602
|
+
|
|
603
|
+
## 📚 Recursos
|
|
604
|
+
|
|
605
|
+
- **Repositorio**: [GitHub](https://github.com/holygrailcss/holygrail5.git)
|
|
606
|
+
- **Licencia**: MIT
|
|
607
|
+
- **Node.js**: Requiere >=12.0.0
|
|
608
|
+
|
|
609
|
+
## 🤝 Contribuir
|
|
610
|
+
|
|
611
|
+
1. Fork el repositorio
|
|
612
|
+
2. Crea una rama (`git checkout -b feature/AmazingFeature`)
|
|
613
|
+
3. Commit tus cambios (`git commit -m 'Add AmazingFeature'`)
|
|
614
|
+
4. Push a la rama (`git push origin feature/AmazingFeature`)
|
|
615
|
+
5. Abre un Pull Request
|
|
616
|
+
|
|
617
|
+
## 📝 Changelog
|
|
618
|
+
|
|
619
|
+
### v1.0.2
|
|
620
|
+
- ✅ Sistema de colores con variables CSS
|
|
621
|
+
- ✅ Helpers de layout (display, flexbox, alignment, gap)
|
|
622
|
+
- ✅ Propiedades lógicas para soporte RTL
|
|
623
|
+
- ✅ Guía HTML mejorada con grid de colores
|
|
624
|
+
- ✅ Búsqueda interactiva en la guía
|
|
625
|
+
- ✅ Header sticky y menú lateral
|
|
626
|
+
- ✅ Reorganización del proyecto (`.data/` para archivos de estado)
|
|
627
|
+
- ✅ Archivos generados en `dist/`
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
**Hecho con ❤️ por HolyGrail CSS**
|