@gustavogalveza/design-system 0.7.0 → 0.9.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/CHANGELOG.md +52 -0
- package/CONFORMANCE.md +24 -35
- package/README.md +63 -8
- package/package.json +1 -1
- package/src/behaviors/button-group.d.ts +60 -0
- package/src/behaviors/button-group.js +489 -0
- package/src/components/button-group.css +71 -4
- package/src/components/progress.css +54 -4
- package/src/index.css +1 -0
- package/src/shapes.css +58 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,58 @@
|
|
|
3
3
|
Formato basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1.1.0/)
|
|
4
4
|
y versionado [SemVer](https://semver.org/lang/es/).
|
|
5
5
|
|
|
6
|
+
## 0.9.0 — 2026-12-05
|
|
7
|
+
|
|
8
|
+
Wavy progress y MaterialShapes (vertical C).
|
|
9
|
+
|
|
10
|
+
### Añadido
|
|
11
|
+
|
|
12
|
+
- `progress.css`: variante `--wavy` lineal (banda de 10 dp enmascarada con una
|
|
13
|
+
onda de 40 px repetida; 20 px en indeterminado) y circular (caja de 48 dp,
|
|
14
|
+
`path` ondulado con `pathLength="100"`, 1,6 dp de amplitud y nueve ondas).
|
|
15
|
+
- `src/shapes.css`: seis formas curadas (`--circle`, `--square`, `--diamond`,
|
|
16
|
+
`--triangle`, `--hexagon`, `--burst`) con 48 vértices y morph por
|
|
17
|
+
`clip-path`; `--m3-shape-size` y `--m3-shape-color`.
|
|
18
|
+
- `preview/shapes.html` con morph interactivo y entrada en la galería.
|
|
19
|
+
- Preview de wavy lineal y circular en `preview/progress.html`.
|
|
20
|
+
- `tests/progress-wavy.test.mjs` y `tests/shapes.test.mjs`.
|
|
21
|
+
|
|
22
|
+
### Cambiado
|
|
23
|
+
|
|
24
|
+
- El índice del README documenta Progress y Formas.
|
|
25
|
+
- La versión del paquete pasa a 0.9.0.
|
|
26
|
+
|
|
27
|
+
### Verificación
|
|
28
|
+
|
|
29
|
+
- `npm test` → 39/39.
|
|
30
|
+
- `esbuild src/index.css` compila; las previews cargan sin errores.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 0.8.0 — 2026-12-05
|
|
34
|
+
|
|
35
|
+
Button group Expressive: selección, ancho animado y overflow.
|
|
36
|
+
|
|
37
|
+
### Añadido
|
|
38
|
+
|
|
39
|
+
- `behaviors/button-group.js`: selección `single`/`multiple` con
|
|
40
|
+
`aria-pressed`, `animateWidth` y overflow a un `m3-menu` generado.
|
|
41
|
+
- CSS del connected: `aria-pressed="true"` pasa a `CornerFull`; `data-animate-width`
|
|
42
|
+
expande el botón pulsado un 15 % y comprime a sus vecinos; `data-overflow`
|
|
43
|
+
oculta los ítems que no caben.
|
|
44
|
+
- Nueva sección de selección, ancho y overflow en `preview/button-group.html`.
|
|
45
|
+
- `tests/button-group.test.mjs` para overflow, selección y contrato CSS.
|
|
46
|
+
- `.d.ts` del behavior.
|
|
47
|
+
|
|
48
|
+
### Cambiado
|
|
49
|
+
|
|
50
|
+
- El índice del README anuncia `behaviors/button-group.js`.
|
|
51
|
+
- La versión del paquete pasa a 0.8.0.
|
|
52
|
+
|
|
53
|
+
### Verificación
|
|
54
|
+
|
|
55
|
+
- `npm test` → 30/30.
|
|
56
|
+
- `esbuild src/index.css` compila; la preview carga sin errores.
|
|
57
|
+
|
|
6
58
|
## 0.7.0 — 2026-12-04
|
|
7
59
|
|
|
8
60
|
Movimiento spring para CSS, generado desde Compose Material3 1.5.
|
package/CONFORMANCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Conformidad M3 Expressive — auditoría web
|
|
2
2
|
|
|
3
|
-
> Fecha: **2026-12-
|
|
3
|
+
> Fecha: **2026-12-05** · Base: `@gustavogalveza/design-system@0.9.0` ·
|
|
4
4
|
> Alcance: adaptación web token-first, no un port de Android.
|
|
5
5
|
|
|
6
6
|
Este documento responde a una pregunta concreta: **qué tan fiel es el paquete a
|
|
@@ -11,22 +11,19 @@ fija la referencia, mide la brecha y prioriza.
|
|
|
11
11
|
|
|
12
12
|
El paquete cubre la **base visual** (color, tipografía, forma, elevación,
|
|
13
13
|
espaciado, estados) y varios componentes Expressive **total o parcialmente**.
|
|
14
|
-
La suite pasa
|
|
14
|
+
La suite pasa 39 pruebas; la validación visual se hará en la vertical de calidad.
|
|
15
15
|
|
|
16
16
|
La brecha principal no es “faltan colores o clases”. Es **comportamiento**:
|
|
17
17
|
|
|
18
18
|
| Prioridad | Brecha | Por qué importa |
|
|
19
19
|
|---|---|---|
|
|
20
|
-
| **P1** | Button group Expressive completo | Faltan overflow menu, animación de ancho y selección conectada; es un componente central de M3E. |
|
|
21
|
-
| **P2** | Wavy progress | Componente Expressive publicado y hoy declarado fuera de alcance. |
|
|
22
|
-
| **P2** | Biblioteca de formas y morph | Solo el loading indicator usa 7 formas aproximadas; no hay API general para `MaterialShapes`. |
|
|
23
20
|
| **P2** | Variantes Expressive 1.5 | App bar con colapso, toolbar con overflow, search con morph de ancho y variantes 1.5, chips con morph, text fields expresivos, menús selectable/checkable, listas segmented, time picker y tooltip expresivos. |
|
|
24
21
|
| **P2** | Ejes variables de tipografía | La escala está, pero `GRAD`/`wdth`/`slnt` no se exponen ni se prueban. |
|
|
25
22
|
| **P3** | Cobertura y exactitud | Vectores exactos del loading, bottom app bar, drag handle, `prefers-contrast`, previews de ejes. |
|
|
26
23
|
|
|
27
|
-
**Decisión recomendada:** no perseguir paridad pixel a pixel con Compose.
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
**Decisión recomendada:** no perseguir paridad pixel a pixel con Compose. Los
|
|
25
|
+
P1 de motion (0.7.0), button group (0.8.0) y wavy progress + shapes (0.9.0)
|
|
26
|
+
están cerrados; siguen las **variantes Expressive 1.5** y el resto documentado
|
|
30
27
|
como adaptación web.
|
|
31
28
|
|
|
32
29
|
## Referencia canónica
|
|
@@ -70,7 +67,7 @@ exactitud o documentación. La regresión visual es transversal y se trata apart
|
|
|
70
67
|
|---|---|---|---|---|
|
|
71
68
|
| Color roles | **Cumple** | 57 roles hex + `source` en `src/colors.css:11-133`; pares `on-*` medidos ≥4.5:1 en `tests/tokens.test.mjs` | Los contenedores suaves quedan en 1.0–1.3:1 contra `surface`, como el baseline M3. Dynamic color y niveles de contraste son de plataforma. | P3 |
|
|
72
69
|
| Tipografía | **Parcial** | 15+15 estilos y 45 alias emphasized en `src/tokens.css:89-184`; alturas por idioma en `src/base.css:334-369` | Faltan tokens/preview de ejes `GRAD`, `wdth`, `slnt`; la fuente la sirve el consumidor. | P2 |
|
|
73
|
-
| Forma | **Parcial** | Escala de 10 pasos en `src/tokens.css:186-196`; morph de botones/icon buttons/split/segmented | No
|
|
70
|
+
| Forma | **Parcial** | Escala de 10 pasos en `src/tokens.css:186-196`; morph de botones/icon buttons/split/segmented; seis formas con morph en `src/shapes.css` | No están las 35 `MaterialShapes`: hay un subconjunto curado de seis siluetas de 48 vértices, documentado como utilidad CSS y no como réplica de los trazados. El loading indicator conserva sus 7 aproximaciones. | P3 |
|
|
74
71
|
| Movimiento | **Cumple (curvas)** | Curvas spring generadas en `src/tokens.css:291-324`; 16 duraciones y fallback en `src/tokens.css:198-250` | Las curvas `linear()` se generan desde damping/stiffness de Compose y se activan bajo `@supports`; sin soporte queda `cubic-bezier`. Umbral de asentamiento 0,1 % (Compose usa 1 %), documentado como divergencia web. La física interrumpible queda como WAAPI opcional P3. | — |
|
|
75
72
|
| Elevación | **Cumple** | Niveles 0–5 en `src/tokens.css:252-258` | La sombra exacta es traducción web; no se promete dp. | — |
|
|
76
73
|
| Capas de estado | **Cumple** | `--state-*` en `src/tokens.css:260-264` | — | — |
|
|
@@ -84,13 +81,13 @@ exactitud o documentación. La regresión visual es transversal y se trata apart
|
|
|
84
81
|
| App bars | **Parcial** | `small`, `medium`, `medium-flexible`, `large`, `large-flexible` en `src/components/app-bar.css:87-128` | Las flexibles son estáticas: abrazan el contenido y no colapsan por scroll. El propio archivo dice que el colapso no es CSS (`app-bar.css:9`). | P2 |
|
|
85
82
|
| Buttons | **Cumple** | Tallas XS–XL, formas, colores y `aria-pressed` en `src/components/button.css:238-279` | — | — |
|
|
86
83
|
| Toggle button | **Cumple** | Variante de alternancia en `src/components/button.css:238-279` | Compose 1.5 tiene API propia; el CSS cubre el estado visual y accesible. | — |
|
|
87
|
-
| Button groups | **
|
|
84
|
+
| Button groups | **Cumple (behavior)** | CSS en `src/components/button-group.css`; selector, ancho y overflow en `src/behaviors/button-group.js` | `aria-pressed` single/multiple, `animateWidth` con flex-grow y overflow a menú. La animación de ancho es aproximación CSS, no el layout medido de Compose. | — |
|
|
88
85
|
| Split button | **Parcial** | Menú con `behaviors/menu.js`, formas y estados en `src/components/split-button.css` | El menú se ancla a la flecha y no hay animación de ancho; documentado. | P3 |
|
|
89
86
|
| FAB y FAB menu | **Cumple** | FAB menu con foco, teclado, cascada y estados de elevación en `src/components/fab-menu.css` | El ítem va 0 en reposo/disabled, 4 en hover y 3 en foco/pulsado; reposo/disabled los cubre `tests/tokens.test.mjs` y los estados `tests/p3.test.mjs`. | — |
|
|
90
87
|
| Icon buttons | **Cumple** | Tallas, formas y estados en `src/components/icon-button.css` | — | — |
|
|
91
88
|
| Toolbars | **Parcial** | Docked, floating y vibrant en `src/components/toolbar.css` | No hay overflow menu; `behaviors/toolbar.js` solo hace roving tabindex. Compose 1.5 incluye overflow en FloatingToolbar. | P2 |
|
|
92
89
|
| Loading indicator | **Parcial** | Morph de 7 formas con `clip-path` en `src/components/loading-indicator.css:20-45` | Los vectores son aproximaciones muestreadas, no los trazados originales; documentado como D1. | P3 |
|
|
93
|
-
| Progress | **
|
|
90
|
+
| Progress | **Cumple (wavy)** | Linear/circular planos y `--wavy` lineal/circular en `src/components/progress.css` | El wavy lineal no cambia el marcado; el circular exige `<path>` con el `d` ondulado y `pathLength="100"`, documentado y demostrado en la preview. | — |
|
|
94
91
|
| Carousel | **Parcial** | Multi-browse, hero, center-aligned hero y uncontained en `src/components/carousel.css:303-363` | El scroll es nativo; no hay parallax ni física de gesto Android. | P3 |
|
|
95
92
|
| Search | **Parcial** | Docked y expanded en `src/components/search.css` | El ancho no morpha al enfocar y faltan variantes 1.5 (`AppBarWithSearch`, full-screen contained). | P2 |
|
|
96
93
|
| Navegación | **Cumple** | Bar, rail y drawer, incluido rail modal en `src/components/navigation-*.css` | — | — |
|
|
@@ -113,7 +110,7 @@ exactitud o documentación. La regresión visual es transversal y se trata apart
|
|
|
113
110
|
|---|---|
|
|
114
111
|
| Dynamic color / HCT en runtime | **No aplica**. El paquete es CSS; se puede generar la paleta en build con MCU y publicar roles. |
|
|
115
112
|
| Haptics, predictive back, overscroll, system bars | **No aplica**. Son APIs de Android. |
|
|
116
|
-
| 35 formas exactas | **
|
|
113
|
+
| 35 formas exactas | **Parcial**. Subconjunto curado de 6 formas con morph en `src/shapes.css`; el loading indicator conserva 7 siluetas aproximadas. No se copian los 35 trazados originales. |
|
|
117
114
|
| Física de springs exacta | **Parcial**. Se aproxima con `linear()` y un umbral de asentamiento de 0,1 % (Compose usa 1 %); el helper WAAPI interrumpible queda en P3. No se promete paridad con Compose. |
|
|
118
115
|
| Fuentes | **Consumidor**. El paquete no sirve Roboto Flex ni Material Symbols. |
|
|
119
116
|
| Terceros (`md3.io`, React/Angular) | **No canónicos**. Se pueden comparar, no copiar como especificación. |
|
|
@@ -122,40 +119,32 @@ exactitud o documentación. La regresión visual es transversal y se trata apart
|
|
|
122
119
|
|
|
123
120
|
### P1 — Diferenciadores Expressive
|
|
124
121
|
|
|
125
|
-
|
|
126
|
-
- Overflow menu cuando no caben los ítems.
|
|
127
|
-
- `animateWidth` al pulsar (expansión del ítem y compresión de vecinos).
|
|
128
|
-
- Selección conectada single/multi con forma y estado accesible.
|
|
129
|
-
- Criterio: mismo markup que hoy; el comportamiento se añade con un módulo opcional.
|
|
130
|
-
|
|
131
|
-
Motion springs se cerró en **0.7.0** con curvas `linear()` generadas y fallback; el helper WAAPI para gestos interrumpibles sigue en P3.
|
|
122
|
+
Ninguno abierto: motion springs (**0.7.0**) y button group (**0.8.0**) cerrados. El helper WAAPI interrumpible sigue en P3.
|
|
132
123
|
|
|
133
124
|
### P2 — Componentes y tokens
|
|
134
125
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
4. **Ejes tipográficos**: tokens `GRAD`/`wdth`/`slnt` y preview con la fuente servida.
|
|
138
|
-
5. **Variantes Expressive 1.5**: colapso de app bar, overflow de toolbar, morph de ancho y variantes `AppBarWithSearch`/full-screen contained de search, chips con morph, text fields expresivos, menús selectable/checkable, listas segmented, `VibrantTimePickerDialog`/time picker scrollable y tooltip con caret. Cada una con decisión “implementar o documentar”.
|
|
126
|
+
1. **Ejes tipográficos**: tokens `GRAD`/`wdth`/`slnt` y preview con la fuente servida.
|
|
127
|
+
2. **Variantes Expressive 1.5**: colapso de app bar, overflow de toolbar, morph de ancho y variantes `AppBarWithSearch`/full-screen contained de search, chips con morph, text fields expresivos, menús selectable/checkable, listas segmented, `VibrantTimePickerDialog`/time picker scrollable y tooltip con caret. Cada una con decisión “implementar o documentar”.
|
|
139
128
|
|
|
140
129
|
### P3 — Cobertura y exactitud
|
|
141
130
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
131
|
+
5. Split button (animación de ancho) y carousel (parallax), si el producto los necesita.
|
|
132
|
+
6. Densidad por componente (hoy solo segmented) o exclusión explícita.
|
|
133
|
+
7. Vectores exactos del loading indicator (si se consigue la fuente).
|
|
134
|
+
8. `prefers-contrast: more` o declaración definitiva de no soporte.
|
|
135
|
+
9. Bottom app bar y drag handle independiente, si el producto los necesita.
|
|
136
|
+
10. Previews de ejes variables y estados que aún no se demuestran.
|
|
137
|
+
11. Comparativa documentada con kits web de terceros, sin adoptarlos como canon.
|
|
138
|
+
12. Regresión visual (transversal): Playwright con 320/600/1440, claro/oscuro, RTL, 200 % y reduced motion.
|
|
139
|
+
13. Helper WAAPI opcional para springs interrumpibles en gestos.
|
|
151
140
|
|
|
152
141
|
## Plan de implementación por verticales
|
|
153
142
|
|
|
154
143
|
| Vertical | Contenido | Verificación |
|
|
155
144
|
|---|---|---|
|
|
156
145
|
| **A. Motion** | **Hecho en 0.7.0**: tokens de springs, `linear()` generado, fallback y migración de morphs. Queda WAAPI opcional. | Tests de tokens, preview de movimiento, reduced motion, comparación visual. |
|
|
157
|
-
| **B. Button group** |
|
|
158
|
-
| **C. Wavy + shapes** |
|
|
146
|
+
| **B. Button group** | **Hecho en 0.8.0**: overflow, `animateWidth` y selección conectada con behavior opcional. | Tests de estados, 320 px, RTL y teclado; pendiente probar con lector de pantalla real. |
|
|
147
|
+
| **C. Wavy + shapes** | **Hecho en 0.9.0**: wavy lineal/circular, seis formas con morph y preview interactiva. | Tests de geometría y contrato CSS, verificación manual en Chrome, reduced motion y preview de formas; pendiente lector de pantalla real y matriz de navegadores. |
|
|
159
148
|
| **D. Variantes 1.5** | App bar, toolbar, search, chips, text fields, menús y listas | Tests de estados y previews por componente. |
|
|
160
149
|
| **E. Calidad** | Regresión visual, ejes de fuente, docs, release | Suite completa, capturas base, `verificar-*`, changelog. |
|
|
161
150
|
|
|
@@ -193,7 +182,7 @@ se prueba que el fallback sigue siendo usable.
|
|
|
193
182
|
|
|
194
183
|
- Componentes locales: `README.md:148-183` y `src/components/`.
|
|
195
184
|
- Tokens: `src/tokens.css`, `src/colors.css`, `src/base.css`.
|
|
196
|
-
- Pruebas: `tests/tokens.test.mjs`, `tests/p3.test.mjs`, `tests/docs.test.mjs` y `tests/
|
|
185
|
+
- Pruebas: `tests/tokens.test.mjs`, `tests/p3.test.mjs`, `tests/docs.test.mjs`, `tests/springs.test.mjs` y `tests/button-group.test.mjs` (30/30).
|
|
197
186
|
- Previews: `preview/typography.html`, `preview/schemes.html`, `preview/motion.html`, `preview.html`.
|
|
198
187
|
- Generador de springs: `scripts/springs.mjs`, `scripts/generate-springs.mjs`.
|
|
199
188
|
- Documentación de auditoría de componentes: interna y no versionada; no forma parte del PR.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ funciona en Svelte, Angular, Vue o React.
|
|
|
12
12
|
El código es original y se distribuye bajo **MIT**. Ver `LICENSE`.
|
|
13
13
|
|
|
14
14
|
**Demo:** [design-system.ggalvez.cl](https://design-system.ggalvez.cl) — la
|
|
15
|
-
landing y la galería con los
|
|
15
|
+
landing y la galería con los 38 componentes, en vivo.
|
|
16
16
|
|
|
17
17
|
**Conformidad:** [CONFORMANCE.md](./CONFORMANCE.md) — auditoría de brechas
|
|
18
18
|
frente a M3 Expressive y plan priorizado.
|
|
@@ -99,6 +99,7 @@ se degrada en silencio, así que conviene saber qué se pierde.
|
|
|
99
99
|
| `@starting-style` | 11 archivos | Sin animación de entrada |
|
|
100
100
|
| `text-wrap: balance` | 13 archivos | Títulos sin balanceo |
|
|
101
101
|
| `position-area` | 3 archivos | Menús y desplegables centrados por el navegador |
|
|
102
|
+
| `mask-image` con SVG | Wavy progress | La onda desaparece y queda una barra plana de 10 px |
|
|
102
103
|
| `:modal`, `container-type`, `interpolate-size` | 3 / 1 / 1 | Sin bloqueo de fondo, sin escalado por columna, sin animación de ancho |
|
|
103
104
|
|
|
104
105
|
Probado en navegador real (Chrome/Edge 158). Las demás líneas son la versión
|
|
@@ -107,7 +108,7 @@ Firefox 128+**.
|
|
|
107
108
|
|
|
108
109
|
## Behaviors
|
|
109
110
|
|
|
110
|
-
Los módulos de `src/behaviors/` son opcionales. **
|
|
111
|
+
Los módulos de `src/behaviors/` son opcionales. **Trece de ellos se
|
|
111
112
|
autoinicializan al importarse** (`tabs`, `menu` y `time-picker` no). Para
|
|
112
113
|
inicializar a mano:
|
|
113
114
|
|
|
@@ -119,7 +120,7 @@ initAllMenus(document.querySelector("#mi-zona"));
|
|
|
119
120
|
|
|
120
121
|
### Tipos
|
|
121
122
|
|
|
122
|
-
El paquete incluye las declaraciones de los
|
|
123
|
+
El paquete incluye las declaraciones de los dieciséis módulos
|
|
123
124
|
(`src/behaviors/*.d.ts`), así que en TypeScript hay autocompletado y
|
|
124
125
|
comprobación de opciones y eventos sin escribir nada:
|
|
125
126
|
|
|
@@ -152,7 +153,7 @@ implica respaldo.
|
|
|
152
153
|
| Badge | `.m3-badge` | — |
|
|
153
154
|
| Bottom sheet | `.m3-bottom-sheet` | `behaviors/bottom-sheet.js` |
|
|
154
155
|
| Button | `.m3-button` | — |
|
|
155
|
-
| Button group | `.m3-button-group` |
|
|
156
|
+
| Button group | `.m3-button-group` | `behaviors/button-group.js` |
|
|
156
157
|
| Card | `.m3-card` | — |
|
|
157
158
|
| Carousel | `.m3-carousel` | `behaviors/carousel.js` |
|
|
158
159
|
| Checkbox | `.m3-checkbox` | nativo |
|
|
@@ -174,6 +175,7 @@ implica respaldo.
|
|
|
174
175
|
| Radio | `.m3-radio-group` | nativo |
|
|
175
176
|
| Search | `.m3-search` | `behaviors/search.js` |
|
|
176
177
|
| Segmented button | `.m3-segmented-button` | — |
|
|
178
|
+
| Shapes | `.m3-shape` | — |
|
|
177
179
|
| Side sheet | `.m3-side-sheet` | `behaviors/side-sheet.js` |
|
|
178
180
|
| Slider | `.m3-slider` | nativo |
|
|
179
181
|
| Snackbar | `.m3-snackbar-region` | — |
|
|
@@ -217,6 +219,24 @@ Tallas: `--sm` (XSmall 32), base (Small 40), `--md` (56), `--lg` (96) y
|
|
|
217
219
|
`.m3-icon .m3-icon--20` con `aria-hidden="true"` si es decorativo.
|
|
218
220
|
Alternancia: `aria-pressed="true"` pinta el seleccionado.
|
|
219
221
|
|
|
222
|
+
### Button group
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<div class="m3-button-group m3-button-group--connected"
|
|
226
|
+
data-m3-button-group data-select="single" data-animate-width>
|
|
227
|
+
<button class="m3-button m3-button--tonal" aria-pressed="true">Día</button>
|
|
228
|
+
<button class="m3-button m3-button--tonal" aria-pressed="false">Semana</button>
|
|
229
|
+
</div>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
El CSS del grupo funciona sin JS. `behaviors/button-group.js` añade
|
|
233
|
+
`data-select="single|multiple"` (mantiene `aria-pressed`), `data-animate-width`
|
|
234
|
+
(el botón pulsado crece un 15 %) y `data-overflow="auto"` (mueve los ítems que
|
|
235
|
+
no caben a un menú). **`data-animate-width` y `data-overflow` son excluyentes**:
|
|
236
|
+
el primero reparte el ancho con `flex`, así que no queda espacio que desbordar.
|
|
237
|
+
Límites: el ancho animado es una aproximación con `flex-grow` y el menú de
|
|
238
|
+
overflow no refleja el `aria-pressed` de un ítem oculto.
|
|
239
|
+
|
|
220
240
|
### Chip
|
|
221
241
|
|
|
222
242
|
```html
|
|
@@ -374,6 +394,40 @@ Límites y equivalencias:
|
|
|
374
394
|
- El **badge** no debe entrar en el nombre accesible: márcalo `aria-hidden` o
|
|
375
395
|
describe el estado en el `aria-label` del destino.
|
|
376
396
|
|
|
397
|
+
### Progress
|
|
398
|
+
|
|
399
|
+
Lineal con `<progress>` nativo; circular con un `<progress>` oculto (rol,
|
|
400
|
+
nombre y valor) más un anillo SVG decorativo. La variante `--wavy` es
|
|
401
|
+
Expressive:
|
|
402
|
+
|
|
403
|
+
- Lineal: no cambia el marcado. La pista se enmascara con una onda de 40 px
|
|
404
|
+
que se repite horizontalmente (20 px en indeterminado), 3 dp de amplitud y
|
|
405
|
+
4 dp de grosor sobre una banda de 10 dp; el relleno nativo y el segmento
|
|
406
|
+
indeterminado usan la misma máscara.
|
|
407
|
+
- Circular: exige un `<path>` con la silueta ondulada en el `d` y
|
|
408
|
+
`pathLength="100"` (el `d` no se puede definir en CSS con soporte fiable).
|
|
409
|
+
La caja pasa a 48 dp, con 1,6 dp de amplitud y nueve ondas. El trazado está
|
|
410
|
+
en `preview/progress.html`.
|
|
411
|
+
|
|
412
|
+
En wavy el stop se oculta, la banda queda fija en 10 px y el hueco de la pista
|
|
413
|
+
se conserva. El contrato circular sigue siendo `--m3-progress-value`
|
|
414
|
+
sincronizado con `value`. Sin `mask-image` el wavy lineal pierde la onda y
|
|
415
|
+
queda una barra plana de 10 px.
|
|
416
|
+
|
|
417
|
+
### Formas
|
|
418
|
+
|
|
419
|
+
```html
|
|
420
|
+
<span class="m3-shape m3-shape--burst" aria-hidden="true"></span>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
`m3-shape` + `--circle|square|diamond|triangle|hexagon|burst`: seis siluetas
|
|
424
|
+
muestreadas a 48 vértices. `--m3-shape-size` (48 por defecto) y
|
|
425
|
+
`--m3-shape-color` (`primary`). Cambiar la clase de forma en el mismo elemento
|
|
426
|
+
interpola el `clip-path` con `--md-sys-motion-spatial-default`; con
|
|
427
|
+
`prefers-reduced-motion` el cambio es instantáneo. Son formas decorativas: si
|
|
428
|
+
no comunican estado, márcalas `aria-hidden="true"`. No son los 35 trazados de
|
|
429
|
+
`androidx.graphics.shapes`, sino una utilidad CSS.
|
|
430
|
+
|
|
377
431
|
### Superficie
|
|
378
432
|
|
|
379
433
|
`m3-surface` + `--surface|lowest|low|container|high|highest`,
|
|
@@ -407,7 +461,7 @@ En línea: [design-system.ggalvez.cl](https://design-system.ggalvez.cl)
|
|
|
407
461
|
En el repositorio, con cualquier servidor estático:
|
|
408
462
|
|
|
409
463
|
- `preview.html`: índice con una entrada por componente.
|
|
410
|
-
- `gallery.html`: layout **list-detail** con los
|
|
464
|
+
- `gallery.html`: layout **list-detail** con los 38 componentes agrupados por
|
|
411
465
|
categoría, buscador, un único iframe reutilizado y deep links `#c-<id>`.
|
|
412
466
|
- `preview/<componente>.html`: la demo completa de ese componente.
|
|
413
467
|
|
|
@@ -463,9 +517,10 @@ del componente y no afecta al uso.
|
|
|
463
517
|
npm test
|
|
464
518
|
```
|
|
465
519
|
|
|
466
|
-
La suite tiene
|
|
520
|
+
La suite tiene 39 pruebas: comprueba los 12 roles fixed con sus valores, los
|
|
467
521
|
pares `on-*`, la igualdad entre el bloque oscuro y la copia de
|
|
468
522
|
`prefers-color-scheme`, los contenedores retonados, las 16 duraciones exactas,
|
|
469
523
|
las curvas spring generadas y su fallback, el espaciado en `px`, la tipografía
|
|
470
|
-
por rol e idioma, las variantes de icono
|
|
471
|
-
|
|
524
|
+
por rol e idioma, las variantes de icono, la selección y el overflow del button
|
|
525
|
+
group, la geometría del wavy lineal y circular, las seis formas y su orden de
|
|
526
|
+
vértices, y que ningún componente vuelva a fijar `GRAD` o duraciones en crudo.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gustavogalveza/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Implementación independiente y no oficial de M3 Expressive: tokens, CSS y HTML nativo, sin framework ni runtime obligatorio",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "gustavogalveza",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button group — selección, ancho animado y overflow.
|
|
3
|
+
*
|
|
4
|
+
* Atributos del DOM:
|
|
5
|
+
* `data-m3-button-group` en la raíz.
|
|
6
|
+
* `data-select="single" | "multiple"` para gestionar `aria-pressed`.
|
|
7
|
+
* `data-animate-width` para marcar el botón pulsado (`data-pressed`).
|
|
8
|
+
* `data-overflow="auto"` para mover los ítems que no caben a un menú.
|
|
9
|
+
*
|
|
10
|
+
* Evento: `m3-button-group-change` en la raíz, burbujea.
|
|
11
|
+
* detail = { value, index, pressed }
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface ButtonGroupChangeDetail {
|
|
15
|
+
value: string;
|
|
16
|
+
index: number;
|
|
17
|
+
pressed: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ButtonGroupOptions {
|
|
21
|
+
/** Activa el overflow si el markup lleva `data-overflow="auto"`. */
|
|
22
|
+
overflow?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ButtonGroupController {
|
|
26
|
+
readonly root: HTMLElement;
|
|
27
|
+
destroy(): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class ButtonGroup implements ButtonGroupController {
|
|
31
|
+
constructor(root: HTMLElement, options?: ButtonGroupOptions);
|
|
32
|
+
readonly root: HTMLElement;
|
|
33
|
+
destroy(): boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Calcula cuántos ítems caben dejando espacio para el botón de overflow.
|
|
38
|
+
*/
|
|
39
|
+
export function computeOverflow(
|
|
40
|
+
widths: number[],
|
|
41
|
+
gap: number,
|
|
42
|
+
available: number,
|
|
43
|
+
overflowWidth: number,
|
|
44
|
+
): { visibleCount: number; overflow: boolean };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Devuelve el conjunto de índices presionados tras activar uno.
|
|
48
|
+
*/
|
|
49
|
+
export function pressedAfterClick(
|
|
50
|
+
current: Set<number>,
|
|
51
|
+
index: number,
|
|
52
|
+
mode: "single" | "multiple",
|
|
53
|
+
): Set<number>;
|
|
54
|
+
|
|
55
|
+
export function initButtonGroup(
|
|
56
|
+
root: HTMLElement,
|
|
57
|
+
options?: ButtonGroupOptions,
|
|
58
|
+
): ButtonGroup;
|
|
59
|
+
|
|
60
|
+
export function initButtonGroups(scope?: Document | Element): ButtonGroup[];
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button group — selección, ancho animado y overflow (ESM, sin dependencias).
|
|
3
|
+
*
|
|
4
|
+
* El CSS dibuja el grupo y sus estados; este módulo aporta lo que el navegador
|
|
5
|
+
* no resuelve:
|
|
6
|
+
*
|
|
7
|
+
* - `data-select="single|multiple"`: mantiene `aria-pressed` en los botones.
|
|
8
|
+
* - `data-animate-width`: marca el botón pulsado para que el CSS lo expanda y
|
|
9
|
+
* comprima a sus vecinos.
|
|
10
|
+
* - `data-overflow="auto"`: mide el grupo, oculta los ítems que no caben y los
|
|
11
|
+
* mueve a un menú de desbordamiento.
|
|
12
|
+
*
|
|
13
|
+
* Contrato de markup:
|
|
14
|
+
*
|
|
15
|
+
* <div class="m3-button-group m3-button-group--connected"
|
|
16
|
+
* data-m3-button-group data-select="single"
|
|
17
|
+
* data-animate-width data-overflow="auto">
|
|
18
|
+
* <button class="m3-button m3-button--tonal" aria-pressed="true">Día</button>
|
|
19
|
+
* <button class="m3-button m3-button--tonal" aria-pressed="false">Semana</button>
|
|
20
|
+
* </div>
|
|
21
|
+
*
|
|
22
|
+
* Sin `data-m3-button-group` el CSS sigue funcionando; el behavior es opcional.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { initMenu } from "./menu.js";
|
|
26
|
+
|
|
27
|
+
const ROOT_SELECTOR = "[data-m3-button-group]";
|
|
28
|
+
const ITEM_SELECTOR = ":scope > .m3-button, :scope > .m3-icon-button";
|
|
29
|
+
const OVERFLOWED = "m3-button-group__item--overflowed";
|
|
30
|
+
const OVERFLOW_END = "m3-button-group__item--overflow-end";
|
|
31
|
+
const PRESSED = "is-pressing";
|
|
32
|
+
const ACTIVE = "m3-button-group--overflow-active";
|
|
33
|
+
const INSTANCES = new WeakMap();
|
|
34
|
+
|
|
35
|
+
let uid = 0;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Calcula cuántos ítems caben dejando espacio para el botón de overflow.
|
|
39
|
+
* @param {number[]} widths Anchos medidos de los ítems.
|
|
40
|
+
* @param {number} gap Separación entre ítems.
|
|
41
|
+
* @param {number} available Ancho disponible del grupo.
|
|
42
|
+
* @param {number} overflowWidth Ancho del botón de overflow.
|
|
43
|
+
* @returns {{visibleCount: number, overflow: boolean}}
|
|
44
|
+
*/
|
|
45
|
+
export function computeOverflow(widths, gap, available, overflowWidth) {
|
|
46
|
+
if (widths.length === 0) return { visibleCount: 0, overflow: false };
|
|
47
|
+
|
|
48
|
+
const total = widths.reduce(
|
|
49
|
+
(sum, width, index) => sum + width + (index === 0 ? 0 : gap),
|
|
50
|
+
0,
|
|
51
|
+
);
|
|
52
|
+
if (total <= available) {
|
|
53
|
+
return { visibleCount: widths.length, overflow: false };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const budget = available - overflowWidth - gap;
|
|
57
|
+
let used = 0;
|
|
58
|
+
let visibleCount = 0;
|
|
59
|
+
for (const width of widths) {
|
|
60
|
+
const next = used + (visibleCount === 0 ? 0 : gap) + width;
|
|
61
|
+
if (next > budget) break;
|
|
62
|
+
used = next;
|
|
63
|
+
visibleCount += 1;
|
|
64
|
+
}
|
|
65
|
+
return { visibleCount, overflow: true };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Devuelve el conjunto de índices presionados tras activar uno.
|
|
70
|
+
* @param {Set<number>} current
|
|
71
|
+
* @param {number} index
|
|
72
|
+
* @param {"single" | "multiple"} mode
|
|
73
|
+
* @returns {Set<number>}
|
|
74
|
+
*/
|
|
75
|
+
export function pressedAfterClick(current, index, mode) {
|
|
76
|
+
const next = new Set(current);
|
|
77
|
+
if (mode === "single") {
|
|
78
|
+
next.clear();
|
|
79
|
+
next.add(index);
|
|
80
|
+
return next;
|
|
81
|
+
}
|
|
82
|
+
if (next.has(index)) next.delete(index);
|
|
83
|
+
else next.add(index);
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function directItems(root) {
|
|
88
|
+
return [...root.querySelectorAll(ITEM_SELECTOR)];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function buttonLabel(button) {
|
|
92
|
+
return (
|
|
93
|
+
button.querySelector(".m3-button__label")?.textContent?.trim() ||
|
|
94
|
+
button.getAttribute("aria-label") ||
|
|
95
|
+
button.textContent.trim()
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isDisabled(button) {
|
|
100
|
+
return button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function cloneIcon(button) {
|
|
104
|
+
const icon = button.querySelector(".m3-icon");
|
|
105
|
+
if (!icon) return null;
|
|
106
|
+
const clone = icon.cloneNode(true);
|
|
107
|
+
clone.setAttribute("aria-hidden", "true");
|
|
108
|
+
return clone;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class SelectionController {
|
|
112
|
+
constructor(root, mode) {
|
|
113
|
+
this.root = root;
|
|
114
|
+
this.mode = mode;
|
|
115
|
+
this.buttons = null;
|
|
116
|
+
this.onClick = this.onClick.bind(this);
|
|
117
|
+
this.init();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
init() {
|
|
121
|
+
const buttons = directItems(this.root);
|
|
122
|
+
let hasPressed = false;
|
|
123
|
+
for (const button of buttons) {
|
|
124
|
+
const pressed = button.getAttribute("aria-pressed") === "true";
|
|
125
|
+
if (pressed && hasPressed && this.mode === "single") {
|
|
126
|
+
button.setAttribute("aria-pressed", "false");
|
|
127
|
+
} else if (pressed) {
|
|
128
|
+
hasPressed = true;
|
|
129
|
+
} else if (!button.hasAttribute("aria-pressed")) {
|
|
130
|
+
button.setAttribute("aria-pressed", "false");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (this.mode === "single" && !hasPressed && buttons.length > 0) {
|
|
134
|
+
buttons[0].setAttribute("aria-pressed", "true");
|
|
135
|
+
}
|
|
136
|
+
this.root.addEventListener("click", this.onClick);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setButtons(buttons) {
|
|
140
|
+
this.buttons = buttons;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onClick(event) {
|
|
144
|
+
const button = event.target.closest(".m3-button, .m3-icon-button");
|
|
145
|
+
if (!button || button.parentElement !== this.root || isDisabled(button)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const buttons = this.buttons ?? directItems(this.root);
|
|
149
|
+
const index = buttons.indexOf(button);
|
|
150
|
+
if (index === -1) return;
|
|
151
|
+
const current = new Set(
|
|
152
|
+
buttons.flatMap((item, itemIndex) =>
|
|
153
|
+
item.getAttribute("aria-pressed") === "true" ? [itemIndex] : [],
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
const next = pressedAfterClick(current, index, this.mode);
|
|
157
|
+
for (const [itemIndex, item] of buttons.entries()) {
|
|
158
|
+
item.setAttribute("aria-pressed", next.has(itemIndex) ? "true" : "false");
|
|
159
|
+
}
|
|
160
|
+
this.root.dispatchEvent(
|
|
161
|
+
new CustomEvent("m3-button-group-change", {
|
|
162
|
+
bubbles: true,
|
|
163
|
+
detail: {
|
|
164
|
+
value:
|
|
165
|
+
button.value ||
|
|
166
|
+
button.getAttribute("aria-label") ||
|
|
167
|
+
buttonLabel(button),
|
|
168
|
+
index,
|
|
169
|
+
pressed: next.has(index),
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
destroy() {
|
|
176
|
+
this.root.removeEventListener("click", this.onClick);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
class PressController {
|
|
182
|
+
constructor(root) {
|
|
183
|
+
this.root = root;
|
|
184
|
+
this.pressedButton = null;
|
|
185
|
+
this.onPointerDown = this.onPointerDown.bind(this);
|
|
186
|
+
this.onPointerUp = this.onPointerUp.bind(this);
|
|
187
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
188
|
+
this.onKeyUp = this.onKeyUp.bind(this);
|
|
189
|
+
this.init();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
init() {
|
|
193
|
+
this.root.addEventListener("pointerdown", this.onPointerDown);
|
|
194
|
+
this.root.addEventListener("pointerup", this.onPointerUp);
|
|
195
|
+
this.root.addEventListener("pointercancel", this.onPointerUp);
|
|
196
|
+
this.root.addEventListener("pointerleave", this.onPointerUp);
|
|
197
|
+
this.root.addEventListener("keydown", this.onKeyDown);
|
|
198
|
+
this.root.addEventListener("keyup", this.onKeyUp);
|
|
199
|
+
this.root.addEventListener("blur", this.onPointerUp, true);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
onPointerDown(event) {
|
|
203
|
+
if (event.button !== 0) return;
|
|
204
|
+
const button = event.target.closest(".m3-button, .m3-icon-button");
|
|
205
|
+
if (!button || button.parentElement !== this.root || isDisabled(button)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.setPressed(button);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
onKeyDown(event) {
|
|
212
|
+
if (event.key !== " " && event.key !== "Enter") return;
|
|
213
|
+
const button = event.target.closest(".m3-button, .m3-icon-button");
|
|
214
|
+
if (!button || button.parentElement !== this.root || isDisabled(button)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
this.setPressed(button);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setPressed(button) {
|
|
221
|
+
this.clearPressed();
|
|
222
|
+
this.pressedButton = button;
|
|
223
|
+
button.dataset.pressed = "true";
|
|
224
|
+
this.root.classList.add(PRESSED);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
onPointerUp() {
|
|
228
|
+
this.clearPressed();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
onKeyUp(event) {
|
|
232
|
+
if (event.key === " " || event.key === "Enter") this.clearPressed();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
clearPressed() {
|
|
236
|
+
if (!this.pressedButton) return;
|
|
237
|
+
delete this.pressedButton.dataset.pressed;
|
|
238
|
+
this.pressedButton = null;
|
|
239
|
+
this.root.classList.remove(PRESSED);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
destroy() {
|
|
243
|
+
this.root.removeEventListener("pointerdown", this.onPointerDown);
|
|
244
|
+
this.root.removeEventListener("pointerup", this.onPointerUp);
|
|
245
|
+
this.root.removeEventListener("pointercancel", this.onPointerUp);
|
|
246
|
+
this.root.removeEventListener("pointerleave", this.onPointerUp);
|
|
247
|
+
this.root.removeEventListener("keydown", this.onKeyDown);
|
|
248
|
+
this.root.removeEventListener("keyup", this.onKeyUp);
|
|
249
|
+
this.root.removeEventListener("blur", this.onPointerUp, true);
|
|
250
|
+
this.clearPressed();
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
class OverflowController {
|
|
256
|
+
constructor(root) {
|
|
257
|
+
this.root = root;
|
|
258
|
+
this.buttons = directItems(root);
|
|
259
|
+
this.visibleCount = -1;
|
|
260
|
+
this.frame = null;
|
|
261
|
+
this.menuController = null;
|
|
262
|
+
this.scheduleMeasure = this.scheduleMeasure.bind(this);
|
|
263
|
+
this.init();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
init() {
|
|
267
|
+
this.overflowRoot = document.createElement("div");
|
|
268
|
+
this.overflowRoot.className = "m3-button-group__overflow m3-menu-anchor";
|
|
269
|
+
this.overflowRoot.hidden = true;
|
|
270
|
+
|
|
271
|
+
const trigger = document.createElement("button");
|
|
272
|
+
trigger.type = "button";
|
|
273
|
+
trigger.className =
|
|
274
|
+
"m3-icon-button m3-icon-button--tonal m3-menu__trigger";
|
|
275
|
+
trigger.setAttribute("aria-label", "Más acciones");
|
|
276
|
+
trigger.setAttribute("aria-haspopup", "menu");
|
|
277
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
278
|
+
const menuId = `m3-button-group-menu-${++uid}`;
|
|
279
|
+
trigger.setAttribute("aria-controls", menuId);
|
|
280
|
+
|
|
281
|
+
const icon = document.createElement("span");
|
|
282
|
+
icon.className = "m3-icon";
|
|
283
|
+
icon.setAttribute("aria-hidden", "true");
|
|
284
|
+
icon.textContent = "more_horiz";
|
|
285
|
+
trigger.append(icon);
|
|
286
|
+
|
|
287
|
+
this.menu = document.createElement("div");
|
|
288
|
+
this.menu.className = "m3-menu";
|
|
289
|
+
this.menu.id = menuId;
|
|
290
|
+
this.menu.setAttribute("role", "menu");
|
|
291
|
+
this.menu.setAttribute(
|
|
292
|
+
"aria-label",
|
|
293
|
+
this.root.getAttribute("aria-label") || "Más acciones",
|
|
294
|
+
);
|
|
295
|
+
this.menu.setAttribute("popover", "manual");
|
|
296
|
+
|
|
297
|
+
this.overflowRoot.append(trigger, this.menu);
|
|
298
|
+
this.root.append(this.overflowRoot);
|
|
299
|
+
this.root.classList.add(ACTIVE);
|
|
300
|
+
this.menuController = initMenu(trigger);
|
|
301
|
+
|
|
302
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
303
|
+
this.resizeObserver = new ResizeObserver(this.scheduleMeasure);
|
|
304
|
+
this.resizeObserver.observe(this.root);
|
|
305
|
+
}
|
|
306
|
+
window.addEventListener("resize", this.scheduleMeasure);
|
|
307
|
+
this.scheduleMeasure();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
scheduleMeasure() {
|
|
311
|
+
if (this.frame !== null) return;
|
|
312
|
+
this.frame = requestAnimationFrame(() => {
|
|
313
|
+
this.frame = null;
|
|
314
|
+
this.measure();
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
measure() {
|
|
319
|
+
if (!this.root.isConnected || this.root.clientWidth === 0) return;
|
|
320
|
+
|
|
321
|
+
for (const button of this.buttons) {
|
|
322
|
+
button.classList.remove(OVERFLOWED);
|
|
323
|
+
}
|
|
324
|
+
this.overflowRoot.hidden = false;
|
|
325
|
+
this.overflowRoot.style.visibility = "hidden";
|
|
326
|
+
|
|
327
|
+
const styles = getComputedStyle(this.root);
|
|
328
|
+
const gap = Number.parseFloat(styles.columnGap) || 0;
|
|
329
|
+
const widths = this.buttons.map(
|
|
330
|
+
(button) => button.getBoundingClientRect().width,
|
|
331
|
+
);
|
|
332
|
+
const overflowWidth = this.overflowRoot.getBoundingClientRect().width;
|
|
333
|
+
const result = computeOverflow(
|
|
334
|
+
widths,
|
|
335
|
+
gap,
|
|
336
|
+
this.root.clientWidth,
|
|
337
|
+
overflowWidth,
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
this.overflowRoot.style.visibility = "";
|
|
341
|
+
this.overflowRoot.hidden = !result.overflow;
|
|
342
|
+
for (const [index, button] of this.buttons.entries()) {
|
|
343
|
+
button.classList.toggle(
|
|
344
|
+
OVERFLOWED,
|
|
345
|
+
result.overflow && index >= result.visibleCount,
|
|
346
|
+
);
|
|
347
|
+
button.classList.remove(OVERFLOW_END);
|
|
348
|
+
}
|
|
349
|
+
this.buttons[result.visibleCount - 1]?.classList.add(OVERFLOW_END);
|
|
350
|
+
|
|
351
|
+
if (result.visibleCount !== this.visibleCount) {
|
|
352
|
+
const wasOpen = this.menuController?.isOpen;
|
|
353
|
+
this.menuController?.close({ returnFocus: result.overflow });
|
|
354
|
+
this.visibleCount = result.visibleCount;
|
|
355
|
+
this.renderMenu();
|
|
356
|
+
if (wasOpen && !result.overflow) {
|
|
357
|
+
this.buttons[result.visibleCount - 1]?.focus();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (!result.overflow) this.menuController?.close({ returnFocus: false });
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
renderMenu() {
|
|
364
|
+
this.menu.replaceChildren();
|
|
365
|
+
for (const button of this.buttons.slice(this.visibleCount)) {
|
|
366
|
+
const item = document.createElement("button");
|
|
367
|
+
item.type = "button";
|
|
368
|
+
item.className = "m3-menu__item";
|
|
369
|
+
item.setAttribute("role", "menuitem");
|
|
370
|
+
const icon = cloneIcon(button);
|
|
371
|
+
if (icon) item.append(icon);
|
|
372
|
+
const label = document.createElement("span");
|
|
373
|
+
label.className = "m3-button__label";
|
|
374
|
+
label.textContent = buttonLabel(button);
|
|
375
|
+
item.append(label);
|
|
376
|
+
const disabled = isDisabled(button);
|
|
377
|
+
item.disabled = button.disabled;
|
|
378
|
+
if (button.getAttribute("aria-disabled") === "true") {
|
|
379
|
+
item.setAttribute("aria-disabled", "true");
|
|
380
|
+
}
|
|
381
|
+
item.addEventListener("click", () => {
|
|
382
|
+
if (disabled) return;
|
|
383
|
+
button.click();
|
|
384
|
+
this.menuController?.close();
|
|
385
|
+
});
|
|
386
|
+
this.menu.append(item);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
destroy() {
|
|
391
|
+
window.removeEventListener("resize", this.scheduleMeasure);
|
|
392
|
+
this.resizeObserver?.disconnect();
|
|
393
|
+
if (this.frame !== null) cancelAnimationFrame(this.frame);
|
|
394
|
+
for (const button of this.buttons) {
|
|
395
|
+
button.classList.remove(OVERFLOWED, OVERFLOW_END);
|
|
396
|
+
}
|
|
397
|
+
this.menuController?.destroy();
|
|
398
|
+
this.overflowRoot?.remove();
|
|
399
|
+
this.root.classList.remove(ACTIVE);
|
|
400
|
+
this.visibleCount = -1;
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export class ButtonGroup {
|
|
406
|
+
/**
|
|
407
|
+
* @param {HTMLElement} root Grupo con `data-m3-button-group`.
|
|
408
|
+
* @param {object} [options]
|
|
409
|
+
* @param {boolean} [options.overflow=true] Activa el overflow si el markup
|
|
410
|
+
* lo pide con `data-overflow="auto"`.
|
|
411
|
+
*/
|
|
412
|
+
constructor(root, options = {}) {
|
|
413
|
+
const existing = INSTANCES.get(root);
|
|
414
|
+
if (existing) return existing;
|
|
415
|
+
if (!(root instanceof HTMLElement)) {
|
|
416
|
+
throw new TypeError("ButtonGroup necesita un elemento raíz");
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
this.root = root;
|
|
420
|
+
const mode =
|
|
421
|
+
root.dataset.select === "single"
|
|
422
|
+
? "single"
|
|
423
|
+
: root.dataset.select === "multiple"
|
|
424
|
+
? "multiple"
|
|
425
|
+
: null;
|
|
426
|
+
this.selection = mode ? new SelectionController(root, mode) : null;
|
|
427
|
+
this.press = root.hasAttribute("data-animate-width")
|
|
428
|
+
? new PressController(root)
|
|
429
|
+
: null;
|
|
430
|
+
this.overflow =
|
|
431
|
+
options.overflow !== false && root.getAttribute("data-overflow") === "auto"
|
|
432
|
+
? new OverflowController(root)
|
|
433
|
+
: null;
|
|
434
|
+
this.selection?.setButtons(this.overflow?.buttons ?? null);
|
|
435
|
+
INSTANCES.set(root, this);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
destroy() {
|
|
439
|
+
this.press?.destroy();
|
|
440
|
+
this.overflow?.destroy();
|
|
441
|
+
this.selection?.destroy();
|
|
442
|
+
INSTANCES.delete(this.root);
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* @param {HTMLElement} root
|
|
449
|
+
* @param {object} [options]
|
|
450
|
+
* @returns {ButtonGroup}
|
|
451
|
+
*/
|
|
452
|
+
export function initButtonGroup(root, options = {}) {
|
|
453
|
+
const existing = INSTANCES.get(root);
|
|
454
|
+
if (existing) return existing;
|
|
455
|
+
const instance = new ButtonGroup(root, options);
|
|
456
|
+
INSTANCES.set(root, instance);
|
|
457
|
+
return instance;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @param {Document | Element} [scope]
|
|
462
|
+
* @returns {ButtonGroup[]}
|
|
463
|
+
*/
|
|
464
|
+
export function initButtonGroups(scope = document) {
|
|
465
|
+
const roots = [];
|
|
466
|
+
if (scope instanceof Element && scope.matches(ROOT_SELECTOR)) {
|
|
467
|
+
roots.push(scope);
|
|
468
|
+
}
|
|
469
|
+
roots.push(...scope.querySelectorAll(ROOT_SELECTOR));
|
|
470
|
+
return roots
|
|
471
|
+
.map((root) => {
|
|
472
|
+
try {
|
|
473
|
+
return initButtonGroup(root);
|
|
474
|
+
} catch (error) {
|
|
475
|
+
console.error("[button-group]", error);
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
.filter(Boolean);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (typeof document !== "undefined" && !globalThis.__M3_MANUAL_INIT__) {
|
|
483
|
+
const boot = () => initButtonGroups();
|
|
484
|
+
if (document.readyState === "loading") {
|
|
485
|
+
document.addEventListener("DOMContentLoaded", boot, { once: true });
|
|
486
|
+
} else {
|
|
487
|
+
boot();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* Button group — M3 Expressive.
|
|
2
|
-
* Agrupa .m3-button existentes: no reimplementa el botón
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Agrupa .m3-button existentes: no reimplementa el botón. El CSS aporta
|
|
3
|
+
* separación, radios de extremo, el estado seleccionado de --connected y las
|
|
4
|
+
* transiciones de ancho; el behavior opcional `button-group.js` gestiona
|
|
5
|
+
* `aria-pressed`, el botón pulsado y el menú de overflow.
|
|
5
6
|
*
|
|
6
7
|
* El kit separa los botones del grupo estándar con un hueco que escala con la
|
|
7
8
|
* talla (XSmall 18, Small 12, Medium/Large/XLarge 8) y une los del conectado
|
|
@@ -144,11 +145,77 @@
|
|
|
144
145
|
--_m3-bg-radius-pressed-start: var(--m3-button-group-pressed-radius);
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
.m3-button-group--connected > .m3-button-group__item--line-end
|
|
148
|
+
.m3-button-group--connected > .m3-button-group__item--line-end,
|
|
149
|
+
.m3-button-group--connected > .m3-button-group__item--overflow-end {
|
|
148
150
|
--_m3-bg-radius-end: var(--_m3-bg-outer-radius);
|
|
149
151
|
--_m3-bg-radius-pressed-end: var(--m3-button-group-pressed-radius);
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
/* Checked shape de Compose: el segmento seleccionado pasa a CornerFull en sus
|
|
155
|
+
* cuatro esquinas, incluso en medio del grupo. Va después de line-start/end
|
|
156
|
+
* para ganar el radio exterior/interior. */
|
|
157
|
+
.m3-button-group--connected > .m3-button[aria-pressed="true"] {
|
|
158
|
+
--_m3-bg-radius-start: var(--_m3-bg-outer-radius);
|
|
159
|
+
--_m3-bg-radius-end: var(--_m3-bg-outer-radius);
|
|
160
|
+
--_m3-bg-radius-pressed-start: var(--_m3-bg-outer-radius);
|
|
161
|
+
--_m3-bg-radius-pressed-end: var(--_m3-bg-outer-radius);
|
|
162
|
+
z-index: 1;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* --- Ancho animado -------------------------------------------------------
|
|
166
|
+
* Aproximación CSS de `ButtonGroupScope.animateWidth`: el botón pulsado crece
|
|
167
|
+
* un 15 % y sus vecinos inmediatos comprimen la mitad cada uno. El grupo debe
|
|
168
|
+
* ocupar el ancho disponible; el behavior solo marca `data-pressed` y la clase
|
|
169
|
+
* `is-pressing`. */
|
|
170
|
+
.m3-button-group[data-animate-width] {
|
|
171
|
+
flex-wrap: nowrap;
|
|
172
|
+
inline-size: 100%;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.m3-button-group[data-animate-width] > .m3-button,
|
|
176
|
+
.m3-button-group[data-animate-width] > .m3-icon-button {
|
|
177
|
+
flex: 1 1 0;
|
|
178
|
+
transition: flex-grow var(--md-sys-motion-spatial-fast);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.m3-button-group[data-animate-width].is-pressing
|
|
182
|
+
> [data-pressed="true"] {
|
|
183
|
+
flex-grow: 1.15;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.m3-button-group[data-animate-width].is-pressing
|
|
187
|
+
> [data-pressed="true"] + .m3-button,
|
|
188
|
+
.m3-button-group[data-animate-width].is-pressing
|
|
189
|
+
> [data-pressed="true"] + .m3-icon-button,
|
|
190
|
+
.m3-button-group[data-animate-width].is-pressing
|
|
191
|
+
> .m3-button:has(+ [data-pressed="true"]),
|
|
192
|
+
.m3-button-group[data-animate-width].is-pressing
|
|
193
|
+
> .m3-icon-button:has(+ [data-pressed="true"]) {
|
|
194
|
+
flex-grow: 0.925;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* --- Overflow ------------------------------------------------------------
|
|
198
|
+
* El behavior oculta los ítems que no caben y los replica en un menú. El
|
|
199
|
+
* contenedor opt-in no envuelve: la medición y el menú son su contrato. */
|
|
200
|
+
.m3-button-group--overflow-active {
|
|
201
|
+
flex-wrap: nowrap;
|
|
202
|
+
inline-size: 100%;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.m3-button-group__item--overflowed {
|
|
206
|
+
display: none !important;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.m3-button-group__overflow {
|
|
210
|
+
display: flex;
|
|
211
|
+
flex: 0 0 auto;
|
|
212
|
+
align-items: center;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.m3-button-group__overflow[hidden] {
|
|
216
|
+
display: none;
|
|
217
|
+
}
|
|
218
|
+
|
|
152
219
|
/* En filled/tonal no se tiñe ningún borde: la separación la da el hueco de
|
|
153
220
|
* 2 dp. Un borde claro sobre `primary-container` no alcanza 3:1, y un borde
|
|
154
221
|
* oscuro sobre `secondary-container` tampoco. */
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
* CircularProgressIndicator TrackActiveSpace = 4dp (hueco a cada lado del arco)
|
|
15
15
|
* ProgressIndicator ActiveShape/StopShape/TrackShape = CornerFull
|
|
16
16
|
*
|
|
17
|
+
* Wavy (Expressive): la variante lineal se dibuja sin cambiar el marcado con
|
|
18
|
+
* una banda de 10dp enmascarada por una onda de 40dp que se repite
|
|
19
|
+
* horizontalmente (20dp en indeterminado; amplitud 3dp y grosor 4dp). La
|
|
20
|
+
* circular exige un `d` ondulado en el SVG —el `d` no se
|
|
21
|
+
* puede poner en CSS con soporte fiable—, así que solo se activa con el
|
|
22
|
+
* marcado de `<path>` que documenta la preview; usa 48dp de caja (Size del
|
|
23
|
+
* kit wavy), 1.6dp de amplitud y 9 ondas (longitud ≈ 14,2dp).
|
|
24
|
+
*
|
|
17
25
|
* No implementado (decisiones):
|
|
18
|
-
* - Wavy: M3 Expressive publica ActiveWaveAmplitude 3dp y
|
|
19
|
-
* ActiveWaveWavelength 40dp/20dp, pero dibujar la onda exige un SVG con
|
|
20
|
-
* path medido o un gradiente repetido; sin tocar el marcado no hay forma
|
|
21
|
-
* fiable. Se deja la forma plana, que es la variante por defecto.
|
|
22
26
|
* - Buffer: <progress> en web no expone un rol de buffer (solo valor
|
|
23
27
|
* determinado o indeterminado). La pista secundaria hace de resto.
|
|
24
28
|
* - Hueco de 4dp entre el indicador activo y el resto de la pista en el
|
|
@@ -227,6 +231,52 @@
|
|
|
227
231
|
}
|
|
228
232
|
}
|
|
229
233
|
|
|
234
|
+
|
|
235
|
+
/* --- Wavy lineal ---------------------------------------------------------
|
|
236
|
+
* Aproximación CSS de LinearWavyProgressIndicator sin cambiar el marcado. La
|
|
237
|
+
* pista se enmascara con una onda de 40dp (20dp en indeterminado), amplitud
|
|
238
|
+
* 3dp y grosor 4dp sobre una banda de 10dp; el relleno nativo y el segmento
|
|
239
|
+
* indeterminado se recortan con la misma máscara. Sin `mask-image` se pierde
|
|
240
|
+
* la onda y queda una barra plana de 10dp. */
|
|
241
|
+
.m3-progress--linear.m3-progress--wavy {
|
|
242
|
+
/* La banda wavy mide 10dp fijos; el grosor de 4dp ya lo dibuja la máscara. */
|
|
243
|
+
--m3-progress-thickness: 10px;
|
|
244
|
+
--m3-progress-wave-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2010%22%20preserveAspectRatio%3D%22none%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M0.00%203.00%20L0.50%202.76%20L1.00%202.53%20L1.50%202.30%20L2.00%202.07%20L2.50%201.85%20L3.00%201.64%20L3.50%201.43%20L4.00%201.24%20L4.50%201.05%20L5.00%200.88%20L5.50%200.72%20L6.00%200.57%20L6.50%200.44%20L7.00%200.33%20L7.50%200.23%20L8.00%200.15%20L8.50%200.08%20L9.00%200.04%20L9.50%200.01%20L10.00%200.00%20L10.50%200.01%20L11.00%200.04%20L11.50%200.08%20L12.00%200.15%20L12.50%200.23%20L13.00%200.33%20L13.50%200.44%20L14.00%200.57%20L14.50%200.72%20L15.00%200.88%20L15.50%201.05%20L16.00%201.24%20L16.50%201.43%20L17.00%201.64%20L17.50%201.85%20L18.00%202.07%20L18.50%202.30%20L19.00%202.53%20L19.50%202.76%20L20.00%203.00%20L20.50%203.24%20L21.00%203.47%20L21.50%203.70%20L22.00%203.93%20L22.50%204.15%20L23.00%204.36%20L23.50%204.57%20L24.00%204.76%20L24.50%204.95%20L25.00%205.12%20L25.50%205.28%20L26.00%205.43%20L26.50%205.56%20L27.00%205.67%20L27.50%205.77%20L28.00%205.85%20L28.50%205.92%20L29.00%205.96%20L29.50%205.99%20L30.00%206.00%20L30.50%205.99%20L31.00%205.96%20L31.50%205.92%20L32.00%205.85%20L32.50%205.77%20L33.00%205.67%20L33.50%205.56%20L34.00%205.43%20L34.50%205.28%20L35.00%205.12%20L35.50%204.95%20L36.00%204.76%20L36.50%204.57%20L37.00%204.36%20L37.50%204.15%20L38.00%203.93%20L38.50%203.70%20L39.00%203.47%20L39.50%203.24%20L40.00%203.00%20L40.00%207.00%20L40.00%207.00%20L39.50%207.24%20L39.00%207.47%20L38.50%207.70%20L38.00%207.93%20L37.50%208.15%20L37.00%208.36%20L36.50%208.57%20L36.00%208.76%20L35.50%208.95%20L35.00%209.12%20L34.50%209.28%20L34.00%209.43%20L33.50%209.56%20L33.00%209.67%20L32.50%209.77%20L32.00%209.85%20L31.50%209.92%20L31.00%209.96%20L30.50%209.99%20L30.00%2010.00%20L29.50%209.99%20L29.00%209.96%20L28.50%209.92%20L28.00%209.85%20L27.50%209.77%20L27.00%209.67%20L26.50%209.56%20L26.00%209.43%20L25.50%209.28%20L25.00%209.12%20L24.50%208.95%20L24.00%208.76%20L23.50%208.57%20L23.00%208.36%20L22.50%208.15%20L22.00%207.93%20L21.50%207.70%20L21.00%207.47%20L20.50%207.24%20L20.00%207.00%20L19.50%206.76%20L19.00%206.53%20L18.50%206.30%20L18.00%206.07%20L17.50%205.85%20L17.00%205.64%20L16.50%205.43%20L16.00%205.24%20L15.50%205.05%20L15.00%204.88%20L14.50%204.72%20L14.00%204.57%20L13.50%204.44%20L13.00%204.33%20L12.50%204.23%20L12.00%204.15%20L11.50%204.08%20L11.00%204.04%20L10.50%204.01%20L10.00%204.00%20L9.50%204.01%20L9.00%204.04%20L8.50%204.08%20L8.00%204.15%20L7.50%204.23%20L7.00%204.33%20L6.50%204.44%20L6.00%204.57%20L5.50%204.72%20L5.00%204.88%20L4.50%205.05%20L4.00%205.24%20L3.50%205.43%20L3.00%205.64%20L2.50%205.85%20L2.00%206.07%20L1.50%206.30%20L1.00%206.53%20L0.50%206.76%20L0.00%207.00%20Z%22%2F%3E%3C%2Fsvg%3E");
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.m3-progress--wavy .m3-progress__track {
|
|
248
|
+
block-size: 10px;
|
|
249
|
+
border-radius: 0;
|
|
250
|
+
-webkit-mask-image: var(--m3-progress-wave-mask);
|
|
251
|
+
mask-image: var(--m3-progress-wave-mask);
|
|
252
|
+
-webkit-mask-size: 40px 10px;
|
|
253
|
+
mask-size: 40px 10px;
|
|
254
|
+
-webkit-mask-repeat: repeat-x;
|
|
255
|
+
mask-repeat: repeat-x;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.m3-progress--wavy .m3-progress__track:has(> progress:indeterminate) {
|
|
259
|
+
-webkit-mask-size: 20px 10px;
|
|
260
|
+
mask-size: 20px 10px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.m3-progress--wavy .m3-progress__bar {
|
|
264
|
+
block-size: 10px;
|
|
265
|
+
border-radius: 0;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.m3-progress--wavy .m3-progress__stop {
|
|
269
|
+
display: none;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* --- Wavy circular --------------------------------------------------------
|
|
273
|
+
* El SVG de esta variante usa `<path>` con la silueta ondulada en el `d` y
|
|
274
|
+
* `pathLength="100"`: las reglas del anillo (dash, hueco, giro) se reutilizan
|
|
275
|
+
* sin cambios. El resto del contrato es idéntico al circular plano. */
|
|
276
|
+
.m3-progress--circular.m3-progress--wavy {
|
|
277
|
+
--m3-progress-size: 48px;
|
|
278
|
+
}
|
|
279
|
+
|
|
230
280
|
/* --- Circular ------------------------------------------------------------- */
|
|
231
281
|
|
|
232
282
|
.m3-progress--circular {
|
package/src/index.css
CHANGED
package/src/shapes.css
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* MaterialShapes — subconjunto curado.
|
|
2
|
+
*
|
|
3
|
+
* `androidx.graphics.shapes` publica 35 trazados; este archivo no los copia.
|
|
4
|
+
* Publica seis formas geométricas de 48 vértices para que `clip-path`
|
|
5
|
+
* interpole entre ellas con la transición de `--md-sys-motion-spatial-default`.
|
|
6
|
+
* Son una utilidad CSS para formas decorativas, no una réplica de los trazados
|
|
7
|
+
* originales. El tamaño se controla con `--m3-shape-size` y el color con
|
|
8
|
+
* `--m3-shape-color`.
|
|
9
|
+
*
|
|
10
|
+
* Accesibilidad: si la forma es decorativa, márcala `aria-hidden="true"` y no
|
|
11
|
+
* le pongas texto alternativo; si comunica estado, el texto va fuera.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
.m3-shape {
|
|
15
|
+
--m3-shape-size: 48px;
|
|
16
|
+
--m3-shape-color: var(--md-sys-color-primary);
|
|
17
|
+
--m3-shape-polygon: none;
|
|
18
|
+
display: inline-grid;
|
|
19
|
+
flex: none;
|
|
20
|
+
inline-size: var(--m3-shape-size);
|
|
21
|
+
block-size: var(--m3-shape-size);
|
|
22
|
+
background: var(--m3-shape-color);
|
|
23
|
+
clip-path: var(--m3-shape-polygon);
|
|
24
|
+
transition: clip-path var(--md-sys-motion-spatial-default);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Para un morph explícito, cambia la clase de forma en el mismo elemento: el
|
|
28
|
+
* número de vértices coincide y el navegador interpola el `clip-path`. */
|
|
29
|
+
|
|
30
|
+
.m3-shape--circle {
|
|
31
|
+
--m3-shape-polygon: polygon(100.00% 50.00%, 99.57% 56.53%, 98.30% 62.94%, 96.19% 69.13%, 93.30% 75.00%, 89.67% 80.44%, 85.36% 85.36%, 80.44% 89.67%, 75.00% 93.30%, 69.13% 96.19%, 62.94% 98.30%, 56.53% 99.57%, 50.00% 100.00%, 43.47% 99.57%, 37.06% 98.30%, 30.87% 96.19%, 25.00% 93.30%, 19.56% 89.67%, 14.64% 85.36%, 10.33% 80.44%, 6.70% 75.00%, 3.81% 69.13%, 1.70% 62.94%, 0.43% 56.53%, 0.00% 50.00%, 0.43% 43.47%, 1.70% 37.06%, 3.81% 30.87%, 6.70% 25.00%, 10.33% 19.56%, 14.64% 14.64%, 19.56% 10.33%, 25.00% 6.70%, 30.87% 3.81%, 37.06% 1.70%, 43.47% 0.43%, 50.00% 0.00%, 56.53% 0.43%, 62.94% 1.70%, 69.13% 3.81%, 75.00% 6.70%, 80.44% 10.33%, 85.36% 14.64%, 89.67% 19.56%, 93.30% 25.00%, 96.19% 30.87%, 98.30% 37.06%, 99.57% 43.47%);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.m3-shape--square {
|
|
35
|
+
--m3-shape-polygon: polygon(96.00% 50.00%, 96.00% 57.67%, 96.00% 65.33%, 96.00% 73.00%, 96.00% 80.67%, 96.00% 88.33%, 96.00% 96.00%, 88.33% 96.00%, 80.67% 96.00%, 73.00% 96.00%, 65.33% 96.00%, 57.67% 96.00%, 50.00% 96.00%, 42.33% 96.00%, 34.67% 96.00%, 27.00% 96.00%, 19.33% 96.00%, 11.67% 96.00%, 4.00% 96.00%, 4.00% 88.33%, 4.00% 80.67%, 4.00% 73.00%, 4.00% 65.33%, 4.00% 57.67%, 4.00% 50.00%, 4.00% 42.33%, 4.00% 34.67%, 4.00% 27.00%, 4.00% 19.33%, 4.00% 11.67%, 4.00% 4.00%, 11.67% 4.00%, 19.33% 4.00%, 27.00% 4.00%, 34.67% 4.00%, 42.33% 4.00%, 50.00% 4.00%, 57.67% 4.00%, 65.33% 4.00%, 73.00% 4.00%, 80.67% 4.00%, 88.33% 4.00%, 96.00% 4.00%, 96.00% 11.67%, 96.00% 19.33%, 96.00% 27.00%, 96.00% 34.67%, 96.00% 42.33%);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.m3-shape--diamond {
|
|
39
|
+
--m3-shape-polygon: polygon(98.00% 50.00%, 94.00% 54.00%, 90.00% 58.00%, 86.00% 62.00%, 82.00% 66.00%, 78.00% 70.00%, 74.00% 74.00%, 70.00% 78.00%, 66.00% 82.00%, 62.00% 86.00%, 58.00% 90.00%, 54.00% 94.00%, 50.00% 98.00%, 46.00% 94.00%, 42.00% 90.00%, 38.00% 86.00%, 34.00% 82.00%, 30.00% 78.00%, 26.00% 74.00%, 22.00% 70.00%, 18.00% 66.00%, 14.00% 62.00%, 10.00% 58.00%, 6.00% 54.00%, 2.00% 50.00%, 6.00% 46.00%, 10.00% 42.00%, 14.00% 38.00%, 18.00% 34.00%, 22.00% 30.00%, 26.00% 26.00%, 30.00% 22.00%, 34.00% 18.00%, 38.00% 14.00%, 42.00% 10.00%, 46.00% 6.00%, 50.00% 2.00%, 54.00% 6.00%, 58.00% 10.00%, 62.00% 14.00%, 66.00% 18.00%, 70.00% 22.00%, 74.00% 26.00%, 78.00% 30.00%, 82.00% 34.00%, 86.00% 38.00%, 90.00% 42.00%, 94.00% 46.00%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.m3-shape--triangle {
|
|
43
|
+
--m3-shape-polygon: polygon(74.00% 48.00%, 77.00% 53.75%, 80.00% 59.50%, 83.00% 65.25%, 86.00% 71.00%, 89.00% 76.75%, 92.00% 82.50%, 95.00% 88.25%, 98.00% 94.00%, 92.00% 94.00%, 86.00% 94.00%, 80.00% 94.00%, 74.00% 94.00%, 68.00% 94.00%, 62.00% 94.00%, 56.00% 94.00%, 50.00% 94.00%, 44.00% 94.00%, 38.00% 94.00%, 32.00% 94.00%, 26.00% 94.00%, 20.00% 94.00%, 14.00% 94.00%, 8.00% 94.00%, 2.00% 94.00%, 5.00% 88.25%, 8.00% 82.50%, 11.00% 76.75%, 14.00% 71.00%, 17.00% 65.25%, 20.00% 59.50%, 23.00% 53.75%, 26.00% 48.00%, 29.00% 42.25%, 32.00% 36.50%, 35.00% 30.75%, 38.00% 25.00%, 41.00% 19.25%, 44.00% 13.50%, 47.00% 7.75%, 50.00% 2.00%, 53.00% 7.75%, 56.00% 13.50%, 59.00% 19.25%, 62.00% 25.00%, 65.00% 30.75%, 68.00% 36.50%, 71.00% 42.25%);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.m3-shape--hexagon {
|
|
47
|
+
--m3-shape-polygon: polygon(98.00% 50.00%, 98.00% 56.25%, 98.00% 62.50%, 98.00% 68.75%, 98.00% 75.00%, 92.00% 78.12%, 86.00% 81.25%, 80.00% 84.38%, 74.00% 87.50%, 68.00% 90.62%, 62.00% 93.75%, 56.00% 96.88%, 50.00% 100.00%, 44.00% 96.88%, 38.00% 93.75%, 32.00% 90.62%, 26.00% 87.50%, 20.00% 84.38%, 14.00% 81.25%, 8.00% 78.12%, 2.00% 75.00%, 2.00% 68.75%, 2.00% 62.50%, 2.00% 56.25%, 2.00% 50.00%, 2.00% 43.75%, 2.00% 37.50%, 2.00% 31.25%, 2.00% 25.00%, 8.00% 21.88%, 14.00% 18.75%, 20.00% 15.62%, 26.00% 12.50%, 32.00% 9.38%, 38.00% 6.25%, 44.00% 3.12%, 50.00% 0.00%, 56.00% 3.12%, 62.00% 6.25%, 68.00% 9.38%, 74.00% 12.50%, 80.00% 15.62%, 86.00% 18.75%, 92.00% 21.88%, 98.00% 25.00%, 98.00% 31.25%, 98.00% 37.50%, 98.00% 43.75%);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.m3-shape--burst {
|
|
51
|
+
--m3-shape-polygon: polygon(100.00% 50.00%, 99.57% 56.53%, 81.88% 58.54%, 80.49% 62.63%, 93.30% 75.00%, 89.67% 80.44%, 73.33% 73.33%, 70.09% 76.18%, 75.00% 93.30%, 69.13% 96.19%, 58.54% 81.88%, 54.31% 82.72%, 50.00% 100.00%, 43.47% 99.57%, 41.46% 81.88%, 37.37% 80.49%, 25.00% 93.30%, 19.56% 89.67%, 26.67% 73.33%, 23.82% 70.09%, 6.70% 75.00%, 3.81% 69.13%, 18.12% 58.54%, 17.28% 54.31%, 0.00% 50.00%, 0.43% 43.47%, 18.12% 41.46%, 19.51% 37.37%, 6.70% 25.00%, 10.33% 19.56%, 26.67% 26.67%, 29.91% 23.82%, 25.00% 6.70%, 30.87% 3.81%, 41.46% 18.12%, 45.69% 17.28%, 50.00% 0.00%, 56.53% 0.43%, 58.54% 18.12%, 62.63% 19.51%, 75.00% 6.70%, 80.44% 10.33%, 73.33% 26.67%, 76.18% 29.91%, 93.30% 25.00%, 96.19% 30.87%, 81.88% 41.46%, 82.72% 45.69%);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-reduced-motion: reduce) {
|
|
55
|
+
.m3-shape {
|
|
56
|
+
transition: none;
|
|
57
|
+
}
|
|
58
|
+
}
|