@lit-roa/custom-header 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,339 @@ 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
+ .celular .logo {
398
+ flex: 1;
399
+ justify-content: center;
400
+ font-size: 1.0625rem;
401
+ min-width: 0;
402
+ }
403
+ .celular .logo img {
404
+ height: 2rem;
405
+ }
406
+ .celular .acciones {
407
+ gap: 0;
408
+ }
409
+ .celular .barra-buscar {
410
+ padding: 0 0.75rem 0.75rem;
411
+ }
412
+ :host([compacto]) .celular .barra-buscar {
413
+ display: none;
414
+ }
415
+ .celular lr-buscador {
416
+ max-width: none;
417
+ margin: 0;
418
+ }
419
+
420
+ /* El menú de celular es lr-menu-lateral: su cabecera ya toma --lr-header-fondo y --lr-header-texto */
421
+ .pie {
422
+ display: grid;
423
+ gap: 0.75rem;
424
+ }
425
+ .boton-cuenta {
426
+ display: flex;
427
+ justify-content: center;
428
+ align-items: center;
429
+ gap: 0.5rem;
430
+ height: 2.875rem;
431
+ border-radius: 10px;
432
+ background: var(--_fondo);
433
+ color: var(--_texto);
434
+ font-weight: 700;
435
+ }
436
+ @media (prefers-reduced-motion: reduce) {
437
+ :host([pegajoso]),
438
+ .fila {
439
+ transition: none;
440
+ animation: none;
441
+ }
442
+ }
434
443
  `,
435
444
  ]; }
436
445
  connectedCallback() {
@@ -447,13 +456,14 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
447
456
  window.removeEventListener('scroll', this.alScroll);
448
457
  document.removeEventListener('click', this.alClicFuera);
449
458
  document.removeEventListener('keydown', this.alEscape);
459
+ clearTimeout(this.cierre);
450
460
  }
451
461
  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()}
462
+ return html `<header class=${this.celular ? 'celular' : ''} part="header">
463
+ <div class="anuncio" ?hidden=${!this.conAnuncio}>
464
+ <slot name="anuncio" @slotchange=${this.alCambiarAnuncio}></slot>
465
+ </div>
466
+ ${this.celular ? this.vistaCelular() : this.vistaEscritorio()}
457
467
  </header>`;
458
468
  }
459
469
  /** Abre el menú de celular. */
@@ -463,96 +473,96 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
463
473
  /** Cierra el menú de celular y los submenús. */
464
474
  cerrarMenu() {
465
475
  this.menu?.cerrar();
466
- this.abierta = -1;
476
+ this.cerrarSubmenu();
467
477
  }
468
478
  vistaEscritorio() {
469
479
  const liga = this.ligas[this.abierta];
470
- return html `<div class="fila">
471
- ${this.logoTpl()}
480
+ return html `<div class="fila">
481
+ ${this.logoTpl()}
472
482
  ${this.ligas.length
473
- ? html `<nav aria-label="Principal">
474
- <ul>
475
- ${this.ligas.map((l, i) => this.ligaEscritorio(l, i))}
476
- </ul>
483
+ ? html `<nav aria-label="Principal">
484
+ <ul>
485
+ ${this.ligas.map((l, i) => this.ligaEscritorio(l, i))}
486
+ </ul>
477
487
  </nav>`
478
- : nothing}
479
- ${this.buscadorTpl()}
480
- <div class="acciones ${this.sinBuscador ? 'solo-acciones' : ''}">${this.avisosTpl()} ${this.cuentaTpl()} ${this.carritoTpl()}</div>
481
- </div>
488
+ : nothing}
489
+ ${this.buscadorTpl()}
490
+ <div class="acciones ${this.sinBuscador ? 'solo-acciones' : ''}">${this.avisosTpl()} ${this.cuentaTpl()} ${this.carritoTpl()}</div>
491
+ </div>
482
492
  ${liga?.columnas?.length ? this.megaTpl(liga) : nothing}`;
483
493
  }
484
494
  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>
495
+ return html `<div class="fila">
496
+ <button class="icono" aria-label="Abrir menú" aria-haspopup="dialog" @click=${this.abrirMenu}>${iconoMenu2}</button>
497
+ ${this.logoTpl()}
498
+ <div class="acciones">${this.avisosTpl()} ${this.carritoTpl()}</div>
499
+ </div>
500
+ ${this.sinBuscador ? nothing : html `<div class="barra-buscar">${this.buscadorTpl()}</div>`}
501
+ <lr-menu-lateral
502
+ .ligas=${this.ligasMenu()}
503
+ logo=${this.logo}
504
+ nombre=${this.nombre}
505
+ href-inicio=${this.hrefInicio}
506
+ @cerrar=${() => (this.abierta = -1)}
507
+ >
508
+ <div slot="pie" class="pie">
509
+ <slot name="menu-pie"></slot>
500
510
  ${this.sinCuenta
501
511
  ? nothing
502
- : html `<button class="boton-cuenta" @click=${this.alCuenta}>
512
+ : html `<button class="boton-cuenta" @click=${this.alCuenta}>
503
513
  ${this.usuario
504
514
  ? html `<span class="avatar" aria-hidden="true">${this.iniciales()}</span> ${this.textoCuenta}`
505
- : html `${iconoUser} ${this.textoEntrar}`}
506
- </button>`}
507
- </div>
515
+ : html `${iconoUser} ${this.textoEntrar}`}
516
+ </button>`}
517
+ </div>
508
518
  </lr-menu-lateral>`;
509
519
  }
510
520
  logoTpl() {
511
521
  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}
522
+ return html `<a class="logo" href=${this.hrefInicio} part="logo" @click=${(e) => this.alNavegar(e, inicio)}>
523
+ ${this.logo ? html `<img src=${this.logo} alt=${this.nombre ? '' : 'Inicio'} />` : nothing}
524
+ ${this.nombre ? html `<span>${this.nombre}</span>` : nothing}
515
525
  </a>`;
516
526
  }
517
527
  buscadorTpl() {
518
528
  if (this.sinBuscador)
519
529
  return nothing;
520
- return html `<lr-buscador
521
- placeholder=${this.placeholderBuscador}
522
- .sugerencias=${this.sugerencias}
523
- ?cargando=${this.buscando}
524
- ver-todo
530
+ return html `<lr-buscador
531
+ placeholder=${this.placeholderBuscador}
532
+ .sugerencias=${this.sugerencias}
533
+ ?cargando=${this.buscando}
534
+ ver-todo
525
535
  ></lr-buscador>`;
526
536
  }
527
537
  /** Cuenta en escritorio; en celular va en el menú lateral. */
528
538
  cuentaTpl() {
529
539
  if (this.sinCuenta)
530
540
  return nothing;
531
- return html `<button class="cuenta" @click=${this.alCuenta}>
541
+ return html `<button class="cuenta" @click=${this.alCuenta}>
532
542
  ${this.usuario
533
543
  ? 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}`}
544
+ : html `${iconoUser}${this.textoEntrar}`}
535
545
  </button>`;
536
546
  }
537
547
  avisosTpl() {
538
548
  if (!this.conAvisos)
539
549
  return nothing;
540
550
  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}
551
+ return html `<button
552
+ class="icono"
553
+ aria-label=${n > 0 ? `${this.textoAvisos}, ${n} sin leer` : this.textoAvisos}
554
+ @click=${this.alAvisos}
555
+ >
556
+ ${iconoBell}${n > 0 ? html `<span class="globo" aria-hidden="true">${n > 99 ? '99+' : n}</span>` : nothing}
547
557
  </button>`;
548
558
  }
549
559
  carritoTpl() {
550
560
  if (this.sinCarrito)
551
561
  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>
562
+ return html `<slot name="carrito">
563
+ <button class="icono" aria-label="Carrito, ${this.piezas} ${this.piezas === 1 ? 'pieza' : 'piezas'}" @click=${this.alCarrito}>
564
+ ${iconoShoppingBag}${this.piezas > 0 ? html `<span class="globo" aria-hidden="true">${this.piezas > 99 ? '99+' : this.piezas}</span>` : nothing}
565
+ </button>
556
566
  </slot>`;
557
567
  }
558
568
  ligaEscritorio(liga, i) {
@@ -561,37 +571,37 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
561
571
  return html `<li><a class="liga" href=${liga.href || '#'} @click=${(e) => this.alNavegar(e, liga)}>${liga.texto}</a></li>`;
562
572
  }
563
573
  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>
574
+ return html `<li @mouseenter=${() => this.abrirSubmenu(i)} @mouseleave=${() => this.alSalirLiga(i)}>
575
+ <button class="liga" aria-expanded=${abierta} @click=${(e) => this.alClicLiga(e, i)}>${liga.texto} ${iconoChevronDown}</button>
566
576
  ${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>`)}
577
+ ? html `<ul class="submenu">
578
+ ${liga.hijos.map((h) => html `<li><a href=${h.href || '#'} @click=${(e) => this.alNavegar(e, h)}>${h.texto}</a></li>`)}
569
579
  </ul>`
570
- : nothing}
580
+ : nothing}
571
581
  </li>`;
572
582
  }
573
583
  megaTpl(liga) {
574
584
  const promo = liga.promo;
575
585
  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>`)}
586
+ return html `<div class="mega" @mouseenter=${() => this.abrirSubmenu(indice)} @mouseleave=${() => this.cerrarConRetraso()}>
587
+ <div class="dentro ${promo ? 'con-promo' : ''}" style="--_columnas: ${liga.columnas.length}">
588
+ ${liga.columnas.map((c) => html `<div>
589
+ <h3>${c.titulo}</h3>
590
+ <ul>
591
+ ${c.ligas.map((l) => html `<li><a href=${l.href || '#'} @click=${(e) => this.alNavegar(e, l)}>${l.texto}</a></li>`)}
592
+ </ul>
593
+ </div>`)}
584
594
  ${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}
595
+ ? html `<a
596
+ class="promo"
597
+ href=${promo.href || '#'}
598
+ style=${promo.imagen ? `background-image: linear-gradient(0deg, rgb(0 0 0 / .55), rgb(0 0 0 / 0) 70%), url(${promo.imagen})` : ''}
599
+ @click=${(e) => this.alNavegar(e, { texto: promo.titulo, href: promo.href, id: promo.id })}
600
+ >
601
+ <b>${promo.titulo}</b>${promo.texto ? html `<span>${promo.texto}</span>` : nothing}
592
602
  </a>`
593
- : nothing}
594
- </div>
603
+ : nothing}
604
+ </div>
595
605
  </div>`;
596
606
  }
597
607
  /** Ligas para el menú de celular: el mega menú se aplana con sus títulos como grupos. */
@@ -621,14 +631,27 @@ let LrCustomHeader = class LrCustomHeader extends LitElement {
621
631
  alClicLiga(evento, i) {
622
632
  // Con mouse el hover ya lo abrió: el clic no debe cerrarlo. Con teclado (detail 0) alterna.
623
633
  if (evento.detail === 0)
624
- this.abierta = this.abierta === i ? -1 : i;
634
+ this.abierta === i ? this.cerrarSubmenu() : this.abrirSubmenu(i);
625
635
  else
626
- this.abierta = i;
636
+ this.abrirSubmenu(i);
627
637
  }
628
638
  alSalirLiga(i) {
629
639
  // El mega menú vive fuera del <li>; se cierra cuando el mouse sale de él.
630
640
  if (!this.ligas[i]?.columnas?.length)
631
- this.abierta = -1;
641
+ this.cerrarConRetraso();
642
+ }
643
+ abrirSubmenu(i) {
644
+ clearTimeout(this.cierre);
645
+ this.abierta = i;
646
+ }
647
+ cerrarSubmenu() {
648
+ clearTimeout(this.cierre);
649
+ this.abierta = -1;
650
+ }
651
+ /** Cierra tras un momento, para que el mouse pueda cruzar en diagonal o por un hueco sin perder el submenú. */
652
+ cerrarConRetraso() {
653
+ clearTimeout(this.cierre);
654
+ this.cierre = setTimeout(() => (this.abierta = -1), 250);
632
655
  }
633
656
  alCambiarAnuncio(e) {
634
657
  this.conAnuncio = e.target.assignedElements().length > 0;