@lit-roa/custom-header 0.5.1 → 0.5.3

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.
@@ -88,11 +88,11 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
88
88
  };
89
89
  this.alClicFuera = (e) => {
90
90
  if (this.abierta >= 0 && !e.composedPath().includes(this))
91
- this.abierta = -1;
91
+ this.cerrarSubmenu();
92
92
  };
93
93
  this.alEscape = (e) => {
94
94
  if (e.key === 'Escape' && this.abierta >= 0)
95
- this.abierta = -1;
95
+ this.cerrarSubmenu();
96
96
  };
97
97
  this.alScroll = () => {
98
98
  if (!this.pegajoso)
@@ -107,330 +107,341 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
107
107
  static { this.styles = [
108
108
  tokens,
109
109
  estilosBase,
110
- css `
111
- :host {
112
- display: block;
113
- --_fondo: var(--lr-header-fondo, #292929);
114
- --_texto: var(--lr-header-texto, #ffffff);
115
- --_alto: var(--lr-header-alto, 4.75rem);
116
- --_alto-compacto: var(--lr-header-alto-compacto, 3.5rem);
117
- position: relative;
118
- z-index: var(--lr-header-capa, 50);
119
- }
120
- :host([pegajoso]) {
121
- position: sticky;
122
- top: 0;
123
- transition: transform 0.25s ease;
124
- }
125
- :host([escondido]) {
126
- transform: translateY(-100%);
127
- }
128
- header {
129
- background: var(--_fondo);
130
- color: var(--_texto);
131
- transition: box-shadow 0.2s;
132
- }
133
- :host([compacto]) header {
134
- box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
135
- }
136
- :host([compacto]) .anuncio {
137
- display: none;
138
- }
139
- .fila {
140
- display: flex;
141
- align-items: center;
142
- gap: 1.5rem;
143
- max-width: var(--lr-header-ancho, 1200px);
144
- height: var(--_alto);
145
- margin: 0 auto;
146
- padding: 0 1.5rem;
147
- transition: height 0.2s;
148
- }
149
- :host([compacto]) .fila {
150
- height: var(--_alto-compacto);
151
- }
152
- button,
153
- a {
154
- font: inherit;
155
- color: inherit;
156
- }
157
- button {
158
- all: unset;
159
- box-sizing: border-box;
160
- cursor: pointer;
161
- }
162
- a {
163
- text-decoration: none;
164
- }
165
- button:focus-visible,
166
- a:focus-visible {
167
- outline: 2px solid currentColor;
168
- outline-offset: 2px;
169
- border-radius: 8px;
170
- }
171
- .logo {
172
- display: flex;
173
- align-items: center;
174
- gap: 0.625rem;
175
- flex: none;
176
- font-weight: 800;
177
- font-size: 1.1875rem;
178
- white-space: nowrap;
179
- }
180
- .logo img {
181
- height: 2.5rem;
182
- width: auto;
183
- max-width: 10rem;
184
- object-fit: contain;
185
- transition: height 0.2s;
186
- }
187
- :host([compacto]) .logo img {
188
- height: 2rem;
189
- }
190
- .fila nav > ul {
191
- display: flex;
192
- gap: 0.25rem;
193
- margin: 0;
194
- padding: 0;
195
- list-style: none;
196
- }
197
- .liga {
198
- display: flex;
199
- align-items: center;
200
- gap: 0.25rem;
201
- padding: 0.5rem 0.75rem;
202
- border-radius: 8px;
203
- font-weight: 600;
204
- font-size: 0.9375rem;
205
- white-space: nowrap;
206
- opacity: 0.9;
207
- }
208
- .liga:hover,
209
- .liga[aria-expanded='true'] {
210
- opacity: 1;
211
- background: rgb(255 255 255 / 0.1);
212
- }
213
- .liga svg {
214
- transition: transform 0.2s;
215
- }
216
- .liga[aria-expanded='true'] svg {
217
- transform: rotate(180deg);
218
- }
219
- li {
220
- position: relative;
221
- }
222
- .submenu {
223
- position: absolute;
224
- top: calc(100% + 0.5rem);
225
- left: 0;
226
- min-width: 13rem;
227
- margin: 0;
228
- padding: 0.5rem;
229
- list-style: none;
230
- background: #fff;
231
- color: #111827;
232
- border-radius: 12px;
233
- box-shadow: 0 18px 30px rgb(0 0 0 / 0.18);
234
- }
235
- .submenu a,
236
- .mega a {
237
- display: block;
238
- padding: 0.5rem 0.75rem;
239
- border-radius: 8px;
240
- }
241
- .submenu a:hover,
242
- .mega a:hover {
243
- background: #f3f4f6;
244
- }
245
- .mega {
246
- position: absolute;
247
- left: 0;
248
- right: 0;
249
- top: 100%;
250
- background: #fff;
251
- color: #111827;
252
- box-shadow: 0 18px 30px rgb(0 0 0 / 0.15);
253
- }
254
- .mega .dentro {
255
- display: grid;
256
- grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
257
- gap: 2rem;
258
- max-width: var(--lr-header-ancho, 1200px);
259
- margin: 0 auto;
260
- padding: 1.75rem 1.5rem;
261
- }
262
- .mega .dentro.con-promo {
263
- grid-template-columns: repeat(var(--_columnas), minmax(9rem, 1fr)) minmax(14rem, 1.3fr);
264
- }
265
- .mega h3 {
266
- margin: 0 0 0.375rem 0.75rem;
267
- font-size: 0.75rem;
268
- text-transform: uppercase;
269
- letter-spacing: 0.06em;
270
- color: #6b7280;
271
- }
272
- .mega ul {
273
- margin: 0;
274
- padding: 0;
275
- list-style: none;
276
- }
277
- .mega .promo {
278
- display: flex;
279
- flex-direction: column;
280
- justify-content: flex-end;
281
- gap: 0.25rem;
282
- min-height: 10rem;
283
- padding: 1.25rem;
284
- border-radius: 12px;
285
- background: var(--lr-header-promo-fondo, linear-gradient(135deg, #7c2d12, #c2410c)) center / cover;
286
- color: #fff;
287
- }
288
- .promo b {
289
- font-size: 1.1875rem;
290
- }
291
- .promo span {
292
- font-size: 0.8125rem;
293
- opacity: 0.9;
294
- }
295
- lr-buscador {
296
- flex: 1;
297
- min-width: 9rem;
298
- max-width: 22rem;
299
- margin-left: auto;
300
- --lr-color-texto: #111827;
301
- --lr-buscador-borde: transparent;
302
- }
303
- .acciones {
304
- display: flex;
305
- align-items: center;
306
- gap: 0.375rem;
307
- flex: none;
308
- }
309
- .solo-acciones {
310
- margin-left: auto;
311
- }
312
- .icono {
313
- position: relative;
314
- display: grid;
315
- place-items: center;
316
- width: 2.625rem;
317
- height: 2.625rem;
318
- border-radius: 999px;
319
- font-size: 1.375rem;
320
- }
321
- .icono:hover,
322
- .cuenta:hover {
323
- background: rgb(255 255 255 / 0.1);
324
- }
325
- .cuenta {
326
- display: flex;
327
- align-items: center;
328
- gap: 0.5rem;
329
- height: 2.625rem;
330
- padding: 0 0.75rem 0 0.5rem;
331
- border-radius: 999px;
332
- font-size: 0.875rem;
333
- font-weight: 600;
334
- }
335
- .nombre-usuario {
336
- max-width: 9rem;
337
- overflow: hidden;
338
- text-overflow: ellipsis;
339
- white-space: nowrap;
340
- }
341
- .cuenta svg {
342
- font-size: 1.25rem;
343
- }
344
- .avatar {
345
- display: grid;
346
- place-items: center;
347
- width: 1.875rem;
348
- height: 1.875rem;
349
- border-radius: 999px;
350
- background: var(--lr-header-avatar, #fbbf24);
351
- color: #292929;
352
- font-size: 0.75rem;
353
- font-weight: 800;
354
- }
355
- .globo {
356
- position: absolute;
357
- top: 0.1875rem;
358
- right: 0;
359
- min-width: 1.1875rem;
360
- height: 1.1875rem;
361
- padding: 0 0.3125rem;
362
- border-radius: 999px;
363
- border: 2px solid var(--_fondo);
364
- background: var(--lr-header-globo, #ea580c);
365
- color: #fff;
366
- font-size: 0.6875rem;
367
- font-weight: 800;
368
- line-height: 0.8rem;
369
- text-align: center;
370
- }
371
- .solo-lectores {
372
- position: absolute;
373
- width: 1px;
374
- height: 1px;
375
- overflow: hidden;
376
- clip: rect(0 0 0 0);
377
- }
378
-
379
- /* Celular */
380
- .celular .fila {
381
- gap: 0.25rem;
382
- padding: 0 0.5rem;
383
- height: 3.75rem;
384
- }
385
- :host([compacto]) .celular .fila {
386
- height: 3.25rem;
387
- }
388
- .celular .logo {
389
- flex: 1;
390
- justify-content: center;
391
- font-size: 1.0625rem;
392
- min-width: 0;
393
- }
394
- .celular .logo img {
395
- height: 2rem;
396
- }
397
- .celular .acciones {
398
- gap: 0;
399
- }
400
- .celular .barra-buscar {
401
- padding: 0 0.75rem 0.75rem;
402
- }
403
- :host([compacto]) .celular .barra-buscar {
404
- display: none;
405
- }
406
- .celular lr-buscador {
407
- max-width: none;
408
- margin: 0;
409
- }
410
-
411
- /* El menú de celular es lr-menu-lateral: su cabecera ya toma --lr-header-fondo y --lr-header-texto */
412
- .pie {
413
- display: grid;
414
- gap: 0.75rem;
415
- }
416
- .boton-cuenta {
417
- display: flex;
418
- justify-content: center;
419
- align-items: center;
420
- gap: 0.5rem;
421
- height: 2.875rem;
422
- border-radius: 10px;
423
- background: var(--_fondo);
424
- color: var(--_texto);
425
- font-weight: 700;
426
- }
427
- @media (prefers-reduced-motion: reduce) {
428
- :host([pegajoso]),
429
- .fila {
430
- transition: none;
431
- animation: none;
432
- }
433
- }
110
+ css `
111
+ :host {
112
+ display: block;
113
+ --_fondo: var(--lr-header-fondo, #292929);
114
+ --_texto: var(--lr-header-texto, #ffffff);
115
+ --_alto: var(--lr-header-alto, 4.75rem);
116
+ --_alto-compacto: var(--lr-header-alto-compacto, 3.5rem);
117
+ position: relative;
118
+ z-index: var(--lr-header-capa, 50);
119
+ }
120
+ :host([pegajoso]) {
121
+ position: sticky;
122
+ top: 0;
123
+ transition: transform 0.25s ease;
124
+ }
125
+ :host([escondido]) {
126
+ transform: translateY(-100%);
127
+ }
128
+ header {
129
+ background: var(--_fondo);
130
+ color: var(--_texto);
131
+ transition: box-shadow 0.2s;
132
+ }
133
+ :host([compacto]) header {
134
+ box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
135
+ }
136
+ :host([compacto]) .anuncio {
137
+ display: none;
138
+ }
139
+ .fila {
140
+ display: flex;
141
+ align-items: center;
142
+ gap: 1.5rem;
143
+ max-width: var(--lr-header-ancho, 1200px);
144
+ height: var(--_alto);
145
+ margin: 0 auto;
146
+ padding: 0 1.5rem;
147
+ transition: height 0.2s;
148
+ }
149
+ :host([compacto]) .fila {
150
+ height: var(--_alto-compacto);
151
+ }
152
+ button,
153
+ a {
154
+ font: inherit;
155
+ color: inherit;
156
+ }
157
+ button {
158
+ all: unset;
159
+ box-sizing: border-box;
160
+ cursor: pointer;
161
+ }
162
+ a {
163
+ text-decoration: none;
164
+ }
165
+ button:focus-visible,
166
+ a:focus-visible {
167
+ outline: 2px solid currentColor;
168
+ outline-offset: 2px;
169
+ border-radius: 8px;
170
+ }
171
+ .logo {
172
+ display: flex;
173
+ align-items: center;
174
+ gap: 0.625rem;
175
+ flex: none;
176
+ font-weight: 800;
177
+ font-size: 1.1875rem;
178
+ white-space: nowrap;
179
+ }
180
+ .logo img {
181
+ height: 2.5rem;
182
+ width: auto;
183
+ max-width: 10rem;
184
+ object-fit: contain;
185
+ transition: height 0.2s;
186
+ }
187
+ :host([compacto]) .logo img {
188
+ height: 2rem;
189
+ }
190
+ .fila nav > ul {
191
+ display: flex;
192
+ gap: 0.25rem;
193
+ margin: 0;
194
+ padding: 0;
195
+ list-style: none;
196
+ }
197
+ .liga {
198
+ display: flex;
199
+ align-items: center;
200
+ gap: 0.25rem;
201
+ padding: 0.5rem 0.75rem;
202
+ border-radius: 8px;
203
+ font-weight: 600;
204
+ font-size: 0.9375rem;
205
+ white-space: nowrap;
206
+ opacity: 0.9;
207
+ }
208
+ .liga:hover,
209
+ .liga[aria-expanded='true'] {
210
+ opacity: 1;
211
+ background: rgb(255 255 255 / 0.1);
212
+ }
213
+ .liga svg {
214
+ transition: transform 0.2s;
215
+ }
216
+ .liga[aria-expanded='true'] svg {
217
+ transform: rotate(180deg);
218
+ }
219
+ li {
220
+ position: relative;
221
+ }
222
+ .submenu {
223
+ position: absolute;
224
+ top: calc(100% + 0.5rem);
225
+ left: 0;
226
+ min-width: 13rem;
227
+ margin: 0;
228
+ padding: 0.5rem;
229
+ list-style: none;
230
+ background: #fff;
231
+ color: #111827;
232
+ border-radius: 12px;
233
+ box-shadow: 0 18px 30px rgb(0 0 0 / 0.18);
234
+ }
235
+ /* Puente invisible sobre el hueco: el mouse sigue dentro del <li> al bajar al submenú. */
236
+ .submenu::before {
237
+ content: '';
238
+ position: absolute;
239
+ left: 0;
240
+ right: 0;
241
+ bottom: 100%;
242
+ height: 0.75rem;
243
+ }
244
+ .submenu a,
245
+ .mega a {
246
+ display: block;
247
+ padding: 0.5rem 0.75rem;
248
+ border-radius: 8px;
249
+ }
250
+ .submenu a:hover,
251
+ .mega a:hover {
252
+ background: #f3f4f6;
253
+ }
254
+ .mega {
255
+ position: absolute;
256
+ left: 0;
257
+ right: 0;
258
+ top: 100%;
259
+ background: #fff;
260
+ color: #111827;
261
+ box-shadow: 0 18px 30px rgb(0 0 0 / 0.15);
262
+ }
263
+ .mega .dentro {
264
+ display: grid;
265
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
266
+ gap: 2rem;
267
+ max-width: var(--lr-header-ancho, 1200px);
268
+ margin: 0 auto;
269
+ padding: 1.75rem 1.5rem;
270
+ }
271
+ .mega .dentro.con-promo {
272
+ grid-template-columns: repeat(var(--_columnas), minmax(9rem, 1fr)) minmax(14rem, 1.3fr);
273
+ }
274
+ .mega h3 {
275
+ margin: 0 0 0.375rem 0.75rem;
276
+ font-size: 0.75rem;
277
+ text-transform: uppercase;
278
+ letter-spacing: 0.06em;
279
+ color: #6b7280;
280
+ }
281
+ .mega ul {
282
+ margin: 0;
283
+ padding: 0;
284
+ list-style: none;
285
+ }
286
+ .mega .promo {
287
+ display: flex;
288
+ flex-direction: column;
289
+ justify-content: flex-end;
290
+ gap: 0.25rem;
291
+ min-height: 10rem;
292
+ padding: 1.25rem;
293
+ border-radius: 12px;
294
+ background: var(--lr-header-promo-fondo, linear-gradient(135deg, #7c2d12, #c2410c)) center / cover;
295
+ color: #fff;
296
+ }
297
+ .promo b {
298
+ font-size: 1.1875rem;
299
+ }
300
+ .promo span {
301
+ font-size: 0.8125rem;
302
+ opacity: 0.9;
303
+ }
304
+ lr-buscador {
305
+ flex: 1;
306
+ min-width: 9rem;
307
+ max-width: 22rem;
308
+ margin-left: auto;
309
+ --lr-color-texto: #111827;
310
+ --lr-buscador-borde: transparent;
311
+ }
312
+ .acciones {
313
+ display: flex;
314
+ align-items: center;
315
+ gap: 0.375rem;
316
+ flex: none;
317
+ }
318
+ .solo-acciones {
319
+ margin-left: auto;
320
+ }
321
+ .icono {
322
+ position: relative;
323
+ display: grid;
324
+ place-items: center;
325
+ width: 2.625rem;
326
+ height: 2.625rem;
327
+ border-radius: 999px;
328
+ font-size: 1.375rem;
329
+ }
330
+ .icono:hover,
331
+ .cuenta:hover {
332
+ background: rgb(255 255 255 / 0.1);
333
+ }
334
+ .cuenta {
335
+ display: flex;
336
+ align-items: center;
337
+ gap: 0.5rem;
338
+ height: 2.625rem;
339
+ padding: 0 0.75rem 0 0.5rem;
340
+ border-radius: 999px;
341
+ font-size: 0.875rem;
342
+ font-weight: 600;
343
+ }
344
+ .nombre-usuario {
345
+ max-width: 9rem;
346
+ overflow: hidden;
347
+ text-overflow: ellipsis;
348
+ white-space: nowrap;
349
+ }
350
+ .cuenta svg {
351
+ font-size: 1.25rem;
352
+ }
353
+ .avatar {
354
+ display: grid;
355
+ place-items: center;
356
+ width: 1.875rem;
357
+ height: 1.875rem;
358
+ border-radius: 999px;
359
+ background: var(--lr-header-avatar, #fbbf24);
360
+ color: #292929;
361
+ font-size: 0.75rem;
362
+ font-weight: 800;
363
+ }
364
+ .globo {
365
+ position: absolute;
366
+ top: 0.1875rem;
367
+ right: 0;
368
+ min-width: 1.1875rem;
369
+ height: 1.1875rem;
370
+ padding: 0 0.3125rem;
371
+ border-radius: 999px;
372
+ border: 2px solid var(--_fondo);
373
+ background: var(--lr-header-globo, #ea580c);
374
+ color: #fff;
375
+ font-size: 0.6875rem;
376
+ font-weight: 800;
377
+ line-height: 0.8rem;
378
+ text-align: center;
379
+ }
380
+ .solo-lectores {
381
+ position: absolute;
382
+ width: 1px;
383
+ height: 1px;
384
+ overflow: hidden;
385
+ clip: rect(0 0 0 0);
386
+ }
387
+
388
+ /* Celular */
389
+ .celular .fila {
390
+ gap: 0.25rem;
391
+ padding: 0 0.5rem;
392
+ height: 3.75rem;
393
+ }
394
+ :host([compacto]) .celular .fila {
395
+ height: 3.25rem;
396
+ }
397
+ /* El logo va pegado al botón del menú, no centrado */
398
+ .celular .logo {
399
+ flex: 1;
400
+ justify-content: flex-start;
401
+ margin-left: 0.25rem;
402
+ font-size: 1.0625rem;
403
+ min-width: 0;
404
+ }
405
+ .celular .logo img {
406
+ height: 2rem;
407
+ }
408
+ .celular .acciones {
409
+ gap: 0;
410
+ }
411
+ .celular .barra-buscar {
412
+ padding: 0 0.75rem 0.75rem;
413
+ }
414
+ :host([compacto]) .celular .barra-buscar {
415
+ display: none;
416
+ }
417
+ .celular lr-buscador {
418
+ max-width: none;
419
+ margin: 0;
420
+ }
421
+
422
+ /* El menú de celular es lr-menu-lateral: su cabecera ya toma --lr-header-fondo y --lr-header-texto */
423
+ .pie {
424
+ display: grid;
425
+ gap: 0.75rem;
426
+ }
427
+ .boton-cuenta {
428
+ display: flex;
429
+ justify-content: center;
430
+ align-items: center;
431
+ gap: 0.5rem;
432
+ height: 2.875rem;
433
+ border-radius: 10px;
434
+ background: var(--_fondo);
435
+ color: var(--_texto);
436
+ font-weight: 700;
437
+ }
438
+ @media (prefers-reduced-motion: reduce) {
439
+ :host([pegajoso]),
440
+ .fila {
441
+ transition: none;
442
+ animation: none;
443
+ }
444
+ }
434
445
  `,
435
446
  ]; }
436
447
  connectedCallback() {
@@ -447,13 +458,14 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
447
458
  window.removeEventListener('scroll', this.alScroll);
448
459
  document.removeEventListener('click', this.alClicFuera);
449
460
  document.removeEventListener('keydown', this.alEscape);
461
+ clearTimeout(this.cierre);
450
462
  }
451
463
  render() {
452
- return html `<header class=${this.celular ? 'celular' : ''} part="header">
453
- <div class="anuncio" ?hidden=${!this.conAnuncio}>
454
- <slot name="anuncio" @slotchange=${this.alCambiarAnuncio}></slot>
455
- </div>
456
- ${this.celular ? this.vistaCelular() : this.vistaEscritorio()}
464
+ return html `<header class=${this.celular ? 'celular' : ''} part="header">
465
+ <div class="anuncio" ?hidden=${!this.conAnuncio}>
466
+ <slot name="anuncio" @slotchange=${this.alCambiarAnuncio}></slot>
467
+ </div>
468
+ ${this.celular ? this.vistaCelular() : this.vistaEscritorio()}
457
469
  </header>`;
458
470
  }
459
471
  /** Abre el menú de celular. */
@@ -463,96 +475,96 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
463
475
  /** Cierra el menú de celular y los submenús. */
464
476
  cerrarMenu() {
465
477
  this.menu?.cerrar();
466
- this.abierta = -1;
478
+ this.cerrarSubmenu();
467
479
  }
468
480
  vistaEscritorio() {
469
481
  const liga = this.ligas[this.abierta];
470
- return html `<div class="fila">
471
- ${this.logoTpl()}
482
+ return html `<div class="fila">
483
+ ${this.logoTpl()}
472
484
  ${this.ligas.length
473
- ? html `<nav aria-label="Principal">
474
- <ul>
475
- ${this.ligas.map((l, i) => this.ligaEscritorio(l, i))}
476
- </ul>
485
+ ? html `<nav aria-label="Principal">
486
+ <ul>
487
+ ${this.ligas.map((l, i) => this.ligaEscritorio(l, i))}
488
+ </ul>
477
489
  </nav>`
478
- : nothing}
479
- ${this.buscadorTpl()}
480
- <div class="acciones ${this.sinBuscador ? 'solo-acciones' : ''}">${this.avisosTpl()} ${this.cuentaTpl()} ${this.carritoTpl()}</div>
481
- </div>
490
+ : nothing}
491
+ ${this.buscadorTpl()}
492
+ <div class="acciones ${this.sinBuscador ? 'solo-acciones' : ''}">${this.avisosTpl()} ${this.cuentaTpl()} ${this.carritoTpl()}</div>
493
+ </div>
482
494
  ${liga?.columnas?.length ? this.megaTpl(liga) : nothing}`;
483
495
  }
484
496
  vistaCelular() {
485
- return html `<div class="fila">
486
- <button class="icono" aria-label="Abrir menú" aria-haspopup="dialog" @click=${this.abrirMenu}>${iconoMenu2}</button>
487
- ${this.logoTpl()}
488
- <div class="acciones">${this.avisosTpl()} ${this.carritoTpl()}</div>
489
- </div>
490
- ${this.sinBuscador ? nothing : html `<div class="barra-buscar">${this.buscadorTpl()}</div>`}
491
- <lr-menu-lateral
492
- .ligas=${this.ligasMenu()}
493
- logo=${this.logo}
494
- nombre=${this.nombre}
495
- href-inicio=${this.hrefInicio}
496
- @cerrar=${() => (this.abierta = -1)}
497
- >
498
- <div slot="pie" class="pie">
499
- <slot name="menu-pie"></slot>
497
+ return html `<div class="fila">
498
+ <button class="icono" aria-label="Abrir menú" aria-haspopup="dialog" @click=${this.abrirMenu}>${iconoMenu2}</button>
499
+ ${this.logoTpl()}
500
+ <div class="acciones">${this.avisosTpl()} ${this.carritoTpl()}</div>
501
+ </div>
502
+ ${this.sinBuscador ? nothing : html `<div class="barra-buscar">${this.buscadorTpl()}</div>`}
503
+ <lr-menu-lateral
504
+ .ligas=${this.ligasMenu()}
505
+ logo=${this.logo}
506
+ nombre=${this.nombre}
507
+ href-inicio=${this.hrefInicio}
508
+ @cerrar=${() => (this.abierta = -1)}
509
+ >
510
+ <div slot="pie" class="pie">
511
+ <slot name="menu-pie"></slot>
500
512
  ${this.sinCuenta
501
513
  ? nothing
502
- : html `<button class="boton-cuenta" @click=${this.alCuenta}>
514
+ : html `<button class="boton-cuenta" @click=${this.alCuenta}>
503
515
  ${this.usuario
504
516
  ? html `<span class="avatar" aria-hidden="true">${this.iniciales()}</span> ${this.textoCuenta}`
505
- : html `${iconoUser} ${this.textoEntrar}`}
506
- </button>`}
507
- </div>
517
+ : html `${iconoUser} ${this.textoEntrar}`}
518
+ </button>`}
519
+ </div>
508
520
  </lr-menu-lateral>`;
509
521
  }
510
522
  logoTpl() {
511
523
  const inicio = { texto: this.nombre || 'Inicio', href: this.hrefInicio, id: 'inicio' };
512
- return html `<a class="logo" href=${this.hrefInicio} part="logo" @click=${(e) => this.alNavegar(e, inicio)}>
513
- ${this.logo ? html `<img src=${this.logo} alt=${this.nombre ? '' : 'Inicio'} />` : nothing}
514
- ${this.nombre ? html `<span>${this.nombre}</span>` : nothing}
524
+ return html `<a class="logo" href=${this.hrefInicio} part="logo" @click=${(e) => this.alNavegar(e, inicio)}>
525
+ ${this.logo ? html `<img src=${this.logo} alt=${this.nombre ? '' : 'Inicio'} />` : nothing}
526
+ ${this.nombre ? html `<span>${this.nombre}</span>` : nothing}
515
527
  </a>`;
516
528
  }
517
529
  buscadorTpl() {
518
530
  if (this.sinBuscador)
519
531
  return nothing;
520
- return html `<lr-buscador
521
- placeholder=${this.placeholderBuscador}
522
- .sugerencias=${this.sugerencias}
523
- ?cargando=${this.buscando}
524
- ver-todo
532
+ return html `<lr-buscador
533
+ placeholder=${this.placeholderBuscador}
534
+ .sugerencias=${this.sugerencias}
535
+ ?cargando=${this.buscando}
536
+ ver-todo
525
537
  ></lr-buscador>`;
526
538
  }
527
539
  /** Cuenta en escritorio; en celular va en el menú lateral. */
528
540
  cuentaTpl() {
529
541
  if (this.sinCuenta)
530
542
  return nothing;
531
- return html `<button class="cuenta" @click=${this.alCuenta}>
543
+ return html `<button class="cuenta" @click=${this.alCuenta}>
532
544
  ${this.usuario
533
545
  ? html `<span class="avatar" aria-hidden="true">${this.iniciales()}</span><span class="solo-lectores">${this.textoCuenta}:</span><span class="nombre-usuario">${this.usuario.split(/\s+/)[0]}</span>`
534
- : html `${iconoUser}${this.textoEntrar}`}
546
+ : html `${iconoUser}${this.textoEntrar}`}
535
547
  </button>`;
536
548
  }
537
549
  avisosTpl() {
538
550
  if (!this.conAvisos)
539
551
  return nothing;
540
552
  const n = Math.max(0, Math.floor(this.avisos));
541
- return html `<button
542
- class="icono"
543
- aria-label=${n > 0 ? `${this.textoAvisos}, ${n} sin leer` : this.textoAvisos}
544
- @click=${this.alAvisos}
545
- >
546
- ${iconoBell}${n > 0 ? html `<span class="globo" aria-hidden="true">${n > 99 ? '99+' : n}</span>` : nothing}
553
+ return html `<button
554
+ class="icono"
555
+ aria-label=${n > 0 ? `${this.textoAvisos}, ${n} sin leer` : this.textoAvisos}
556
+ @click=${this.alAvisos}
557
+ >
558
+ ${iconoBell}${n > 0 ? html `<span class="globo" aria-hidden="true">${n > 99 ? '99+' : n}</span>` : nothing}
547
559
  </button>`;
548
560
  }
549
561
  carritoTpl() {
550
562
  if (this.sinCarrito)
551
563
  return nothing;
552
- return html `<slot name="carrito">
553
- <button class="icono" aria-label="Carrito, ${this.piezas} ${this.piezas === 1 ? 'pieza' : 'piezas'}" @click=${this.alCarrito}>
554
- ${iconoShoppingBag}${this.piezas > 0 ? html `<span class="globo" aria-hidden="true">${this.piezas > 99 ? '99+' : this.piezas}</span>` : nothing}
555
- </button>
564
+ return html `<slot name="carrito">
565
+ <button class="icono" aria-label="Carrito, ${this.piezas} ${this.piezas === 1 ? 'pieza' : 'piezas'}" @click=${this.alCarrito}>
566
+ ${iconoShoppingBag}${this.piezas > 0 ? html `<span class="globo" aria-hidden="true">${this.piezas > 99 ? '99+' : this.piezas}</span>` : nothing}
567
+ </button>
556
568
  </slot>`;
557
569
  }
558
570
  ligaEscritorio(liga, i) {
@@ -561,37 +573,37 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
561
573
  return html `<li><a class="liga" href=${liga.href || '#'} @click=${(e) => this.alNavegar(e, liga)}>${liga.texto}</a></li>`;
562
574
  }
563
575
  const abierta = this.abierta === i;
564
- return html `<li @mouseenter=${() => (this.abierta = i)} @mouseleave=${() => this.alSalirLiga(i)}>
565
- <button class="liga" aria-expanded=${abierta} @click=${(e) => this.alClicLiga(e, i)}>${liga.texto} ${iconoChevronDown}</button>
576
+ return html `<li @mouseenter=${() => this.abrirSubmenu(i)} @mouseleave=${() => this.alSalirLiga(i)}>
577
+ <button class="liga" aria-expanded=${abierta} @click=${(e) => this.alClicLiga(e, i)}>${liga.texto} ${iconoChevronDown}</button>
566
578
  ${abierta && !liga.columnas?.length
567
- ? html `<ul class="submenu">
568
- ${liga.hijos.map((h) => html `<li><a href=${h.href || '#'} @click=${(e) => this.alNavegar(e, h)}>${h.texto}</a></li>`)}
579
+ ? html `<ul class="submenu">
580
+ ${liga.hijos.map((h) => html `<li><a href=${h.href || '#'} @click=${(e) => this.alNavegar(e, h)}>${h.texto}</a></li>`)}
569
581
  </ul>`
570
- : nothing}
582
+ : nothing}
571
583
  </li>`;
572
584
  }
573
585
  megaTpl(liga) {
574
586
  const promo = liga.promo;
575
587
  const indice = this.abierta;
576
- return html `<div class="mega" @mouseenter=${() => (this.abierta = indice)} @mouseleave=${() => (this.abierta = -1)}>
577
- <div class="dentro ${promo ? 'con-promo' : ''}" style="--_columnas: ${liga.columnas.length}">
578
- ${liga.columnas.map((c) => html `<div>
579
- <h3>${c.titulo}</h3>
580
- <ul>
581
- ${c.ligas.map((l) => html `<li><a href=${l.href || '#'} @click=${(e) => this.alNavegar(e, l)}>${l.texto}</a></li>`)}
582
- </ul>
583
- </div>`)}
588
+ return html `<div class="mega" @mouseenter=${() => this.abrirSubmenu(indice)} @mouseleave=${() => this.cerrarConRetraso()}>
589
+ <div class="dentro ${promo ? 'con-promo' : ''}" style="--_columnas: ${liga.columnas.length}">
590
+ ${liga.columnas.map((c) => html `<div>
591
+ <h3>${c.titulo}</h3>
592
+ <ul>
593
+ ${c.ligas.map((l) => html `<li><a href=${l.href || '#'} @click=${(e) => this.alNavegar(e, l)}>${l.texto}</a></li>`)}
594
+ </ul>
595
+ </div>`)}
584
596
  ${promo
585
- ? html `<a
586
- class="promo"
587
- href=${promo.href || '#'}
588
- style=${promo.imagen ? `background-image: linear-gradient(0deg, rgb(0 0 0 / .55), rgb(0 0 0 / 0) 70%), url(${promo.imagen})` : ''}
589
- @click=${(e) => this.alNavegar(e, { texto: promo.titulo, href: promo.href, id: promo.id })}
590
- >
591
- <b>${promo.titulo}</b>${promo.texto ? html `<span>${promo.texto}</span>` : nothing}
597
+ ? html `<a
598
+ class="promo"
599
+ href=${promo.href || '#'}
600
+ style=${promo.imagen ? `background-image: linear-gradient(0deg, rgb(0 0 0 / .55), rgb(0 0 0 / 0) 70%), url(${promo.imagen})` : ''}
601
+ @click=${(e) => this.alNavegar(e, { texto: promo.titulo, href: promo.href, id: promo.id })}
602
+ >
603
+ <b>${promo.titulo}</b>${promo.texto ? html `<span>${promo.texto}</span>` : nothing}
592
604
  </a>`
593
- : nothing}
594
- </div>
605
+ : nothing}
606
+ </div>
595
607
  </div>`;
596
608
  }
597
609
  /** Ligas para el menú de celular: el mega menú se aplana con sus títulos como grupos. */
@@ -621,14 +633,27 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
621
633
  alClicLiga(evento, i) {
622
634
  // Con mouse el hover ya lo abrió: el clic no debe cerrarlo. Con teclado (detail 0) alterna.
623
635
  if (evento.detail === 0)
624
- this.abierta = this.abierta === i ? -1 : i;
636
+ this.abierta === i ? this.cerrarSubmenu() : this.abrirSubmenu(i);
625
637
  else
626
- this.abierta = i;
638
+ this.abrirSubmenu(i);
627
639
  }
628
640
  alSalirLiga(i) {
629
641
  // El mega menú vive fuera del <li>; se cierra cuando el mouse sale de él.
630
642
  if (!this.ligas[i]?.columnas?.length)
631
- this.abierta = -1;
643
+ this.cerrarConRetraso();
644
+ }
645
+ abrirSubmenu(i) {
646
+ clearTimeout(this.cierre);
647
+ this.abierta = i;
648
+ }
649
+ cerrarSubmenu() {
650
+ clearTimeout(this.cierre);
651
+ this.abierta = -1;
652
+ }
653
+ /** Cierra tras un momento, para que el mouse pueda cruzar en diagonal o por un hueco sin perder el submenú. */
654
+ cerrarConRetraso() {
655
+ clearTimeout(this.cierre);
656
+ this.cierre = setTimeout(() => (this.abierta = -1), 250);
632
657
  }
633
658
  alCambiarAnuncio(e) {
634
659
  this.conAnuncio = e.target.assignedElements().length > 0;