swl-ses 3.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/CLAUDE.md +425 -0
- package/_userland/agentes/.gitkeep +0 -0
- package/_userland/habilidades/.gitkeep +0 -0
- package/agentes/accesibilidad-wcag-swl.md +683 -0
- package/agentes/arquitecto-swl.md +210 -0
- package/agentes/auto-evolucion-swl.md +408 -0
- package/agentes/backend-api-swl.md +442 -0
- package/agentes/backend-node-swl.md +439 -0
- package/agentes/backend-python-swl.md +469 -0
- package/agentes/backend-workers-swl.md +444 -0
- package/agentes/cloud-infra-swl.md +466 -0
- package/agentes/consolidador-swl.md +487 -0
- package/agentes/datos-swl.md +568 -0
- package/agentes/depurador-swl.md +301 -0
- package/agentes/devops-ci-swl.md +352 -0
- package/agentes/disenador-ui-swl.md +546 -0
- package/agentes/documentador-swl.md +323 -0
- package/agentes/frontend-angular-swl.md +603 -0
- package/agentes/frontend-css-swl.md +700 -0
- package/agentes/frontend-react-swl.md +672 -0
- package/agentes/frontend-swl.md +483 -0
- package/agentes/frontend-tailwind-swl.md +808 -0
- package/agentes/implementador-swl.md +235 -0
- package/agentes/investigador-swl.md +274 -0
- package/agentes/investigador-ux-swl.md +482 -0
- package/agentes/migrador-swl.md +389 -0
- package/agentes/mobile-android-swl.md +473 -0
- package/agentes/mobile-cross-swl.md +501 -0
- package/agentes/mobile-ios-swl.md +464 -0
- package/agentes/notificador-swl.md +886 -0
- package/agentes/observabilidad-swl.md +408 -0
- package/agentes/orquestador-swl.md +490 -0
- package/agentes/planificador-swl.md +222 -0
- package/agentes/producto-prd-swl.md +565 -0
- package/agentes/release-manager-swl.md +545 -0
- package/agentes/rendimiento-swl.md +691 -0
- package/agentes/revisor-codigo-swl.md +254 -0
- package/agentes/revisor-seguridad-swl.md +316 -0
- package/agentes/tdd-qa-swl.md +323 -0
- package/agentes/ux-disenador-swl.md +498 -0
- package/bin/swl-ses.js +119 -0
- package/comandos/swl/actualizar.md +117 -0
- package/comandos/swl/aprender.md +348 -0
- package/comandos/swl/auditar-deps.md +390 -0
- package/comandos/swl/autoresearch.md +346 -0
- package/comandos/swl/checkpoint.md +296 -0
- package/comandos/swl/compactar.md +283 -0
- package/comandos/swl/crear-skill.md +609 -0
- package/comandos/swl/discutir-fase.md +230 -0
- package/comandos/swl/ejecutar-fase.md +302 -0
- package/comandos/swl/evolucionar.md +377 -0
- package/comandos/swl/instalar.md +220 -0
- package/comandos/swl/mapear-codebase.md +205 -0
- package/comandos/swl/nuevo-proyecto.md +154 -0
- package/comandos/swl/planear-fase.md +221 -0
- package/comandos/swl/release.md +405 -0
- package/comandos/swl/salud.md +382 -0
- package/comandos/swl/verificar.md +292 -0
- package/habilidades/accesibilidad-a11y/SKILL.md +584 -0
- package/habilidades/angular-avanzado/SKILL.md +491 -0
- package/habilidades/angular-moderno/SKILL.md +326 -0
- package/habilidades/api-rest-diseno/SKILL.md +302 -0
- package/habilidades/api-rest-diseno/recursos/openapi-template.yaml +506 -0
- package/habilidades/aprendizaje-continuo/SKILL.md +369 -0
- package/habilidades/async-python/SKILL.md +474 -0
- package/habilidades/auth-patrones/SKILL.md +488 -0
- package/habilidades/auto-evolucion-protocolo/SKILL.md +376 -0
- package/habilidades/autoresearch/SKILL.md +248 -0
- package/habilidades/autoresearch/recursos/checklist-template.md +191 -0
- package/habilidades/autoresearch/scripts/calcular-score.js +88 -0
- package/habilidades/checklist-calidad/SKILL.md +247 -0
- package/habilidades/checklist-calidad/recursos/quality-report-template.md +148 -0
- package/habilidades/checklist-seguridad/SKILL.md +224 -0
- package/habilidades/checkpoints-verificacion/SKILL.md +309 -0
- package/habilidades/checkpoints-verificacion/recursos/checkpoint-templates.md +360 -0
- package/habilidades/ci-cd-pipelines/SKILL.md +583 -0
- package/habilidades/ci-cd-pipelines/recursos/github-actions-template.yaml +403 -0
- package/habilidades/cloud-aws/SKILL.md +497 -0
- package/habilidades/compactacion-contexto/SKILL.md +201 -0
- package/habilidades/contenedores-docker/SKILL.md +453 -0
- package/habilidades/contenedores-docker/recursos/dockerfile-template.dockerfile +160 -0
- package/habilidades/css-moderno/SKILL.md +463 -0
- package/habilidades/datos-etl/SKILL.md +486 -0
- package/habilidades/dependencias-auditoria/SKILL.md +293 -0
- package/habilidades/deprecacion-migracion/SKILL.md +485 -0
- package/habilidades/design-tokens/SKILL.md +519 -0
- package/habilidades/discutir-fase/SKILL.md +167 -0
- package/habilidades/diseno-responsivo/SKILL.md +326 -0
- package/habilidades/django-experto/SKILL.md +395 -0
- package/habilidades/doc-sync/SKILL.md +259 -0
- package/habilidades/ejecutar-fase/SKILL.md +199 -0
- package/habilidades/estructura-proyecto-claude/SKILL.md +459 -0
- package/habilidades/estructura-proyecto-claude/recursos/claude-md-template.md +261 -0
- package/habilidades/estructura-proyecto-claude/recursos/frontmatter-y-hooks-referencia.md +213 -0
- package/habilidades/estructura-proyecto-claude/recursos/mcp-json-template.json +77 -0
- package/habilidades/estructura-proyecto-claude/recursos/variantes-por-stack.md +177 -0
- package/habilidades/event-driven/SKILL.md +580 -0
- package/habilidades/extractor-de-aprendizajes/SKILL.md +234 -0
- package/habilidades/fastapi-experto/SKILL.md +368 -0
- package/habilidades/frontend-avanzado/SKILL.md +555 -0
- package/habilidades/git-worktrees-paralelo/SKILL.md +246 -0
- package/habilidades/iam-secretos/SKILL.md +511 -0
- package/habilidades/instalar-sistema/SKILL.md +140 -0
- package/habilidades/kubernetes-orquestacion/SKILL.md +549 -0
- package/habilidades/manejo-errores/SKILL.md +512 -0
- package/habilidades/mapear-codebase/SKILL.md +199 -0
- package/habilidades/microservicios/SKILL.md +473 -0
- package/habilidades/mobile-flutter/SKILL.md +566 -0
- package/habilidades/mobile-react-native/SKILL.md +493 -0
- package/habilidades/monitoring-alertas/SKILL.md +447 -0
- package/habilidades/node-experto/SKILL.md +521 -0
- package/habilidades/notificaciones-multicanal/SKILL.md +448 -0
- package/habilidades/notificaciones-multicanal/recursos/config-template.json +115 -0
- package/habilidades/nuevo-proyecto/SKILL.md +183 -0
- package/habilidades/patrones-python/SKILL.md +381 -0
- package/habilidades/performance-baseline/SKILL.md +243 -0
- package/habilidades/planear-fase/SKILL.md +184 -0
- package/habilidades/postgresql-experto/SKILL.md +379 -0
- package/habilidades/react-experto/SKILL.md +434 -0
- package/habilidades/react-optimizacion/SKILL.md +328 -0
- package/habilidades/release-semver/SKILL.md +226 -0
- package/habilidades/release-semver/scripts/generar-changelog.sh +238 -0
- package/habilidades/sql-optimizacion/SKILL.md +314 -0
- package/habilidades/tailwind-experto/SKILL.md +412 -0
- package/habilidades/tdd-workflow/SKILL.md +267 -0
- package/habilidades/testing-python/SKILL.md +350 -0
- package/habilidades/threat-model-lite/SKILL.md +218 -0
- package/habilidades/typescript-avanzado/SKILL.md +454 -0
- package/habilidades/ux-diseno/SKILL.md +488 -0
- package/habilidades/validacion-ci-sistema/SKILL.md +543 -0
- package/habilidades/validacion-ci-sistema/scripts/validar-sistema.sh +286 -0
- package/habilidades/verificar-trabajo/SKILL.md +208 -0
- package/habilidades/wireframes-flujos/SKILL.md +396 -0
- package/habilidades/workflow-claude-code/SKILL.md +359 -0
- package/hooks/calidad-pre-commit.js +578 -0
- package/hooks/escaneo-secretos.js +302 -0
- package/hooks/extraccion-aprendizajes.js +550 -0
- package/hooks/linea-estado.js +249 -0
- package/hooks/monitor-contexto.js +230 -0
- package/hooks/proteccion-rutas.js +249 -0
- package/manifiestos/hooks-config.json +41 -0
- package/manifiestos/modulos.json +318 -0
- package/manifiestos/perfiles.json +189 -0
- package/package.json +45 -0
- package/plantillas/PROJECT.md +122 -0
- package/plantillas/REQUIREMENTS.md +132 -0
- package/plantillas/ROADMAP.md +143 -0
- package/plantillas/STATE.md +109 -0
- package/plantillas/research/ARCHITECTURE.md +220 -0
- package/plantillas/research/FEATURES.md +175 -0
- package/plantillas/research/PITFALLS.md +299 -0
- package/plantillas/research/STACK.md +233 -0
- package/plantillas/research/SUMMARY.md +165 -0
- package/plugin.json +144 -0
- package/reglas/accesibilidad.md +269 -0
- package/reglas/api-diseno.md +400 -0
- package/reglas/arquitectura.md +183 -0
- package/reglas/cloud-infra.md +247 -0
- package/reglas/docs.md +245 -0
- package/reglas/estilo-codigo.md +179 -0
- package/reglas/git-workflow.md +186 -0
- package/reglas/performance.md +195 -0
- package/reglas/pruebas.md +159 -0
- package/reglas/seguridad.md +151 -0
- package/reglas/skills-estandar.md +473 -0
- package/scripts/actualizar.js +51 -0
- package/scripts/desinstalar.js +86 -0
- package/scripts/doctor.js +222 -0
- package/scripts/inicializar.js +89 -0
- package/scripts/instalador.js +333 -0
- package/scripts/lib/detectar-runtime.js +177 -0
- package/scripts/lib/estado.js +112 -0
- package/scripts/lib/hooks-settings.js +283 -0
- package/scripts/lib/manifiestos.js +138 -0
- package/scripts/lib/seguridad.js +160 -0
- package/scripts/publicar.js +209 -0
- package/scripts/validar.js +120 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: css-moderno
|
|
3
|
+
description: CSS moderno 2024+. Cubre Container Queries, CSS Layers (@layer), Nesting nativo, Custom Properties avanzadas, funciones min/max/clamp/color-mix, propiedades lógicas (block/inline), View Transitions API, animaciones performantes solo-compositor, dark mode patterns y anti-patrones críticos.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CSS Moderno — 2024+
|
|
7
|
+
|
|
8
|
+
## Filosofía
|
|
9
|
+
|
|
10
|
+
CSS moderno elimina la necesidad de preprocesadores para la mayoría de los casos.
|
|
11
|
+
Las características nativas del 2023-2024 cubren lo que antes requería Sass/Less,
|
|
12
|
+
con mejor rendimiento y sin dependencias de build.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Container Queries
|
|
17
|
+
|
|
18
|
+
Las Container Queries cambian el paradigma: en lugar de basar el responsive en
|
|
19
|
+
el viewport, los componentes responden al tamaño de su contenedor padre.
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
/* Definir el contenedor */
|
|
23
|
+
.card-wrapper {
|
|
24
|
+
container-type: inline-size;
|
|
25
|
+
container-name: tarjeta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* El componente responde a su contenedor, no al viewport */
|
|
29
|
+
.card {
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-columns: 1fr;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@container tarjeta (min-width: 400px) {
|
|
35
|
+
.card {
|
|
36
|
+
grid-template-columns: auto 1fr;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@container tarjeta (min-width: 600px) {
|
|
41
|
+
.card {
|
|
42
|
+
grid-template-columns: 200px 1fr 100px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Container Query con unidades de contenedor
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
.card-titulo {
|
|
51
|
+
/* cqi = 1% del inline-size del contenedor */
|
|
52
|
+
font-size: clamp(1rem, 4cqi, 2rem);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 2. CSS Layers (@layer)
|
|
59
|
+
|
|
60
|
+
`@layer` resuelve la especificidad sin recurrir a `!important`.
|
|
61
|
+
Declara el orden de capas: la última tiene mayor prioridad.
|
|
62
|
+
|
|
63
|
+
```css
|
|
64
|
+
/* Declarar el orden de capas al inicio */
|
|
65
|
+
@layer reset, base, componentes, utilidades, overrides;
|
|
66
|
+
|
|
67
|
+
@layer reset {
|
|
68
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
69
|
+
* { margin: 0; }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@layer base {
|
|
73
|
+
body { font-family: system-ui, sans-serif; }
|
|
74
|
+
a { color: inherit; }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@layer componentes {
|
|
78
|
+
.btn {
|
|
79
|
+
padding: 0.5rem 1rem;
|
|
80
|
+
border-radius: 0.25rem;
|
|
81
|
+
background: var(--color-primario);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@layer utilidades {
|
|
86
|
+
.mt-4 { margin-top: 1rem; }
|
|
87
|
+
.text-center { text-align: center; }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Las utilidades siempre ganan sobre componentes, sin !important */
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Importar estilos de terceros en capas
|
|
94
|
+
|
|
95
|
+
```css
|
|
96
|
+
/* Aislar Normalize o Bootstrap en su propia capa */
|
|
97
|
+
@import url('normalize.css') layer(reset);
|
|
98
|
+
@import url('bootstrap.css') layer(frameworks);
|
|
99
|
+
|
|
100
|
+
/* Tus estilos siempre ganan, sin conflictos */
|
|
101
|
+
@layer componentes {
|
|
102
|
+
.btn { /* Sobrescribe Bootstrap sin lucha de especificidad */ }
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 3. CSS Nesting Nativo
|
|
109
|
+
|
|
110
|
+
CSS nativo ya soporta nesting sin Sass:
|
|
111
|
+
|
|
112
|
+
```css
|
|
113
|
+
/* Nesting básico */
|
|
114
|
+
.nav {
|
|
115
|
+
display: flex;
|
|
116
|
+
gap: 1rem;
|
|
117
|
+
|
|
118
|
+
& a {
|
|
119
|
+
text-decoration: none;
|
|
120
|
+
color: var(--color-texto);
|
|
121
|
+
|
|
122
|
+
&:hover {
|
|
123
|
+
color: var(--color-primario);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&.activo {
|
|
127
|
+
font-weight: bold;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Media query anidada */
|
|
132
|
+
@media (max-width: 768px) {
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Nesting con pseudo-elementos
|
|
139
|
+
|
|
140
|
+
```css
|
|
141
|
+
.card {
|
|
142
|
+
position: relative;
|
|
143
|
+
|
|
144
|
+
&::before {
|
|
145
|
+
content: '';
|
|
146
|
+
position: absolute;
|
|
147
|
+
inset: 0;
|
|
148
|
+
background: linear-gradient(to bottom, transparent, rgb(0 0 0 / 0.5));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
& > .card-content {
|
|
152
|
+
position: relative;
|
|
153
|
+
z-index: 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 4. Custom Properties Avanzadas
|
|
161
|
+
|
|
162
|
+
### Design tokens con custom properties
|
|
163
|
+
|
|
164
|
+
```css
|
|
165
|
+
:root {
|
|
166
|
+
/* Primitivos */
|
|
167
|
+
--azul-500: oklch(56% 0.2 250);
|
|
168
|
+
--azul-600: oklch(46% 0.2 250);
|
|
169
|
+
|
|
170
|
+
/* Semánticos */
|
|
171
|
+
--color-primario: var(--azul-500);
|
|
172
|
+
--color-primario-hover: var(--azul-600);
|
|
173
|
+
--color-superficie: #ffffff;
|
|
174
|
+
--color-texto: #0f172a;
|
|
175
|
+
|
|
176
|
+
/* Espaciado */
|
|
177
|
+
--espacio-1: 0.25rem;
|
|
178
|
+
--espacio-2: 0.5rem;
|
|
179
|
+
--espacio-4: 1rem;
|
|
180
|
+
|
|
181
|
+
/* Tipografía */
|
|
182
|
+
--fuente-base: 'Inter', system-ui, sans-serif;
|
|
183
|
+
--tamano-sm: 0.875rem;
|
|
184
|
+
--tamano-base: 1rem;
|
|
185
|
+
--tamano-lg: 1.125rem;
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Custom Properties con @property (tipadas)
|
|
190
|
+
|
|
191
|
+
```css
|
|
192
|
+
/* Animaciones de gradiente y valores no-string */
|
|
193
|
+
@property --porcentaje {
|
|
194
|
+
syntax: '<percentage>';
|
|
195
|
+
inherits: false;
|
|
196
|
+
initial-value: 0%;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.barra {
|
|
200
|
+
background: linear-gradient(to right, var(--color-primario) var(--porcentaje), #e2e8f0 var(--porcentaje));
|
|
201
|
+
transition: --porcentaje 0.3s ease;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.barra:hover {
|
|
205
|
+
--porcentaje: 75%;
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 5. Funciones Matemáticas
|
|
212
|
+
|
|
213
|
+
### min(), max(), clamp()
|
|
214
|
+
|
|
215
|
+
```css
|
|
216
|
+
/* Tipografía fluida — sin media queries */
|
|
217
|
+
h1 {
|
|
218
|
+
/* min 1.5rem, preferido 4vw, max 3rem */
|
|
219
|
+
font-size: clamp(1.5rem, 4vw, 3rem);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Contenedor que nunca es menor a 300px ni mayor a 600px */
|
|
223
|
+
.tarjeta {
|
|
224
|
+
width: clamp(300px, 50%, 600px);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* Padding que se adapta sin romperse */
|
|
228
|
+
.seccion {
|
|
229
|
+
padding-inline: max(1rem, (100% - 1200px) / 2);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### color-mix()
|
|
234
|
+
|
|
235
|
+
```css
|
|
236
|
+
/* Mezclar colores nativamente */
|
|
237
|
+
.boton-hover {
|
|
238
|
+
--color-base: var(--color-primario);
|
|
239
|
+
background-color: color-mix(in oklch, var(--color-base) 80%, black);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Transparencia */
|
|
243
|
+
.overlay {
|
|
244
|
+
background: color-mix(in srgb, var(--color-primario) 20%, transparent);
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### round(), mod(), rem()
|
|
249
|
+
|
|
250
|
+
```css
|
|
251
|
+
.grid {
|
|
252
|
+
/* Número exacto de columnas sin espacio sobrante */
|
|
253
|
+
grid-template-columns: repeat(auto-fill, minmax(round(down, 100%, 150px), 1fr));
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 6. Propiedades Lógicas
|
|
260
|
+
|
|
261
|
+
Las propiedades lógicas funcionan correctamente en RTL y modos de escritura
|
|
262
|
+
vertical sin necesidad de sobreescribir estilos:
|
|
263
|
+
|
|
264
|
+
```css
|
|
265
|
+
/* Físico — mal para internacionalización */
|
|
266
|
+
.elemento {
|
|
267
|
+
margin-left: 1rem;
|
|
268
|
+
padding-right: 2rem;
|
|
269
|
+
border-top: 1px solid;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* Lógico — correcto para cualquier dirección */
|
|
273
|
+
.elemento {
|
|
274
|
+
margin-inline-start: 1rem; /* izq en LTR, der en RTL */
|
|
275
|
+
padding-inline-end: 2rem; /* der en LTR, izq en RTL */
|
|
276
|
+
border-block-start: 1px solid;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Atajos lógicos */
|
|
280
|
+
.caja {
|
|
281
|
+
margin-inline: auto; /* margin-left + margin-right */
|
|
282
|
+
padding-block: 1rem; /* padding-top + padding-bottom */
|
|
283
|
+
inset-inline: 0; /* left: 0; right: 0 */
|
|
284
|
+
border-start-start-radius: 8px; /* top-left en LTR */
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## 7. View Transitions API
|
|
291
|
+
|
|
292
|
+
```css
|
|
293
|
+
/* Transiciones nativas entre páginas/estados */
|
|
294
|
+
::view-transition-old(root) {
|
|
295
|
+
animation: salir 0.3s ease-in;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
::view-transition-new(root) {
|
|
299
|
+
animation: entrar 0.3s ease-out;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* Transición de elemento específico */
|
|
303
|
+
.hero-imagen {
|
|
304
|
+
view-transition-name: hero;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
::view-transition-old(hero),
|
|
308
|
+
::view-transition-new(hero) {
|
|
309
|
+
object-fit: cover;
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```javascript
|
|
314
|
+
// Trigger en JavaScript
|
|
315
|
+
document.startViewTransition(() => {
|
|
316
|
+
actualizarDOM(); // Cambiar contenido aquí
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 8. Animaciones Performantes (Solo-compositor)
|
|
323
|
+
|
|
324
|
+
Solo las propiedades `transform` y `opacity` se animan en el compositor
|
|
325
|
+
(GPU), sin triggear layout ni paint:
|
|
326
|
+
|
|
327
|
+
```css
|
|
328
|
+
/* BIEN: solo compositor */
|
|
329
|
+
.boton {
|
|
330
|
+
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.boton:hover {
|
|
334
|
+
transform: translateY(-2px) scale(1.02);
|
|
335
|
+
opacity: 0.9;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* MAL: trigerea layout (costoso) */
|
|
339
|
+
.boton:hover {
|
|
340
|
+
margin-top: -2px; /* layout thrashing */
|
|
341
|
+
width: 102%; /* layout thrashing */
|
|
342
|
+
top: -2px; /* layout (sin position relative guardado) */
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Hints de rendimiento
|
|
347
|
+
|
|
348
|
+
```css
|
|
349
|
+
/* Avisar al navegador que el elemento será animado */
|
|
350
|
+
.elemento-animado {
|
|
351
|
+
will-change: transform; /* SOLO usar cuando hay problema de rendimiento real */
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* Contener el paint a este elemento */
|
|
355
|
+
.componente-independiente {
|
|
356
|
+
contain: strict;
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 9. Dark Mode Patterns
|
|
363
|
+
|
|
364
|
+
### Enfoque con custom properties (recomendado)
|
|
365
|
+
|
|
366
|
+
```css
|
|
367
|
+
:root {
|
|
368
|
+
color-scheme: light dark;
|
|
369
|
+
|
|
370
|
+
--color-fondo: #ffffff;
|
|
371
|
+
--color-texto: #0f172a;
|
|
372
|
+
--color-borde: #e2e8f0;
|
|
373
|
+
--color-superficie: #f8fafc;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@media (prefers-color-scheme: dark) {
|
|
377
|
+
:root {
|
|
378
|
+
--color-fondo: #0f172a;
|
|
379
|
+
--color-texto: #f1f5f9;
|
|
380
|
+
--color-borde: #1e293b;
|
|
381
|
+
--color-superficie: #1e293b;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* Con toggle manual usando data-tema */
|
|
386
|
+
[data-tema='claro'] { /* mismas custom props de light */ }
|
|
387
|
+
[data-tema='oscuro'] { /* mismas custom props de dark */ }
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Imágenes adaptadas
|
|
391
|
+
|
|
392
|
+
```css
|
|
393
|
+
.logo {
|
|
394
|
+
content: url('/logo-claro.svg');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@media (prefers-color-scheme: dark) {
|
|
398
|
+
.logo {
|
|
399
|
+
content: url('/logo-oscuro.svg');
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 10. Anti-patrones
|
|
407
|
+
|
|
408
|
+
### !important — never
|
|
409
|
+
|
|
410
|
+
```css
|
|
411
|
+
/* MAL: rompe la cascada, difícil de mantener */
|
|
412
|
+
.titulo { color: red !important; }
|
|
413
|
+
|
|
414
|
+
/* BIEN: usar @layer para controlar especificidad */
|
|
415
|
+
@layer overrides {
|
|
416
|
+
.titulo { color: red; }
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Z-index wars
|
|
421
|
+
|
|
422
|
+
```css
|
|
423
|
+
/* MAL: z-index arbitrarios que escalan infinitamente */
|
|
424
|
+
.modal { z-index: 9999; }
|
|
425
|
+
.tooltip { z-index: 99999; }
|
|
426
|
+
.notificacion { z-index: 999999; }
|
|
427
|
+
|
|
428
|
+
/* BIEN: sistema de capas con custom properties */
|
|
429
|
+
:root {
|
|
430
|
+
--z-base: 1;
|
|
431
|
+
--z-dropdown: 100;
|
|
432
|
+
--z-sticky: 200;
|
|
433
|
+
--z-modal: 300;
|
|
434
|
+
--z-tooltip: 400;
|
|
435
|
+
--z-notificacion: 500;
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Layout thrashing en JS
|
|
440
|
+
|
|
441
|
+
```javascript
|
|
442
|
+
// MAL: leer y escribir el DOM alternadamente
|
|
443
|
+
for (const el of elementos) {
|
|
444
|
+
const altura = el.offsetHeight; // fuerza layout
|
|
445
|
+
el.style.height = (altura * 2) + 'px'; // invalida layout
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// BIEN: separar lecturas de escrituras
|
|
449
|
+
const alturas = elementos.map(el => el.offsetHeight); // todas las lecturas
|
|
450
|
+
elementos.forEach((el, i) => {
|
|
451
|
+
el.style.height = (alturas[i] * 2) + 'px'; // todas las escrituras
|
|
452
|
+
});
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Unidades fijas para tipografía
|
|
456
|
+
|
|
457
|
+
```css
|
|
458
|
+
/* MAL: ignora las preferencias de zoom del usuario */
|
|
459
|
+
body { font-size: 16px; }
|
|
460
|
+
|
|
461
|
+
/* BIEN: relativa a la preferencia del usuario */
|
|
462
|
+
body { font-size: 1rem; }
|
|
463
|
+
```
|