@lit-roa/hero 0.0.0-stage → 0.1.1

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 CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # @lit-roa/hero
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Carrusel principal de la página de inicio. Siempre empieza con una diapositiva de bienvenida
4
+ (antetítulo, título, texto, logo y hasta dos botones) y le siguen los anuncios de la tienda. La
5
+ portada de la tienda queda de fondo fijo de todo el carrusel; sin portada, un degradado del color
6
+ principal. Usa `lr-carrusel` por dentro (avance automático, pausa, arrastre, menos movimiento).
7
+
8
+ ```bash
9
+ npm install @lit-roa/hero
10
+ ```
11
+
12
+ ```ts
13
+ import '@lit-roa/hero';
14
+ ```
15
+
16
+ ```html
17
+ <lr-hero
18
+ disposicion="portada"
19
+ portada="/portada.jpg"
20
+ logo="/logo.png"
21
+ antetitulo="Bienvenido a"
22
+ titulo="Arena TCG"
23
+ texto="Cartas sueltas, sobres y torneos cada semana."
24
+ ></lr-hero>
25
+ <script>
26
+ const hero = document.querySelector('lr-hero');
27
+ hero.botones = [
28
+ { texto: 'Ver productos', href: '/productos' },
29
+ { texto: 'Próximos eventos', href: '/eventos' },
30
+ ];
31
+ hero.anuncios = [
32
+ { id: 'torneo', etiqueta: 'sáb 30 nov · 4 pm', titulo: 'Torneo regional', imagen: '/torneo.jpg', boton: 'Inscribirme', href: '/eventos/torneo' },
33
+ ];
34
+ hero.addEventListener('clic-hero', (e) => console.log(e.detail)); // { id, href }
35
+ </script>
36
+ ```
37
+
38
+ ## Disposiciones
39
+
40
+ | `disposicion` | Bienvenida | Anuncios | Celular |
41
+ | --- | --- | --- | --- |
42
+ | `portada` (por omisión) | Portada a todo lo ancho con velo del lado del texto | Portada teñida del color principal, imagen en tarjeta a la derecha | Los anuncios no muestran imagen |
43
+ | `dividido` | Texto en tarjeta blanca, portada y logo al lado | Texto en tarjeta blanca, imagen al lado; portada desenfocada de marco | Imagen arriba de la tarjeta |
44
+ | `escaparate` | Centrada con logo | Imagen nítida en tarjeta; portada desenfocada; pestañas con barra de avance | Imagen chica arriba, barritas tipo historias |
45
+
46
+ ## Propiedades
47
+
48
+ | Propiedad | Atributo | Tipo | Por omisión |
49
+ | --- | --- | --- | --- |
50
+ | `disposicion` | `disposicion` | `'portada' \| 'dividido' \| 'escaparate'` | `'portada'` |
51
+ | `portada` / `portadaCelular` | `portada` / `portada-celular` | `string` | `''` |
52
+ | `logo` / `logoAlt` | `logo` / `logo-alt` | `string` | `''` |
53
+ | `antetitulo`, `titulo`, `texto` | igual | `string` | `''` |
54
+ | `botones` | — | `BotonHero[]` (`{ texto, href, variante? }`, máximo 2) | `[]` |
55
+ | `anuncios` | — | `AnuncioHero[]` (`{ id?, titulo, texto?, antetitulo?, etiqueta?, imagen?, imagenCelular?, imagenAlt?, boton?, href? }`) | `[]` |
56
+ | `intervalo` | `intervalo` | `number` (ms; `0` no avanza solo) | `7000` |
57
+ | `ocultarImagenCelular` | `ocultar-imagen-celular` | `boolean` | `false` |
58
+ | `etiqueta` | `etiqueta` | `string` (nombre accesible) | `'Inicio'` |
59
+
60
+ ## Evento
61
+
62
+ - `clic-hero`: al tocar un botón. `detail`: `{ id, href }` (`id` solo en anuncios). El sitio navega; con Ctrl o Cmd se abre como liga normal.
63
+
64
+ ## Variables CSS
65
+
66
+ - `--lr-hero-alto` (30rem) y `--lr-hero-alto-celular` (32rem): alto mínimo.
67
+ - `--lr-hero-acento` (#facc15): etiqueta de los anuncios, antetítulo y barra de avance de las pestañas (esta con `--lr-carrusel-avance`).
68
+ - Toma el color principal y el redondeo de `--lr-color-primario` y `--lr-radio`.
package/dist/hero.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { LitElement } from 'lit';
2
+ import '@lit-roa/carrusel';
3
+ export interface BotonHero {
4
+ texto: string;
5
+ href: string;
6
+ /** `principal` (relleno, por omisión) o `secundario` (contorno). */
7
+ variante?: 'principal' | 'secundario';
8
+ }
9
+ export interface AnuncioHero {
10
+ /** Identificador libre que viaja en `clic-hero`. */
11
+ id?: string;
12
+ titulo: string;
13
+ texto?: string;
14
+ /** Texto chico arriba del título (por ejemplo "Anuncio"). */
15
+ antetitulo?: string;
16
+ /** Etiqueta resaltada arriba del título (por ejemplo la fecha de un evento). */
17
+ etiqueta?: string;
18
+ imagen?: string;
19
+ /** Imagen para pantallas de hasta 640 px. */
20
+ imagenCelular?: string;
21
+ imagenAlt?: string;
22
+ /** Texto del botón; sin él no hay botón. */
23
+ boton?: string;
24
+ href?: string;
25
+ }
26
+ export interface DetalleClicHero {
27
+ /** `id` del anuncio; no viene en los botones de la bienvenida. */
28
+ id?: string;
29
+ href: string;
30
+ }
31
+ export type DisposicionHero = 'portada' | 'dividido' | 'escaparate';
32
+ /**
33
+ * Carrusel principal de la página de inicio: siempre empieza con una
34
+ * diapositiva de bienvenida (antetítulo, título, texto, logo y hasta dos
35
+ * botones) y le siguen los anuncios. La portada de la tienda queda de fondo
36
+ * fijo de todo el carrusel; sin portada, un degradado del color principal.
37
+ *
38
+ * Tres disposiciones:
39
+ * - `portada` (por omisión): la portada a todo lo ancho; en los anuncios se
40
+ * tiñe del color principal y la imagen va en una tarjeta a la derecha. En
41
+ * celular los anuncios no muestran imagen.
42
+ * - `dividido`: la portada desenfocada de marco, el texto en una tarjeta
43
+ * blanca y la imagen al lado (arriba en celular).
44
+ * - `escaparate`: la portada desenfocada, la imagen nítida en una tarjeta y
45
+ * pestañas con el título de cada diapositiva y barra de avance.
46
+ *
47
+ * @fires clic-hero - Al tocar un botón. `detail`: `{ id, href }`. El sitio navega.
48
+ * @cssprop --lr-hero-alto - Alto mínimo en escritorio (30rem).
49
+ * @cssprop --lr-hero-alto-celular - Alto mínimo en celular (32rem).
50
+ * @cssprop --lr-hero-acento - Color de la etiqueta de los anuncios (#facc15).
51
+ */
52
+ export declare class LrHero extends LitElement {
53
+ static styles: import("lit").CSSResult[];
54
+ disposicion: DisposicionHero;
55
+ /** Portada de la tienda: fondo fijo de todo el carrusel. */
56
+ portada: string;
57
+ /** Portada para pantallas de hasta 640 px. */
58
+ portadaCelular: string;
59
+ /** Logo de la tienda (bienvenida de `dividido` y `escaparate`). */
60
+ logo: string;
61
+ logoAlt: string;
62
+ antetitulo: string;
63
+ titulo: string;
64
+ texto: string;
65
+ /** Hasta dos botones de la bienvenida (por ejemplo Productos y Eventos). */
66
+ botones: BotonHero[];
67
+ anuncios: AnuncioHero[];
68
+ /** Milisegundos entre diapositivas; `0` = no avanza solo. */
69
+ intervalo: number;
70
+ /** Oculta la imagen de los anuncios en celular también en `dividido` y `escaparate`. */
71
+ ocultarImagenCelular: boolean;
72
+ etiqueta: string;
73
+ private activa;
74
+ render(): import("lit-html").TemplateResult<1>;
75
+ private bienvenida;
76
+ private anuncio;
77
+ private alCambiar;
78
+ private alClic;
79
+ }
80
+ declare global {
81
+ interface HTMLElementTagNameMap {
82
+ 'lr-hero': LrHero;
83
+ }
84
+ }
85
+ //# sourceMappingURL=hero.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hero.d.ts","sourceRoot":"","sources":["../src/hero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAGrD,OAAO,mBAAmB,CAAC;AAG3B,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,MAAO,SAAQ,UAAU;IACpC,OAAgB,MAAM,4BA0WpB;IAE2B,WAAW,EAAE,eAAe,CAAa;IAEtE,4DAA4D;IAChD,OAAO,SAAM;IAEzB,8CAA8C;IACF,cAAc,SAAM;IAEhE,mEAAmE;IACvD,IAAI,SAAM;IAEe,OAAO,SAAM;IAEtC,UAAU,SAAM;IAEhB,MAAM,SAAM;IAEZ,KAAK,SAAM;IAEvB,4EAA4E;IAC5C,OAAO,EAAE,SAAS,EAAE,CAAM;IAE1B,QAAQ,EAAE,WAAW,EAAE,CAAM;IAE7D,6DAA6D;IACjC,SAAS,SAAQ;IAE7C,wFAAwF;IACP,oBAAoB,UAAS;IAElG,QAAQ,SAAY;IAEvB,OAAO,CAAC,MAAM,CAAK;IAEnB,MAAM;IAyBf,OAAO,CAAC,UAAU;IA+BlB,OAAO,CAAC,OAAO;IAwBf,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,MAAM;CAKf;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB;CACF"}
package/dist/hero.js ADDED
@@ -0,0 +1,550 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, css, html, nothing } from 'lit';
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import { emitir, estilosBase, tokens } from '@lit-roa/base';
10
+ import '@lit-roa/carrusel';
11
+ /**
12
+ * Carrusel principal de la página de inicio: siempre empieza con una
13
+ * diapositiva de bienvenida (antetítulo, título, texto, logo y hasta dos
14
+ * botones) y le siguen los anuncios. La portada de la tienda queda de fondo
15
+ * fijo de todo el carrusel; sin portada, un degradado del color principal.
16
+ *
17
+ * Tres disposiciones:
18
+ * - `portada` (por omisión): la portada a todo lo ancho; en los anuncios se
19
+ * tiñe del color principal y la imagen va en una tarjeta a la derecha. En
20
+ * celular los anuncios no muestran imagen.
21
+ * - `dividido`: la portada desenfocada de marco, el texto en una tarjeta
22
+ * blanca y la imagen al lado (arriba en celular).
23
+ * - `escaparate`: la portada desenfocada, la imagen nítida en una tarjeta y
24
+ * pestañas con el título de cada diapositiva y barra de avance.
25
+ *
26
+ * @fires clic-hero - Al tocar un botón. `detail`: `{ id, href }`. El sitio navega.
27
+ * @cssprop --lr-hero-alto - Alto mínimo en escritorio (30rem).
28
+ * @cssprop --lr-hero-alto-celular - Alto mínimo en celular (32rem).
29
+ * @cssprop --lr-hero-acento - Color de la etiqueta de los anuncios (#facc15).
30
+ */
31
+ let LrHero = class LrHero extends LitElement {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.disposicion = 'portada';
35
+ /** Portada de la tienda: fondo fijo de todo el carrusel. */
36
+ this.portada = '';
37
+ /** Portada para pantallas de hasta 640 px. */
38
+ this.portadaCelular = '';
39
+ /** Logo de la tienda (bienvenida de `dividido` y `escaparate`). */
40
+ this.logo = '';
41
+ this.logoAlt = '';
42
+ this.antetitulo = '';
43
+ this.titulo = '';
44
+ this.texto = '';
45
+ /** Hasta dos botones de la bienvenida (por ejemplo Productos y Eventos). */
46
+ this.botones = [];
47
+ this.anuncios = [];
48
+ /** Milisegundos entre diapositivas; `0` = no avanza solo. */
49
+ this.intervalo = 7000;
50
+ /** Oculta la imagen de los anuncios en celular también en `dividido` y `escaparate`. */
51
+ this.ocultarImagenCelular = false;
52
+ this.etiqueta = 'Inicio';
53
+ this.activa = 0;
54
+ }
55
+ static { this.styles = [
56
+ tokens,
57
+ estilosBase,
58
+ css `
59
+ :host {
60
+ display: block;
61
+ --_oscuro: color-mix(in srgb, var(--_color-primario), #000 50%);
62
+ --_acento: var(--lr-hero-acento, #facc15);
63
+ --_alto: var(--lr-hero-alto, 30rem);
64
+ }
65
+ .marco {
66
+ position: relative;
67
+ isolation: isolate;
68
+ overflow: hidden;
69
+ border-radius: var(--_radio);
70
+ background: linear-gradient(135deg, var(--_oscuro), var(--_color-primario));
71
+ color: #fff;
72
+ }
73
+ .fondo,
74
+ .tinte,
75
+ .tinte::before,
76
+ .tinte::after {
77
+ position: absolute;
78
+ inset: 0;
79
+ z-index: -1;
80
+ }
81
+ .fondo img {
82
+ width: 100%;
83
+ height: 100%;
84
+ object-fit: cover;
85
+ display: block;
86
+ }
87
+ :host([disposicion='dividido']) .fondo,
88
+ :host([disposicion='escaparate']) .fondo {
89
+ inset: -3rem;
90
+ filter: blur(32px) saturate(1.25);
91
+ }
92
+ .tinte::before,
93
+ .tinte::after {
94
+ content: '';
95
+ transition: opacity 0.6s;
96
+ }
97
+ .tinte::after {
98
+ opacity: 0;
99
+ }
100
+ .marco[data-activa='anuncio'] .tinte::before {
101
+ opacity: 0;
102
+ }
103
+ .marco[data-activa='anuncio'] .tinte::after {
104
+ opacity: 1;
105
+ }
106
+ /* Portada: velo oscuro del lado del texto en la bienvenida, color de la marca en los anuncios. */
107
+ .tinte::before {
108
+ background: linear-gradient(90deg, rgb(10 12 30 / 0.82) 0%, rgb(10 12 30 / 0.55) 45%, rgb(10 12 30 / 0) 80%);
109
+ }
110
+ .tinte::after {
111
+ background: linear-gradient(
112
+ 105deg,
113
+ color-mix(in srgb, var(--_oscuro) 94%, transparent) 0%,
114
+ color-mix(in srgb, var(--_color-primario) 82%, transparent) 45%,
115
+ color-mix(in srgb, var(--_oscuro) 50%, transparent) 100%
116
+ );
117
+ }
118
+ :host([disposicion='dividido']) .tinte::before,
119
+ :host([disposicion='dividido']) .tinte::after,
120
+ :host([disposicion='escaparate']) .tinte::before,
121
+ :host([disposicion='escaparate']) .tinte::after {
122
+ background: rgb(10 12 30 / 0.45);
123
+ }
124
+ lr-carrusel {
125
+ --lr-carrusel-radio: 0;
126
+ --lr-carrusel-avance: var(--_acento);
127
+ /* El carrusel pone el color de texto del sitio; aquí manda el del hero. */
128
+ color: inherit;
129
+ }
130
+
131
+ /* ---- Diapositivas ---- */
132
+ .diapositiva {
133
+ position: relative;
134
+ display: flex;
135
+ min-height: var(--_alto);
136
+ padding: clamp(1.5rem, 5vw, 4rem);
137
+ padding-bottom: max(clamp(1.5rem, 5vw, 4rem), var(--lr-carrusel-reserva-abajo, 0px));
138
+ gap: 3rem;
139
+ align-items: center;
140
+ }
141
+ .texto {
142
+ display: flex;
143
+ flex-direction: column;
144
+ align-items: flex-start;
145
+ gap: 1rem;
146
+ max-width: 36rem;
147
+ min-width: 0;
148
+ }
149
+ .antetitulo {
150
+ font-size: 0.8125rem;
151
+ font-weight: 800;
152
+ letter-spacing: 0.08em;
153
+ text-transform: uppercase;
154
+ color: var(--_acento);
155
+ }
156
+ .etiqueta {
157
+ display: inline-flex;
158
+ padding: 0.375rem 0.75rem;
159
+ border-radius: 999px;
160
+ background: var(--_acento);
161
+ color: #1f2937;
162
+ font-size: 0.8125rem;
163
+ font-weight: 700;
164
+ }
165
+ h2 {
166
+ margin: 0;
167
+ font-size: clamp(1.875rem, 4.5vw, 3.25rem);
168
+ line-height: 1.06;
169
+ font-weight: 800;
170
+ letter-spacing: -0.02em;
171
+ text-wrap: balance;
172
+ }
173
+ .anuncio h2 {
174
+ font-size: clamp(1.75rem, 4vw, 2.875rem);
175
+ }
176
+ p {
177
+ margin: 0;
178
+ font-size: clamp(1rem, 1.8vw, 1.1875rem);
179
+ line-height: 1.5;
180
+ opacity: 0.92;
181
+ }
182
+ .botones {
183
+ display: flex;
184
+ flex-wrap: wrap;
185
+ gap: 0.75rem;
186
+ margin-top: 0.5rem;
187
+ }
188
+ .boton {
189
+ display: inline-flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ height: 3rem;
193
+ padding: 0 1.375rem;
194
+ border-radius: calc(var(--_radio) / 1.5);
195
+ font-weight: 700;
196
+ text-decoration: none;
197
+ white-space: nowrap;
198
+ background: var(--_color-primario);
199
+ color: var(--_color-sobre-primario);
200
+ border: 1.5px solid transparent;
201
+ }
202
+ .boton.secundario {
203
+ background: transparent;
204
+ color: #fff;
205
+ border-color: rgb(255 255 255 / 0.85);
206
+ }
207
+ .anuncio .boton {
208
+ background: #fff;
209
+ color: #111827;
210
+ }
211
+ .boton:hover {
212
+ filter: brightness(0.94);
213
+ }
214
+ .boton:focus-visible {
215
+ outline: 2px solid #fff;
216
+ outline-offset: 3px;
217
+ }
218
+ .imagen {
219
+ position: relative;
220
+ flex: 1 1 0;
221
+ align-self: stretch;
222
+ min-width: 0;
223
+ max-height: calc(var(--_alto) - 5rem);
224
+ border-radius: calc(var(--_radio) * 1.25);
225
+ overflow: hidden;
226
+ box-shadow: 0 24px 60px rgb(0 0 0 / 0.4), 0 0 0 1px rgb(255 255 255 / 0.15);
227
+ }
228
+ .imagen img:not(.logo) {
229
+ position: absolute;
230
+ inset: 0;
231
+ width: 100%;
232
+ height: 100%;
233
+ object-fit: cover;
234
+ }
235
+ .anuncio .texto {
236
+ flex: 1 1 0;
237
+ }
238
+ .logo {
239
+ width: 5.25rem;
240
+ height: 5.25rem;
241
+ border-radius: 1.25rem;
242
+ object-fit: contain;
243
+ background: #fff;
244
+ box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
245
+ }
246
+
247
+ /* ---- Dividido ---- */
248
+ :host([disposicion='dividido']) .diapositiva {
249
+ padding: 1.75rem;
250
+ padding-bottom: max(1.75rem, var(--lr-carrusel-reserva-abajo, 0px));
251
+ gap: 1.5rem;
252
+ align-items: stretch;
253
+ }
254
+ :host([disposicion='dividido']) .texto {
255
+ flex: 1 1 0;
256
+ max-width: none;
257
+ justify-content: center;
258
+ padding: clamp(1.5rem, 4vw, 3rem);
259
+ border-radius: calc(var(--_radio) * 1.25);
260
+ background: #fff;
261
+ color: var(--_color-texto);
262
+ box-shadow: 0 20px 50px rgb(0 0 0 / 0.3);
263
+ }
264
+ :host([disposicion='dividido']) .antetitulo {
265
+ color: var(--_color-primario);
266
+ }
267
+ :host([disposicion='dividido']) p {
268
+ color: var(--_color-texto-suave);
269
+ opacity: 1;
270
+ }
271
+ :host([disposicion='dividido']) .boton.secundario {
272
+ color: var(--_color-primario);
273
+ border-color: var(--_color-primario);
274
+ }
275
+ :host([disposicion='dividido']) .anuncio .boton {
276
+ background: var(--_color-primario);
277
+ color: var(--_color-sobre-primario);
278
+ }
279
+ :host([disposicion='dividido']) .imagen {
280
+ max-height: none;
281
+ box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
282
+ }
283
+ :host([disposicion='dividido']) .imagen.sin-imagen {
284
+ background: linear-gradient(135deg, var(--_oscuro), var(--_color-primario));
285
+ }
286
+ :host([disposicion='dividido']) .imagen .logo {
287
+ position: absolute;
288
+ left: 1.5rem;
289
+ bottom: 1.5rem;
290
+ }
291
+ :host([disposicion='dividido']) .imagen.sin-imagen .logo {
292
+ left: calc(50% - 2.625rem);
293
+ bottom: calc(50% - 2.625rem);
294
+ }
295
+
296
+ /* ---- Escaparate ---- */
297
+ :host([disposicion='escaparate']) .bienvenida {
298
+ justify-content: center;
299
+ text-align: center;
300
+ }
301
+ :host([disposicion='escaparate']) .bienvenida .texto {
302
+ align-items: center;
303
+ max-width: 40rem;
304
+ }
305
+ :host([disposicion='escaparate']) .bienvenida .botones {
306
+ justify-content: center;
307
+ }
308
+ :host([disposicion='escaparate']) .bienvenida .boton.principal {
309
+ background: #fff;
310
+ color: #111827;
311
+ }
312
+ :host([disposicion='escaparate']) .imagen {
313
+ flex: 0 1 46%;
314
+ align-self: center;
315
+ aspect-ratio: 3 / 2;
316
+ }
317
+
318
+ @media (max-width: 640px) {
319
+ :host {
320
+ --_alto: var(--lr-hero-alto-celular, 32rem);
321
+ }
322
+ .diapositiva {
323
+ flex-direction: column;
324
+ justify-content: flex-end;
325
+ align-items: stretch;
326
+ gap: 1.25rem;
327
+ padding: 1.5rem 1.375rem;
328
+ padding-bottom: max(1.5rem, var(--lr-carrusel-reserva-abajo, 0px));
329
+ }
330
+ .tinte::before {
331
+ background: linear-gradient(0deg, rgb(10 12 30 / 0.92) 0%, rgb(10 12 30 / 0.6) 45%, rgb(10 12 30 / 0.05) 85%);
332
+ }
333
+ .tinte::after {
334
+ background: linear-gradient(
335
+ 0deg,
336
+ color-mix(in srgb, var(--_oscuro) 96%, transparent) 0%,
337
+ color-mix(in srgb, var(--_color-primario) 85%, transparent) 50%,
338
+ color-mix(in srgb, var(--_oscuro) 55%, transparent) 100%
339
+ );
340
+ }
341
+ .texto,
342
+ .anuncio .texto {
343
+ flex: none;
344
+ }
345
+ .botones {
346
+ flex-direction: column;
347
+ align-self: stretch;
348
+ }
349
+ .boton {
350
+ width: 100%;
351
+ }
352
+ /* Portada: los anuncios no muestran imagen en celular. */
353
+ :host(:not([disposicion])) .anuncio .imagen,
354
+ :host([disposicion='portada']) .anuncio .imagen,
355
+ :host([ocultar-imagen-celular]) .anuncio .imagen {
356
+ display: none;
357
+ }
358
+ .imagen {
359
+ flex: none;
360
+ order: -1;
361
+ height: 9.5rem;
362
+ max-height: none;
363
+ }
364
+ :host([disposicion='escaparate']) .diapositiva {
365
+ justify-content: center;
366
+ text-align: center;
367
+ }
368
+ :host([disposicion='escaparate']) .texto {
369
+ align-items: center;
370
+ align-self: center;
371
+ }
372
+ :host([disposicion='escaparate']) .imagen {
373
+ flex: none;
374
+ aspect-ratio: auto;
375
+ align-self: stretch;
376
+ }
377
+ :host([disposicion='dividido']) .diapositiva {
378
+ gap: 0;
379
+ padding: 0.875rem;
380
+ padding-bottom: max(0.875rem, var(--lr-carrusel-reserva-abajo, 0px));
381
+ justify-content: flex-start;
382
+ }
383
+ :host([disposicion='dividido']) .texto {
384
+ flex: 1 0 auto;
385
+ justify-content: flex-start;
386
+ padding: 1.25rem;
387
+ }
388
+ :host([disposicion='dividido']) .anuncio:not(:has(.imagen)) .texto,
389
+ :host([ocultar-imagen-celular][disposicion='dividido']) .anuncio .texto {
390
+ justify-content: center;
391
+ }
392
+ :host([disposicion='dividido']) .imagen {
393
+ height: 11rem;
394
+ border-radius: calc(var(--_radio) * 1.25) calc(var(--_radio) * 1.25) 0 0;
395
+ box-shadow: none;
396
+ }
397
+ :host([disposicion='dividido']) .imagen + .texto,
398
+ :host([disposicion='dividido']) .texto:has(+ .imagen) {
399
+ border-radius: 0 0 calc(var(--_radio) * 1.25) calc(var(--_radio) * 1.25);
400
+ }
401
+ :host([ocultar-imagen-celular][disposicion='dividido']) .anuncio .texto {
402
+ border-radius: calc(var(--_radio) * 1.25);
403
+ }
404
+ :host([disposicion='dividido']) .imagen .logo {
405
+ width: 4rem;
406
+ height: 4rem;
407
+ border-radius: 0.875rem;
408
+ left: 1rem;
409
+ bottom: 1rem;
410
+ }
411
+ :host([disposicion='dividido']) .imagen.sin-imagen .logo {
412
+ left: calc(50% - 2rem);
413
+ bottom: calc(50% - 2rem);
414
+ }
415
+ }
416
+ `,
417
+ ]; }
418
+ render() {
419
+ const escaparate = this.disposicion === 'escaparate';
420
+ return html `
421
+ <div class="marco" data-activa=${this.activa === 0 ? 'bienvenida' : 'anuncio'}>
422
+ ${this.portada
423
+ ? html `<picture class="fondo" aria-hidden="true">
424
+ ${this.portadaCelular ? html `<source media="(max-width: 640px)" srcset=${this.portadaCelular} />` : nothing}
425
+ <img src=${this.portada} alt="" fetchpriority="high" />
426
+ </picture>`
427
+ : nothing}
428
+ <div class="tinte" aria-hidden="true"></div>
429
+ <lr-carrusel
430
+ etiqueta=${this.etiqueta}
431
+ intervalo=${this.intervalo}
432
+ ?puntos-encima=${!escaparate}
433
+ ?pestanas=${escaparate}
434
+ efecto=${escaparate ? 'desvanecer' : 'deslizar'}
435
+ @cambio-diapositiva=${this.alCambiar}
436
+ >
437
+ ${this.bienvenida()} ${this.anuncios.map((a) => this.anuncio(a))}
438
+ </lr-carrusel>
439
+ </div>
440
+ `;
441
+ }
442
+ bienvenida() {
443
+ const dividido = this.disposicion === 'dividido';
444
+ const logo = this.logo ? html `<img class="logo" src=${this.logo} alt=${this.logoAlt} />` : nothing;
445
+ const botones = this.botones.slice(0, 2);
446
+ return html `<article class="diapositiva bienvenida" data-pestana=${this.titulo || 'Bienvenida'} data-pestana-detalle="Inicio">
447
+ <div class="texto">
448
+ ${this.disposicion === 'escaparate' ? logo : nothing}
449
+ ${this.antetitulo ? html `<span class="antetitulo">${this.antetitulo}</span>` : nothing}
450
+ ${this.titulo ? html `<h2>${this.titulo}</h2>` : nothing}
451
+ ${this.texto ? html `<p>${this.texto}</p>` : nothing}
452
+ ${botones.length
453
+ ? html `<div class="botones">
454
+ ${botones.map((b, i) => html `<a
455
+ class="boton ${b.variante ?? (i === 0 ? 'principal' : 'secundario')}"
456
+ href=${b.href}
457
+ @click=${(e) => this.alClic(e, b.href)}
458
+ >${b.texto}</a
459
+ >`)}
460
+ </div>`
461
+ : nothing}
462
+ </div>
463
+ ${dividido
464
+ ? html `<div class="imagen ${this.portada ? '' : 'sin-imagen'}">
465
+ ${this.portada ? html `<img src=${this.portadaCelular || this.portada} alt="" />` : nothing} ${logo}
466
+ </div>`
467
+ : nothing}
468
+ </article>`;
469
+ }
470
+ anuncio(a) {
471
+ return html `<article class="diapositiva anuncio" data-pestana=${a.titulo} data-pestana-detalle=${a.etiqueta || a.antetitulo || 'Anuncio'}>
472
+ <div class="texto">
473
+ ${a.etiqueta ? html `<span class="etiqueta">${a.etiqueta}</span>` : nothing}
474
+ ${a.antetitulo ? html `<span class="antetitulo">${a.antetitulo}</span>` : nothing}
475
+ <h2>${a.titulo}</h2>
476
+ ${a.texto ? html `<p>${a.texto}</p>` : nothing}
477
+ ${a.boton && a.href
478
+ ? html `<div class="botones">
479
+ <a class="boton" href=${a.href} @click=${(e) => this.alClic(e, a.href, a.id)}>${a.boton}</a>
480
+ </div>`
481
+ : nothing}
482
+ </div>
483
+ ${a.imagen
484
+ ? html `<div class="imagen">
485
+ <picture>
486
+ ${a.imagenCelular ? html `<source media="(max-width: 640px)" srcset=${a.imagenCelular} />` : nothing}
487
+ <img src=${a.imagen} alt=${a.imagenAlt ?? ''} loading="lazy" />
488
+ </picture>
489
+ </div>`
490
+ : nothing}
491
+ </article>`;
492
+ }
493
+ alCambiar(evento) {
494
+ evento.stopPropagation();
495
+ this.activa = evento.detail.indice;
496
+ }
497
+ alClic(evento, href, id) {
498
+ if (evento.ctrlKey || evento.metaKey)
499
+ return;
500
+ evento.preventDefault();
501
+ emitir(this, 'clic-hero', { id, href });
502
+ }
503
+ };
504
+ __decorate([
505
+ property({ reflect: true })
506
+ ], LrHero.prototype, "disposicion", void 0);
507
+ __decorate([
508
+ property()
509
+ ], LrHero.prototype, "portada", void 0);
510
+ __decorate([
511
+ property({ attribute: 'portada-celular' })
512
+ ], LrHero.prototype, "portadaCelular", void 0);
513
+ __decorate([
514
+ property()
515
+ ], LrHero.prototype, "logo", void 0);
516
+ __decorate([
517
+ property({ attribute: 'logo-alt' })
518
+ ], LrHero.prototype, "logoAlt", void 0);
519
+ __decorate([
520
+ property()
521
+ ], LrHero.prototype, "antetitulo", void 0);
522
+ __decorate([
523
+ property()
524
+ ], LrHero.prototype, "titulo", void 0);
525
+ __decorate([
526
+ property()
527
+ ], LrHero.prototype, "texto", void 0);
528
+ __decorate([
529
+ property({ attribute: false })
530
+ ], LrHero.prototype, "botones", void 0);
531
+ __decorate([
532
+ property({ attribute: false })
533
+ ], LrHero.prototype, "anuncios", void 0);
534
+ __decorate([
535
+ property({ type: Number })
536
+ ], LrHero.prototype, "intervalo", void 0);
537
+ __decorate([
538
+ property({ type: Boolean, reflect: true, attribute: 'ocultar-imagen-celular' })
539
+ ], LrHero.prototype, "ocultarImagenCelular", void 0);
540
+ __decorate([
541
+ property()
542
+ ], LrHero.prototype, "etiqueta", void 0);
543
+ __decorate([
544
+ state()
545
+ ], LrHero.prototype, "activa", void 0);
546
+ LrHero = __decorate([
547
+ customElement('lr-hero')
548
+ ], LrHero);
549
+ export { LrHero };
550
+ //# sourceMappingURL=hero.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hero.js","sourceRoot":"","sources":["../src/hero.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,mBAAmB,CAAC;AAoC3B;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;IAA/B;;QA6WwB,gBAAW,GAAoB,SAAS,CAAC;QAEtE,4DAA4D;QAChD,YAAO,GAAG,EAAE,CAAC;QAEzB,8CAA8C;QACF,mBAAc,GAAG,EAAE,CAAC;QAEhE,mEAAmE;QACvD,SAAI,GAAG,EAAE,CAAC;QAEe,YAAO,GAAG,EAAE,CAAC;QAEtC,eAAU,GAAG,EAAE,CAAC;QAEhB,WAAM,GAAG,EAAE,CAAC;QAEZ,UAAK,GAAG,EA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/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uCAA2B;AAE1B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wCAA8B;AAGjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAkB;AAGoC;IAAhF,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;oDAA8B;AAElG;IAAX,QAAQ,EAAE;wCAAqB;AAEf;IAAhB,KAAK,EAAE;sCAAoB;AA7YjB,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAyelB"}
@@ -0,0 +1,3 @@
1
+ export { LrHero } from './hero.js';
2
+ export type { AnuncioHero, BotonHero, DetalleClicHero, DisposicionHero } from './hero.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { LrHero } from './hero.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@lit-roa/hero",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Carrusel principal de inicio: bienvenida fija, anuncios y la portada de la tienda de fondo, en tres disposiciones.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src"
17
+ ],
18
+ "sideEffects": [
19
+ "./dist/*.js"
20
+ ],
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "tsc -b"
24
+ },
25
+ "dependencies": {
26
+ "@lit-roa/base": "^0.7.0",
27
+ "@lit-roa/carrusel": "^0.3.0",
28
+ "lit": "^3.3.3"
29
+ },
30
+ "license": "MIT"
31
+ }
package/src/hero.ts ADDED
@@ -0,0 +1,556 @@
1
+ import { LitElement, css, html, nothing } from 'lit';
2
+ import { customElement, property, state } from 'lit/decorators.js';
3
+ import { emitir, estilosBase, tokens } from '@lit-roa/base';
4
+ import '@lit-roa/carrusel';
5
+ import type { DetalleCambioDiapositiva } from '@lit-roa/carrusel';
6
+
7
+ export interface BotonHero {
8
+ texto: string;
9
+ href: string;
10
+ /** `principal` (relleno, por omisión) o `secundario` (contorno). */
11
+ variante?: 'principal' | 'secundario';
12
+ }
13
+
14
+ export interface AnuncioHero {
15
+ /** Identificador libre que viaja en `clic-hero`. */
16
+ id?: string;
17
+ titulo: string;
18
+ texto?: string;
19
+ /** Texto chico arriba del título (por ejemplo "Anuncio"). */
20
+ antetitulo?: string;
21
+ /** Etiqueta resaltada arriba del título (por ejemplo la fecha de un evento). */
22
+ etiqueta?: string;
23
+ imagen?: string;
24
+ /** Imagen para pantallas de hasta 640 px. */
25
+ imagenCelular?: string;
26
+ imagenAlt?: string;
27
+ /** Texto del botón; sin él no hay botón. */
28
+ boton?: string;
29
+ href?: string;
30
+ }
31
+
32
+ export interface DetalleClicHero {
33
+ /** `id` del anuncio; no viene en los botones de la bienvenida. */
34
+ id?: string;
35
+ href: string;
36
+ }
37
+
38
+ export type DisposicionHero = 'portada' | 'dividido' | 'escaparate';
39
+
40
+ /**
41
+ * Carrusel principal de la página de inicio: siempre empieza con una
42
+ * diapositiva de bienvenida (antetítulo, título, texto, logo y hasta dos
43
+ * botones) y le siguen los anuncios. La portada de la tienda queda de fondo
44
+ * fijo de todo el carrusel; sin portada, un degradado del color principal.
45
+ *
46
+ * Tres disposiciones:
47
+ * - `portada` (por omisión): la portada a todo lo ancho; en los anuncios se
48
+ * tiñe del color principal y la imagen va en una tarjeta a la derecha. En
49
+ * celular los anuncios no muestran imagen.
50
+ * - `dividido`: la portada desenfocada de marco, el texto en una tarjeta
51
+ * blanca y la imagen al lado (arriba en celular).
52
+ * - `escaparate`: la portada desenfocada, la imagen nítida en una tarjeta y
53
+ * pestañas con el título de cada diapositiva y barra de avance.
54
+ *
55
+ * @fires clic-hero - Al tocar un botón. `detail`: `{ id, href }`. El sitio navega.
56
+ * @cssprop --lr-hero-alto - Alto mínimo en escritorio (30rem).
57
+ * @cssprop --lr-hero-alto-celular - Alto mínimo en celular (32rem).
58
+ * @cssprop --lr-hero-acento - Color de la etiqueta de los anuncios (#facc15).
59
+ */
60
+ @customElement('lr-hero')
61
+ export class LrHero extends LitElement {
62
+ static override styles = [
63
+ tokens,
64
+ estilosBase,
65
+ css`
66
+ :host {
67
+ display: block;
68
+ --_oscuro: color-mix(in srgb, var(--_color-primario), #000 50%);
69
+ --_acento: var(--lr-hero-acento, #facc15);
70
+ --_alto: var(--lr-hero-alto, 30rem);
71
+ }
72
+ .marco {
73
+ position: relative;
74
+ isolation: isolate;
75
+ overflow: hidden;
76
+ border-radius: var(--_radio);
77
+ background: linear-gradient(135deg, var(--_oscuro), var(--_color-primario));
78
+ color: #fff;
79
+ }
80
+ .fondo,
81
+ .tinte,
82
+ .tinte::before,
83
+ .tinte::after {
84
+ position: absolute;
85
+ inset: 0;
86
+ z-index: -1;
87
+ }
88
+ .fondo img {
89
+ width: 100%;
90
+ height: 100%;
91
+ object-fit: cover;
92
+ display: block;
93
+ }
94
+ :host([disposicion='dividido']) .fondo,
95
+ :host([disposicion='escaparate']) .fondo {
96
+ inset: -3rem;
97
+ filter: blur(32px) saturate(1.25);
98
+ }
99
+ .tinte::before,
100
+ .tinte::after {
101
+ content: '';
102
+ transition: opacity 0.6s;
103
+ }
104
+ .tinte::after {
105
+ opacity: 0;
106
+ }
107
+ .marco[data-activa='anuncio'] .tinte::before {
108
+ opacity: 0;
109
+ }
110
+ .marco[data-activa='anuncio'] .tinte::after {
111
+ opacity: 1;
112
+ }
113
+ /* Portada: velo oscuro del lado del texto en la bienvenida, color de la marca en los anuncios. */
114
+ .tinte::before {
115
+ background: linear-gradient(90deg, rgb(10 12 30 / 0.82) 0%, rgb(10 12 30 / 0.55) 45%, rgb(10 12 30 / 0) 80%);
116
+ }
117
+ .tinte::after {
118
+ background: linear-gradient(
119
+ 105deg,
120
+ color-mix(in srgb, var(--_oscuro) 94%, transparent) 0%,
121
+ color-mix(in srgb, var(--_color-primario) 82%, transparent) 45%,
122
+ color-mix(in srgb, var(--_oscuro) 50%, transparent) 100%
123
+ );
124
+ }
125
+ :host([disposicion='dividido']) .tinte::before,
126
+ :host([disposicion='dividido']) .tinte::after,
127
+ :host([disposicion='escaparate']) .tinte::before,
128
+ :host([disposicion='escaparate']) .tinte::after {
129
+ background: rgb(10 12 30 / 0.45);
130
+ }
131
+ lr-carrusel {
132
+ --lr-carrusel-radio: 0;
133
+ --lr-carrusel-avance: var(--_acento);
134
+ /* El carrusel pone el color de texto del sitio; aquí manda el del hero. */
135
+ color: inherit;
136
+ }
137
+
138
+ /* ---- Diapositivas ---- */
139
+ .diapositiva {
140
+ position: relative;
141
+ display: flex;
142
+ min-height: var(--_alto);
143
+ padding: clamp(1.5rem, 5vw, 4rem);
144
+ padding-bottom: max(clamp(1.5rem, 5vw, 4rem), var(--lr-carrusel-reserva-abajo, 0px));
145
+ gap: 3rem;
146
+ align-items: center;
147
+ }
148
+ .texto {
149
+ display: flex;
150
+ flex-direction: column;
151
+ align-items: flex-start;
152
+ gap: 1rem;
153
+ max-width: 36rem;
154
+ min-width: 0;
155
+ }
156
+ .antetitulo {
157
+ font-size: 0.8125rem;
158
+ font-weight: 800;
159
+ letter-spacing: 0.08em;
160
+ text-transform: uppercase;
161
+ color: var(--_acento);
162
+ }
163
+ .etiqueta {
164
+ display: inline-flex;
165
+ padding: 0.375rem 0.75rem;
166
+ border-radius: 999px;
167
+ background: var(--_acento);
168
+ color: #1f2937;
169
+ font-size: 0.8125rem;
170
+ font-weight: 700;
171
+ }
172
+ h2 {
173
+ margin: 0;
174
+ font-size: clamp(1.875rem, 4.5vw, 3.25rem);
175
+ line-height: 1.06;
176
+ font-weight: 800;
177
+ letter-spacing: -0.02em;
178
+ text-wrap: balance;
179
+ }
180
+ .anuncio h2 {
181
+ font-size: clamp(1.75rem, 4vw, 2.875rem);
182
+ }
183
+ p {
184
+ margin: 0;
185
+ font-size: clamp(1rem, 1.8vw, 1.1875rem);
186
+ line-height: 1.5;
187
+ opacity: 0.92;
188
+ }
189
+ .botones {
190
+ display: flex;
191
+ flex-wrap: wrap;
192
+ gap: 0.75rem;
193
+ margin-top: 0.5rem;
194
+ }
195
+ .boton {
196
+ display: inline-flex;
197
+ align-items: center;
198
+ justify-content: center;
199
+ height: 3rem;
200
+ padding: 0 1.375rem;
201
+ border-radius: calc(var(--_radio) / 1.5);
202
+ font-weight: 700;
203
+ text-decoration: none;
204
+ white-space: nowrap;
205
+ background: var(--_color-primario);
206
+ color: var(--_color-sobre-primario);
207
+ border: 1.5px solid transparent;
208
+ }
209
+ .boton.secundario {
210
+ background: transparent;
211
+ color: #fff;
212
+ border-color: rgb(255 255 255 / 0.85);
213
+ }
214
+ .anuncio .boton {
215
+ background: #fff;
216
+ color: #111827;
217
+ }
218
+ .boton:hover {
219
+ filter: brightness(0.94);
220
+ }
221
+ .boton:focus-visible {
222
+ outline: 2px solid #fff;
223
+ outline-offset: 3px;
224
+ }
225
+ .imagen {
226
+ position: relative;
227
+ flex: 1 1 0;
228
+ align-self: stretch;
229
+ min-width: 0;
230
+ max-height: calc(var(--_alto) - 5rem);
231
+ border-radius: calc(var(--_radio) * 1.25);
232
+ overflow: hidden;
233
+ box-shadow: 0 24px 60px rgb(0 0 0 / 0.4), 0 0 0 1px rgb(255 255 255 / 0.15);
234
+ }
235
+ .imagen img:not(.logo) {
236
+ position: absolute;
237
+ inset: 0;
238
+ width: 100%;
239
+ height: 100%;
240
+ object-fit: cover;
241
+ }
242
+ .anuncio .texto {
243
+ flex: 1 1 0;
244
+ }
245
+ .logo {
246
+ width: 5.25rem;
247
+ height: 5.25rem;
248
+ border-radius: 1.25rem;
249
+ object-fit: contain;
250
+ background: #fff;
251
+ box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);
252
+ }
253
+
254
+ /* ---- Dividido ---- */
255
+ :host([disposicion='dividido']) .diapositiva {
256
+ padding: 1.75rem;
257
+ padding-bottom: max(1.75rem, var(--lr-carrusel-reserva-abajo, 0px));
258
+ gap: 1.5rem;
259
+ align-items: stretch;
260
+ }
261
+ :host([disposicion='dividido']) .texto {
262
+ flex: 1 1 0;
263
+ max-width: none;
264
+ justify-content: center;
265
+ padding: clamp(1.5rem, 4vw, 3rem);
266
+ border-radius: calc(var(--_radio) * 1.25);
267
+ background: #fff;
268
+ color: var(--_color-texto);
269
+ box-shadow: 0 20px 50px rgb(0 0 0 / 0.3);
270
+ }
271
+ :host([disposicion='dividido']) .antetitulo {
272
+ color: var(--_color-primario);
273
+ }
274
+ :host([disposicion='dividido']) p {
275
+ color: var(--_color-texto-suave);
276
+ opacity: 1;
277
+ }
278
+ :host([disposicion='dividido']) .boton.secundario {
279
+ color: var(--_color-primario);
280
+ border-color: var(--_color-primario);
281
+ }
282
+ :host([disposicion='dividido']) .anuncio .boton {
283
+ background: var(--_color-primario);
284
+ color: var(--_color-sobre-primario);
285
+ }
286
+ :host([disposicion='dividido']) .imagen {
287
+ max-height: none;
288
+ box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
289
+ }
290
+ :host([disposicion='dividido']) .imagen.sin-imagen {
291
+ background: linear-gradient(135deg, var(--_oscuro), var(--_color-primario));
292
+ }
293
+ :host([disposicion='dividido']) .imagen .logo {
294
+ position: absolute;
295
+ left: 1.5rem;
296
+ bottom: 1.5rem;
297
+ }
298
+ :host([disposicion='dividido']) .imagen.sin-imagen .logo {
299
+ left: calc(50% - 2.625rem);
300
+ bottom: calc(50% - 2.625rem);
301
+ }
302
+
303
+ /* ---- Escaparate ---- */
304
+ :host([disposicion='escaparate']) .bienvenida {
305
+ justify-content: center;
306
+ text-align: center;
307
+ }
308
+ :host([disposicion='escaparate']) .bienvenida .texto {
309
+ align-items: center;
310
+ max-width: 40rem;
311
+ }
312
+ :host([disposicion='escaparate']) .bienvenida .botones {
313
+ justify-content: center;
314
+ }
315
+ :host([disposicion='escaparate']) .bienvenida .boton.principal {
316
+ background: #fff;
317
+ color: #111827;
318
+ }
319
+ :host([disposicion='escaparate']) .imagen {
320
+ flex: 0 1 46%;
321
+ align-self: center;
322
+ aspect-ratio: 3 / 2;
323
+ }
324
+
325
+ @media (max-width: 640px) {
326
+ :host {
327
+ --_alto: var(--lr-hero-alto-celular, 32rem);
328
+ }
329
+ .diapositiva {
330
+ flex-direction: column;
331
+ justify-content: flex-end;
332
+ align-items: stretch;
333
+ gap: 1.25rem;
334
+ padding: 1.5rem 1.375rem;
335
+ padding-bottom: max(1.5rem, var(--lr-carrusel-reserva-abajo, 0px));
336
+ }
337
+ .tinte::before {
338
+ background: linear-gradient(0deg, rgb(10 12 30 / 0.92) 0%, rgb(10 12 30 / 0.6) 45%, rgb(10 12 30 / 0.05) 85%);
339
+ }
340
+ .tinte::after {
341
+ background: linear-gradient(
342
+ 0deg,
343
+ color-mix(in srgb, var(--_oscuro) 96%, transparent) 0%,
344
+ color-mix(in srgb, var(--_color-primario) 85%, transparent) 50%,
345
+ color-mix(in srgb, var(--_oscuro) 55%, transparent) 100%
346
+ );
347
+ }
348
+ .texto,
349
+ .anuncio .texto {
350
+ flex: none;
351
+ }
352
+ .botones {
353
+ flex-direction: column;
354
+ align-self: stretch;
355
+ }
356
+ .boton {
357
+ width: 100%;
358
+ }
359
+ /* Portada: los anuncios no muestran imagen en celular. */
360
+ :host(:not([disposicion])) .anuncio .imagen,
361
+ :host([disposicion='portada']) .anuncio .imagen,
362
+ :host([ocultar-imagen-celular]) .anuncio .imagen {
363
+ display: none;
364
+ }
365
+ .imagen {
366
+ flex: none;
367
+ order: -1;
368
+ height: 9.5rem;
369
+ max-height: none;
370
+ }
371
+ :host([disposicion='escaparate']) .diapositiva {
372
+ justify-content: center;
373
+ text-align: center;
374
+ }
375
+ :host([disposicion='escaparate']) .texto {
376
+ align-items: center;
377
+ align-self: center;
378
+ }
379
+ :host([disposicion='escaparate']) .imagen {
380
+ flex: none;
381
+ aspect-ratio: auto;
382
+ align-self: stretch;
383
+ }
384
+ :host([disposicion='dividido']) .diapositiva {
385
+ gap: 0;
386
+ padding: 0.875rem;
387
+ padding-bottom: max(0.875rem, var(--lr-carrusel-reserva-abajo, 0px));
388
+ justify-content: flex-start;
389
+ }
390
+ :host([disposicion='dividido']) .texto {
391
+ flex: 1 0 auto;
392
+ justify-content: flex-start;
393
+ padding: 1.25rem;
394
+ }
395
+ :host([disposicion='dividido']) .anuncio:not(:has(.imagen)) .texto,
396
+ :host([ocultar-imagen-celular][disposicion='dividido']) .anuncio .texto {
397
+ justify-content: center;
398
+ }
399
+ :host([disposicion='dividido']) .imagen {
400
+ height: 11rem;
401
+ border-radius: calc(var(--_radio) * 1.25) calc(var(--_radio) * 1.25) 0 0;
402
+ box-shadow: none;
403
+ }
404
+ :host([disposicion='dividido']) .imagen + .texto,
405
+ :host([disposicion='dividido']) .texto:has(+ .imagen) {
406
+ border-radius: 0 0 calc(var(--_radio) * 1.25) calc(var(--_radio) * 1.25);
407
+ }
408
+ :host([ocultar-imagen-celular][disposicion='dividido']) .anuncio .texto {
409
+ border-radius: calc(var(--_radio) * 1.25);
410
+ }
411
+ :host([disposicion='dividido']) .imagen .logo {
412
+ width: 4rem;
413
+ height: 4rem;
414
+ border-radius: 0.875rem;
415
+ left: 1rem;
416
+ bottom: 1rem;
417
+ }
418
+ :host([disposicion='dividido']) .imagen.sin-imagen .logo {
419
+ left: calc(50% - 2rem);
420
+ bottom: calc(50% - 2rem);
421
+ }
422
+ }
423
+ `,
424
+ ];
425
+
426
+ @property({ reflect: true }) disposicion: DisposicionHero = 'portada';
427
+
428
+ /** Portada de la tienda: fondo fijo de todo el carrusel. */
429
+ @property() portada = '';
430
+
431
+ /** Portada para pantallas de hasta 640 px. */
432
+ @property({ attribute: 'portada-celular' }) portadaCelular = '';
433
+
434
+ /** Logo de la tienda (bienvenida de `dividido` y `escaparate`). */
435
+ @property() logo = '';
436
+
437
+ @property({ attribute: 'logo-alt' }) logoAlt = '';
438
+
439
+ @property() antetitulo = '';
440
+
441
+ @property() titulo = '';
442
+
443
+ @property() texto = '';
444
+
445
+ /** Hasta dos botones de la bienvenida (por ejemplo Productos y Eventos). */
446
+ @property({ attribute: false }) botones: BotonHero[] = [];
447
+
448
+ @property({ attribute: false }) anuncios: AnuncioHero[] = [];
449
+
450
+ /** Milisegundos entre diapositivas; `0` = no avanza solo. */
451
+ @property({ type: Number }) intervalo = 7000;
452
+
453
+ /** Oculta la imagen de los anuncios en celular también en `dividido` y `escaparate`. */
454
+ @property({ type: Boolean, reflect: true, attribute: 'ocultar-imagen-celular' }) ocultarImagenCelular = false;
455
+
456
+ @property() etiqueta = 'Inicio';
457
+
458
+ @state() private activa = 0;
459
+
460
+ override render() {
461
+ const escaparate = this.disposicion === 'escaparate';
462
+ return html`
463
+ <div class="marco" data-activa=${this.activa === 0 ? 'bienvenida' : 'anuncio'}>
464
+ ${this.portada
465
+ ? html`<picture class="fondo" aria-hidden="true">
466
+ ${this.portadaCelular ? html`<source media="(max-width: 640px)" srcset=${this.portadaCelular} />` : nothing}
467
+ <img src=${this.portada} alt="" fetchpriority="high" />
468
+ </picture>`
469
+ : nothing}
470
+ <div class="tinte" aria-hidden="true"></div>
471
+ <lr-carrusel
472
+ etiqueta=${this.etiqueta}
473
+ intervalo=${this.intervalo}
474
+ ?puntos-encima=${!escaparate}
475
+ ?pestanas=${escaparate}
476
+ efecto=${escaparate ? 'desvanecer' : 'deslizar'}
477
+ @cambio-diapositiva=${this.alCambiar}
478
+ >
479
+ ${this.bienvenida()} ${this.anuncios.map((a) => this.anuncio(a))}
480
+ </lr-carrusel>
481
+ </div>
482
+ `;
483
+ }
484
+
485
+ private bienvenida() {
486
+ const dividido = this.disposicion === 'dividido';
487
+ const logo = this.logo ? html`<img class="logo" src=${this.logo} alt=${this.logoAlt} />` : nothing;
488
+ const botones = this.botones.slice(0, 2);
489
+ return html`<article class="diapositiva bienvenida" data-pestana=${this.titulo || 'Bienvenida'} data-pestana-detalle="Inicio">
490
+ <div class="texto">
491
+ ${this.disposicion === 'escaparate' ? logo : nothing}
492
+ ${this.antetitulo ? html`<span class="antetitulo">${this.antetitulo}</span>` : nothing}
493
+ ${this.titulo ? html`<h2>${this.titulo}</h2>` : nothing}
494
+ ${this.texto ? html`<p>${this.texto}</p>` : nothing}
495
+ ${botones.length
496
+ ? html`<div class="botones">
497
+ ${botones.map(
498
+ (b, i) => html`<a
499
+ class="boton ${b.variante ?? (i === 0 ? 'principal' : 'secundario')}"
500
+ href=${b.href}
501
+ @click=${(e: MouseEvent) => this.alClic(e, b.href)}
502
+ >${b.texto}</a
503
+ >`
504
+ )}
505
+ </div>`
506
+ : nothing}
507
+ </div>
508
+ ${dividido
509
+ ? html`<div class="imagen ${this.portada ? '' : 'sin-imagen'}">
510
+ ${this.portada ? html`<img src=${this.portadaCelular || this.portada} alt="" />` : nothing} ${logo}
511
+ </div>`
512
+ : nothing}
513
+ </article>`;
514
+ }
515
+
516
+ private anuncio(a: AnuncioHero) {
517
+ return html`<article class="diapositiva anuncio" data-pestana=${a.titulo} data-pestana-detalle=${a.etiqueta || a.antetitulo || 'Anuncio'}>
518
+ <div class="texto">
519
+ ${a.etiqueta ? html`<span class="etiqueta">${a.etiqueta}</span>` : nothing}
520
+ ${a.antetitulo ? html`<span class="antetitulo">${a.antetitulo}</span>` : nothing}
521
+ <h2>${a.titulo}</h2>
522
+ ${a.texto ? html`<p>${a.texto}</p>` : nothing}
523
+ ${a.boton && a.href
524
+ ? html`<div class="botones">
525
+ <a class="boton" href=${a.href} @click=${(e: MouseEvent) => this.alClic(e, a.href!, a.id)}>${a.boton}</a>
526
+ </div>`
527
+ : nothing}
528
+ </div>
529
+ ${a.imagen
530
+ ? html`<div class="imagen">
531
+ <picture>
532
+ ${a.imagenCelular ? html`<source media="(max-width: 640px)" srcset=${a.imagenCelular} />` : nothing}
533
+ <img src=${a.imagen} alt=${a.imagenAlt ?? ''} loading="lazy" />
534
+ </picture>
535
+ </div>`
536
+ : nothing}
537
+ </article>`;
538
+ }
539
+
540
+ private alCambiar(evento: CustomEvent<DetalleCambioDiapositiva>) {
541
+ evento.stopPropagation();
542
+ this.activa = evento.detail.indice;
543
+ }
544
+
545
+ private alClic(evento: MouseEvent, href: string, id?: string) {
546
+ if (evento.ctrlKey || evento.metaKey) return;
547
+ evento.preventDefault();
548
+ emitir<DetalleClicHero>(this, 'clic-hero', { id, href });
549
+ }
550
+ }
551
+
552
+ declare global {
553
+ interface HTMLElementTagNameMap {
554
+ 'lr-hero': LrHero;
555
+ }
556
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { LrHero } from './hero.js';
2
+ export type { AnuncioHero, BotonHero, DetalleClicHero, DisposicionHero } from './hero.js';