@hiscovega/grisso 1.0.3 → 1.0.5
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 +135 -70
- package/dist/grisso.css +1 -1
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +131 -0
- package/lib/generators.d.ts +0 -4
- package/lib/generators.js +13 -6
- package/lib/partials/borders.js +7 -0
- package/lib/partials/layout.js +13 -9
- package/lib/partials/sizing.js +33 -5
- package/lib/partials/typography.js +10 -3
- package/lib/purge.js +2 -2
- package/package.json +11 -20
- package/tokens-example.css +1 -1
- package/plugin.cjs +0 -5
- package/plugin.js +0 -43
package/README.md
CHANGED
|
@@ -5,67 +5,71 @@
|
|
|
5
5
|
## Instalación
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @hiscovega/grisso
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Uso
|
|
12
12
|
|
|
13
13
|
### Opción A: CSS directo
|
|
14
14
|
|
|
15
|
-
Importa el CSS pre-compilado directamente. Útil para desarrollo
|
|
15
|
+
Importa el CSS pre-compilado directamente. Útil para desarrollo.
|
|
16
16
|
|
|
17
17
|
```css
|
|
18
18
|
/* En tu CSS global */
|
|
19
|
-
@import "@
|
|
19
|
+
@import "@hiscovega/grisso";
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
O en HTML:
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
|
-
<link rel="stylesheet" href="node_modules/@
|
|
25
|
+
<link rel="stylesheet" href="node_modules/@hiscovega/grisso/dist/grisso.css" />
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
### Opción B:
|
|
28
|
+
### Opción B: CLI
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Genera CSS desde la terminal. Ideal para scripts de build y CI/CD.
|
|
31
31
|
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
```bash
|
|
33
|
+
# CSS completo a stdout
|
|
34
|
+
npx grisso build
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
grisso({
|
|
39
|
-
content: ["./src/**/*.{js,ts,jsx,tsx,css}"],
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
```
|
|
36
|
+
# Escribir a archivo
|
|
37
|
+
npx grisso build --output dist/grisso.css
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
# Con config personalizada
|
|
40
|
+
npx grisso build --config grisso.config.mjs --output dist/grisso.css
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
grisso
|
|
42
|
+
# Tree-shaking (solo clases usadas)
|
|
43
|
+
npx grisso build --content "src/**/*.tsx" --content "src/**/*.css" --output dist/grisso.css
|
|
44
|
+
|
|
45
|
+
# Sin minificar (útil para depuración)
|
|
46
|
+
npx grisso build --no-minify --output dist/grisso.css
|
|
47
|
+
|
|
48
|
+
# Pipear a otro comando
|
|
49
|
+
npx grisso build | pbcopy
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
**Flags de `grisso build`:**
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
| Flag | Descripción |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `--config <ruta>` | Ruta a `grisso.config.mjs` |
|
|
57
|
+
| `--content <glob>` | Globs para tree-shaking (repetible) |
|
|
58
|
+
| `--output <ruta>` | Archivo de salida (sin `--output` → stdout) |
|
|
59
|
+
| `--no-minify` | Deshabilitar minificación |
|
|
60
|
+
| `--help, -h` | Ayuda del comando |
|
|
61
|
+
|
|
62
|
+
Sin `--output`, el CSS va a stdout y los mensajes de estado a stderr, siguiendo la convención Unix.
|
|
63
|
+
|
|
64
|
+
### Opción C: API programática
|
|
65
|
+
|
|
66
|
+
Usa `buildCSS()` directamente desde Node.js. Genera, purga y optimiza CSS — ideal para scripts de build, herramientas custom o integración con cualquier bundler.
|
|
54
67
|
|
|
55
68
|
```js
|
|
56
|
-
import { buildCSS } from "@
|
|
69
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
57
70
|
|
|
58
71
|
// Build completo (todo el CSS, minificado)
|
|
59
72
|
const css = await buildCSS();
|
|
60
|
-
|
|
61
|
-
// Build con tree-shaking
|
|
62
|
-
const css = await buildCSS({
|
|
63
|
-
content: ["./src/**/*.{js,ts,jsx,tsx,css}"],
|
|
64
|
-
config: "./grisso.config.mjs",
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Build sin minificar
|
|
68
|
-
const css = await buildCSS({ minify: false });
|
|
69
73
|
```
|
|
70
74
|
|
|
71
75
|
**Opciones de `buildCSS()`:**
|
|
@@ -78,6 +82,83 @@ const css = await buildCSS({ minify: false });
|
|
|
78
82
|
|
|
79
83
|
Sin `content`, se incluye todo el CSS. Con `content`, se eliminan las clases no usadas via PurgeCSS.
|
|
80
84
|
|
|
85
|
+
#### Ejemplos
|
|
86
|
+
|
|
87
|
+
**Tree-shaking** — solo las clases que usa tu proyecto:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
const css = await buildCSS({
|
|
91
|
+
content: ["./src/**/*.{js,ts,jsx,tsx}", "./src/**/*.css"],
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Config personalizada + tree-shaking:**
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const css = await buildCSS({
|
|
99
|
+
config: "./grisso.config.mjs",
|
|
100
|
+
content: ["./src/**/*.{js,ts,jsx,tsx,css}"],
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**CSS sin minificar** (útil para depuración):
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
const css = await buildCSS({ minify: false });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Script de build** — genera un archivo CSS para producción:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
// scripts/build-css.mjs
|
|
114
|
+
import { writeFileSync } from "node:fs";
|
|
115
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
116
|
+
|
|
117
|
+
const css = await buildCSS({
|
|
118
|
+
content: ["./src/**/*.{jsx,tsx,css}"],
|
|
119
|
+
config: "./grisso.config.mjs",
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
writeFileSync("./dist/styles.css", css);
|
|
123
|
+
console.log(`CSS generado: ${css.length} bytes`);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Integración con Vite** (plugin custom):
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
// vite.config.js
|
|
130
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
131
|
+
|
|
132
|
+
export default {
|
|
133
|
+
plugins: [
|
|
134
|
+
{
|
|
135
|
+
name: "grisso",
|
|
136
|
+
async buildStart() {
|
|
137
|
+
const css = await buildCSS({
|
|
138
|
+
content: ["./src/**/*.{jsx,tsx,css}"],
|
|
139
|
+
});
|
|
140
|
+
this.emitFile({ type: "asset", fileName: "grisso.css", source: css });
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Servidor de desarrollo** — generar CSS on-the-fly:
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
// Ejemplo con Express
|
|
151
|
+
import express from "express";
|
|
152
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
153
|
+
|
|
154
|
+
const app = express();
|
|
155
|
+
|
|
156
|
+
app.get("/grisso.css", async (req, res) => {
|
|
157
|
+
const css = await buildCSS({ minify: false });
|
|
158
|
+
res.type("text/css").send(css);
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
81
162
|
## Configuración personalizada
|
|
82
163
|
|
|
83
164
|
Crea un `grisso.config.mjs` en la raíz de tu proyecto para extender o reemplazar los tokens por defecto. Sigue el patrón de Tailwind v3:
|
|
@@ -104,25 +185,16 @@ export default {
|
|
|
104
185
|
};
|
|
105
186
|
```
|
|
106
187
|
|
|
107
|
-
|
|
188
|
+
Si no se pasa `config` a `buildCSS()`, busca automáticamente `grisso.config.mjs` en el directorio de trabajo. Si no existe, usa los defaults.
|
|
108
189
|
|
|
109
|
-
|
|
110
|
-
grisso({
|
|
111
|
-
content: ["./src/**/*.{js,ts,jsx,tsx,css}"],
|
|
112
|
-
config: "./grisso.config.mjs",
|
|
113
|
-
});
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Si no se pasa `config`, el plugin busca automáticamente `grisso.config.mjs` en el directorio de trabajo. Si no existe, usa los defaults.
|
|
117
|
-
|
|
118
|
-
Los defaults se pueden consultar importando `@griddo/grisso/config`.
|
|
190
|
+
Los defaults se pueden consultar importando `@hiscovega/grisso/config`.
|
|
119
191
|
|
|
120
192
|
## Design Tokens (CSS custom properties)
|
|
121
193
|
|
|
122
194
|
Grisso usa CSS custom properties para todos los valores. Copia `tokens-example.css` y adapta los valores a tu design system:
|
|
123
195
|
|
|
124
196
|
```bash
|
|
125
|
-
cp node_modules/@
|
|
197
|
+
cp node_modules/@hiscovega/grisso/tokens-example.css src/tokens.css
|
|
126
198
|
```
|
|
127
199
|
|
|
128
200
|
```css
|
|
@@ -140,7 +212,7 @@ Importa los tokens antes que Grisso en tu CSS global:
|
|
|
140
212
|
|
|
141
213
|
```css
|
|
142
214
|
@import "./tokens.css";
|
|
143
|
-
@import "@
|
|
215
|
+
@import "@hiscovega/grisso";
|
|
144
216
|
```
|
|
145
217
|
|
|
146
218
|
## Clases disponibles
|
|
@@ -151,7 +223,7 @@ Importa los tokens antes que Grisso en tu CSS global:
|
|
|
151
223
|
{breakpoint}-{propiedad}-{escala}
|
|
152
224
|
```
|
|
153
225
|
|
|
154
|
-
Ejemplos: `flex`, `tablet-flex`, `p-md`, `desktop-mt-lg`, `text-center`
|
|
226
|
+
Ejemplos: `flex`, `tablet-flex`, `p-md`, `desktop-mt-lg`, `text-center`, `w-1/2`, `z-10`, `tracking-tight`
|
|
155
227
|
|
|
156
228
|
### Breakpoints (mobile-first)
|
|
157
229
|
|
|
@@ -164,22 +236,22 @@ Ejemplos: `flex`, `tablet-flex`, `p-md`, `desktop-mt-lg`, `text-center`
|
|
|
164
236
|
|
|
165
237
|
### Categorías
|
|
166
238
|
|
|
167
|
-
| Categoría | Ejemplos
|
|
168
|
-
| -------------- |
|
|
169
|
-
| **Layout** | `flex`, `block`, `hidden`, `relative`, `absolute`, `overflow-hidden` |
|
|
170
|
-
| **Flex/Grid** | `flex-col`, `flex-wrap`, `items-center`, `justify-between`, `gap-md`
|
|
171
|
-
| **Spacing** | `p-sm`, `pt-lg`, `mx-auto`, `mt-xs`, `mb-md`
|
|
172
|
-
| **Sizing** | `w-full`, `h-full`, `w-1`, `max-w-full`
|
|
173
|
-
| **Tipografía** | `text-1`, `text-center`, `font-bold`, `leading-tight`
|
|
174
|
-
| **Fondos** | `bg-1`, `bg-ui`, `bg-cover`, `bg-center`
|
|
175
|
-
| **Bordes** | `border-sm`, `divide-x`, `outline-none`
|
|
176
|
-
| **Efectos** | `shadow-md`, `opacity-3`, `overlay-2`
|
|
177
|
-
| **Iconos** | `icon-1`, `icon-3`
|
|
239
|
+
| Categoría | Ejemplos |
|
|
240
|
+
| -------------- | ----------------------------------------------------------------------------- |
|
|
241
|
+
| **Layout** | `flex`, `block`, `hidden`, `relative`, `absolute`, `overflow-hidden`, `inset-0`, `inset-x-sm`, `z-10` |
|
|
242
|
+
| **Flex/Grid** | `flex-col`, `flex-wrap`, `items-center`, `justify-between`, `gap-md` |
|
|
243
|
+
| **Spacing** | `p-sm`, `pt-lg`, `mx-auto`, `mt-xs`, `mb-md` |
|
|
244
|
+
| **Sizing** | `w-full`, `h-full`, `w-1/2`, `w-2/3`, `h-1/4`, `max-w-full` |
|
|
245
|
+
| **Tipografía** | `text-1`, `text-center`, `font-bold`, `font-light`, `leading-snug`, `tracking-tight` |
|
|
246
|
+
| **Fondos** | `bg-1`, `bg-ui`, `bg-cover`, `bg-center` |
|
|
247
|
+
| **Bordes** | `border-sm`, `border-1`, `border-t-sm`, `divide-x`, `outline-none` |
|
|
248
|
+
| **Efectos** | `shadow-md`, `opacity-3`, `overlay-2` |
|
|
249
|
+
| **Iconos** | `icon-1`, `icon-3` |
|
|
178
250
|
|
|
179
251
|
## Build
|
|
180
252
|
|
|
181
253
|
```bash
|
|
182
|
-
npm run build # Compila TS + genera dist/grisso.css (~
|
|
254
|
+
npm run build # Compila TS + genera dist/grisso.css (~154 KB)
|
|
183
255
|
npm run typecheck # Type-check sin emitir (tsc --noEmit)
|
|
184
256
|
npm run lint # Lint con Biome
|
|
185
257
|
npm test # Tests con Vitest
|
|
@@ -187,27 +259,20 @@ npm run test:watch # Tests en modo watch
|
|
|
187
259
|
npm run playground # Build + tree-shake + abre playground/index.html
|
|
188
260
|
```
|
|
189
261
|
|
|
190
|
-
###
|
|
191
|
-
|
|
192
|
-
El script de build acepta flags opcionales:
|
|
262
|
+
### CLI
|
|
193
263
|
|
|
194
|
-
|
|
195
|
-
node scripts/build.js # Full build → dist/grisso.css
|
|
196
|
-
node scripts/build.js --config grisso.config.mjs # Con config personalizada
|
|
197
|
-
node scripts/build.js --content "src/**/*.html" --output out.css # Tree-shaken
|
|
198
|
-
node scripts/build.js --config conf.mjs --content "src/**" --output x # Todo junto
|
|
199
|
-
```
|
|
264
|
+
El CLI se usa internamente y está disponible para consumidores via `npx grisso build`. Ver [Opción B: CLI](#opción-b-cli) para detalles completos.
|
|
200
265
|
|
|
201
|
-
Con `--content`, se usa PurgeCSS para eliminar clases no usadas (
|
|
266
|
+
Con `--content`, se usa PurgeCSS para eliminar clases no usadas (~154 KB → ~4 KB en el playground).
|
|
202
267
|
|
|
203
268
|
## Desarrollo: Añadir nuevas utilities
|
|
204
269
|
|
|
205
|
-
1. Edita el partial correspondiente en `src/
|
|
270
|
+
1. Edita el partial correspondiente en `src/partials/{category}.ts`
|
|
206
271
|
2. Usa `simpleClass`, `complexClass` o `customClass` con los tokens del config
|
|
207
272
|
3. Ejecuta `npm run build`
|
|
208
273
|
|
|
209
274
|
```ts
|
|
210
|
-
// src/
|
|
275
|
+
// src/partials/layout.ts
|
|
211
276
|
import { simpleClass, complexClass } from "../generators.js";
|
|
212
277
|
|
|
213
278
|
// Clase simple — genera .flex + variantes responsive
|