Compare commits
4 Commits
tenant/sme
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| f70b93922e | |||
| d49c78b993 | |||
| 8ef00054c9 | |||
| 7247e8e694 |
@@ -1,8 +1,8 @@
|
|||||||
<header class="immersive-header" [class.immersive-header--compact]="!showHero()">
|
<header class="immersive-header" [class.immersive-header--compact]="!showHero()">
|
||||||
<div class="immersive-header__backdrop">
|
<div class="ih-backdrop">
|
||||||
@if (showHero() && backgroundImageUrl(); as backgroundImage) {
|
@if (showHero() && backgroundImageUrl(); as backgroundImage) {
|
||||||
<img
|
<img
|
||||||
class="immersive-header__backdrop-image"
|
class="ih-backdrop-image"
|
||||||
[src]="backgroundImage"
|
[src]="backgroundImage"
|
||||||
alt=""
|
alt=""
|
||||||
loading="eager"
|
loading="eager"
|
||||||
@@ -12,12 +12,12 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="immersive-header__content">
|
<div class="ih-content">
|
||||||
<nav
|
<nav
|
||||||
class="immersive-header__nav container-xl px-3 px-md-4"
|
class="ih-nav container-xl px-3 px-md-4"
|
||||||
aria-label="Navegación de la tienda"
|
aria-label="Navegación de la tienda"
|
||||||
>
|
>
|
||||||
<a routerLink="/" class="immersive-header__brand" aria-label="Ir al inicio">
|
<a routerLink="/" class="ih-brand" aria-label="Ir al inicio">
|
||||||
@if (logoUrl()) {
|
@if (logoUrl()) {
|
||||||
<img
|
<img
|
||||||
[src]="logoUrl()"
|
[src]="logoUrl()"
|
||||||
@@ -29,12 +29,12 @@
|
|||||||
}
|
}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="immersive-header__actions">
|
<div class="ih-actions">
|
||||||
@if (displaySearchBar()) {
|
@if (displaySearchBar()) {
|
||||||
<form
|
<form
|
||||||
id="immersive-search"
|
id="immersive-search"
|
||||||
class="immersive-header__search"
|
class="ih-search"
|
||||||
[class.immersive-header__search--open]="isSearchOpen()"
|
[class.ih-search--open]="isSearchOpen()"
|
||||||
role="search"
|
role="search"
|
||||||
(submit)="submitSearch($event)"
|
(submit)="submitSearch($event)"
|
||||||
>
|
>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
(valueChange)="showSearchError.set(false)"
|
(valueChange)="showSearchError.set(false)"
|
||||||
/>
|
/>
|
||||||
@if (showSearchError()) {
|
@if (showSearchError()) {
|
||||||
<span id="immersive-search-error" class="immersive-header__search-error" role="alert"
|
<span id="immersive-search-error" class="ih-search-error" role="alert"
|
||||||
>Ingresá al menos 3 caracteres.</span
|
>Ingresá al menos 3 caracteres.</span
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
@if (ticketsMenu(); as menu) {
|
@if (ticketsMenu(); as menu) {
|
||||||
<app-button
|
<app-button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
hostClass="immersive-header__tickets"
|
hostClass="ih-tickets"
|
||||||
data-testid="store-header-tickets"
|
data-testid="store-header-tickets"
|
||||||
(click)="ticketsClick.emit()"
|
(click)="ticketsClick.emit()"
|
||||||
>
|
>
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
<button
|
<button
|
||||||
#searchToggle
|
#searchToggle
|
||||||
type="button"
|
type="button"
|
||||||
class="immersive-header__search-toggle"
|
class="ih-search-toggle"
|
||||||
aria-label="Buscar productos"
|
aria-label="Buscar productos"
|
||||||
aria-controls="immersive-search"
|
aria-controls="immersive-search"
|
||||||
[attr.aria-expanded]="isSearchOpen()"
|
[attr.aria-expanded]="isSearchOpen()"
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="immersive-header__account">
|
<div class="ih-account">
|
||||||
<app-icon-button
|
<app-icon-button
|
||||||
variant="user"
|
variant="user"
|
||||||
ariaLabel="Mi cuenta"
|
ariaLabel="Mi cuenta"
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
(logoutClick)="onLogoutClick()"
|
(logoutClick)="onLogoutClick()"
|
||||||
/>
|
/>
|
||||||
} @else if (isUserDropdownOpen()) {
|
} @else if (isUserDropdownOpen()) {
|
||||||
<div id="immersive-user-dropdown" class="immersive-header__guest-menu">
|
<div id="immersive-user-dropdown" class="ih-guest-menu">
|
||||||
<button type="button" (click)="isUserDropdownOpen.set(false); loginClick.emit()">
|
<button type="button" (click)="isUserDropdownOpen.set(false); loginClick.emit()">
|
||||||
Iniciar sesión
|
Iniciar sesión
|
||||||
</button>
|
</button>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
|
|
||||||
@if (checkoutRemainingTime(); as remainingTime) {
|
@if (checkoutRemainingTime(); as remainingTime) {
|
||||||
<div
|
<div
|
||||||
class="immersive-header__timer container-xl px-3 px-md-4"
|
class="ih-timer container-xl px-3 px-md-4"
|
||||||
role="timer"
|
role="timer"
|
||||||
aria-label="Tiempo restante de compra"
|
aria-label="Tiempo restante de compra"
|
||||||
>
|
>
|
||||||
@@ -131,10 +131,10 @@
|
|||||||
|
|
||||||
@if (showHero()) {
|
@if (showHero()) {
|
||||||
@if (heroContent(); as content) {
|
@if (heroContent(); as content) {
|
||||||
<div class="immersive-header__copy">
|
<div class="ih-copy">
|
||||||
<p class="immersive-header__eyebrow">{{ content.eyebrow }}</p>
|
<p class="ih-eyebrow">{{ content.eyebrow }}</p>
|
||||||
<h1 class="immersive-header__title">{{ content.title }}</h1>
|
<h1 class="ih-title">{{ content.title }}</h1>
|
||||||
<p class="immersive-header__description">{{ content.description }}</p>
|
<p class="ih-description">{{ content.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__content {
|
.ih-content {
|
||||||
grid-area: 1 / 1;
|
grid-area: 1 / 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
padding-bottom: clamp(1rem, 2vw, 1.5rem);
|
padding-bottom: clamp(1rem, 2vw, 1.5rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop {
|
.ih-backdrop {
|
||||||
grid-area: 1 / 1;
|
grid-area: 1 / 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
background-color: #101010;
|
background-color: #101010;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop-image {
|
.ih-backdrop-image {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
object-position: center 42%;
|
object-position: center 42%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop::before,
|
.ih-backdrop::before,
|
||||||
.immersive-header__backdrop::after {
|
.ih-backdrop::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -48,15 +48,15 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop::before {
|
.ih-backdrop::before {
|
||||||
background: rgba(0, 0, 0, 0.7);
|
background: rgba(0, 0, 0, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop::after {
|
.ih-backdrop::after {
|
||||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0.4) 47%, #f5f5f5 100%);
|
background: linear-gradient(180deg, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0.4) 47%, #f5f5f5 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__nav {
|
.ih-nav {
|
||||||
position: relative;
|
position: relative;
|
||||||
// Keep the whole navigation stacking context above the hero copy and carousel.
|
// Keep the whole navigation stacking context above the hero copy and carousel.
|
||||||
// Otherwise those later siblings can sit on top of the dropdown and capture
|
// Otherwise those later siblings can sit on top of the dropdown and capture
|
||||||
@@ -69,28 +69,28 @@
|
|||||||
min-height: 2.25rem;
|
min-height: 2.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__brand {
|
.ih-brand {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex: none;
|
flex: none;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.immersive-header__brand img {
|
.ih-brand img {
|
||||||
display: block;
|
display: block;
|
||||||
width: clamp(105px, 13vw, 145px);
|
width: clamp(105px, 13vw, 145px);
|
||||||
max-height: 2.25rem;
|
max-height: 2.25rem;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
.immersive-header__actions {
|
.ih-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: clamp(0.35rem, 1vw, 1rem);
|
gap: clamp(0.35rem, 1vw, 1rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search {
|
.ih-search {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: clamp(115px, 17vw, 205px);
|
width: clamp(115px, 17vw, 205px);
|
||||||
}
|
}
|
||||||
.immersive-header__search-error {
|
.ih-search-error {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + 0.25rem);
|
top: calc(100% + 0.25rem);
|
||||||
right: 0;
|
right: 0;
|
||||||
@@ -99,52 +99,52 @@
|
|||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep .immersive-header__tickets {
|
:host ::ng-deep .ih-tickets {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
.immersive-header__account {
|
.ih-account {
|
||||||
position: relative;
|
position: relative;
|
||||||
// The nav becomes display: contents on mobile, so it cannot provide the
|
// The nav becomes display: contents on mobile, so it cannot provide the
|
||||||
// stacking context there. Keep the dropdown trigger above following rows.
|
// stacking context there. Keep the dropdown trigger above following rows.
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
:host ::ng-deep .immersive-header__actions .icon-btn,
|
:host ::ng-deep .ih-actions .icon-btn,
|
||||||
:host ::ng-deep .immersive-header__actions .cart-icon {
|
:host ::ng-deep .ih-actions .cart-icon {
|
||||||
color: var(--tenant-primary, #ff7006);
|
color: var(--tenant-primary, #ff7006);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__copy {
|
.ih-copy {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
margin: clamp(2.1rem, 5vw, 3.25rem) auto 0;
|
margin: clamp(2.1rem, 5vw, 3.25rem) auto 0;
|
||||||
padding-inline: 1rem;
|
padding-inline: 1rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.immersive-header__eyebrow,
|
.ih-eyebrow,
|
||||||
.immersive-header__title {
|
.ih-title {
|
||||||
font-family: 'Smooch', cursive;
|
font-family: 'Smooch', cursive;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
|
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
|
||||||
}
|
}
|
||||||
.immersive-header__eyebrow {
|
.ih-eyebrow {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
.immersive-header__title {
|
.ih-title {
|
||||||
margin: -0.15rem 0 0;
|
margin: -0.15rem 0 0;
|
||||||
font-size: 140px;
|
font-size: 140px;
|
||||||
line-height: 0.7;
|
line-height: 0.7;
|
||||||
}
|
}
|
||||||
.immersive-header__description {
|
.ih-description {
|
||||||
margin: 30px 0 0;
|
margin: 30px 0 0;
|
||||||
font-family: 'Gotham Book', sans-serif;
|
font-family: 'Gotham Book', sans-serif;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
|
text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
|
||||||
}
|
}
|
||||||
.immersive-header__timer {
|
.ih-timer {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
@@ -163,27 +163,27 @@
|
|||||||
color: #666666;
|
color: #666666;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|
||||||
.immersive-header__content {
|
.ih-content {
|
||||||
padding: 35px 0 36px;
|
padding: 35px 0 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__nav {
|
.ih-nav {
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__brand img {
|
.ih-brand img {
|
||||||
width: clamp(92px, 24vw, 145px);
|
width: clamp(92px, 24vw, 145px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__actions {
|
.ih-actions {
|
||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
gap: 0.375rem;
|
gap: 0.375rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search-toggle {
|
.ih-search-toggle {
|
||||||
display: none;
|
display: none;
|
||||||
flex: none;
|
flex: none;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__guest-menu {
|
.ih-guest-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + 0.5rem);
|
top: calc(100% + 0.5rem);
|
||||||
right: 0;
|
right: 0;
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep .immersive-header--compact {
|
:host ::ng-deep .immersive-header--compact {
|
||||||
.immersive-header__tickets {
|
.ih-tickets {
|
||||||
flex: none;
|
flex: none;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
|
||||||
@@ -234,58 +234,58 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__account .icon-btn {
|
.ih-account .icon-btn {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
color: #888;
|
color: #888;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.immersive-header--compact .immersive-header__backdrop {
|
.immersive-header--compact .ih-backdrop {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep .immersive-header--compact .immersive-header__actions .icon-btn,
|
:host ::ng-deep .immersive-header--compact .ih-actions .icon-btn,
|
||||||
:host ::ng-deep .immersive-header--compact .immersive-header__actions .cart-icon {
|
:host ::ng-deep .immersive-header--compact .ih-actions .cart-icon {
|
||||||
color: #888;
|
color: #888;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 359.98px) {
|
@media (max-width: 359.98px) {
|
||||||
.immersive-header--compact .immersive-header__nav {
|
.immersive-header--compact .ih-nav {
|
||||||
padding-inline: 1rem !important;
|
padding-inline: 1rem !important;
|
||||||
gap: 0.375rem;
|
gap: 0.375rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header--compact .immersive-header__actions {
|
.immersive-header--compact .ih-actions {
|
||||||
gap: 0.125rem;
|
gap: 0.125rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.immersive-header__nav {
|
.ih-nav {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
.immersive-header__actions {
|
.ih-actions {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
.immersive-header__search {
|
.ih-search {
|
||||||
width: clamp(105px, 38vw, 180px);
|
width: clamp(105px, 38vw, 180px);
|
||||||
}
|
}
|
||||||
.immersive-header__copy {
|
.ih-copy {
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
}
|
}
|
||||||
.immersive-header__eyebrow {
|
.ih-eyebrow {
|
||||||
font-size: clamp(2rem, 8vw, 50px);
|
font-size: clamp(2rem, 8vw, 50px);
|
||||||
}
|
}
|
||||||
.immersive-header__title {
|
.ih-title {
|
||||||
font-size: clamp(3rem, 12vw, 5rem);
|
font-size: clamp(3rem, 12vw, 5rem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 767.98px) {
|
@media (max-width: 767.98px) {
|
||||||
.immersive-header--compact {
|
.immersive-header--compact {
|
||||||
.immersive-header__search {
|
.ih-search {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + 0.5rem);
|
top: calc(100% + 0.5rem);
|
||||||
right: 8vw;
|
right: 8vw;
|
||||||
@@ -297,17 +297,17 @@
|
|||||||
box-shadow: 0 4px 16px #0002;
|
box-shadow: 0 4px 16px #0002;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search--open {
|
.ih-search--open {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search-error {
|
.ih-search-error {
|
||||||
position: static;
|
position: static;
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 0.25rem;
|
margin-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search-toggle {
|
.ih-search-toggle {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
.immersive-header:not(.immersive-header--compact) {
|
.immersive-header:not(.immersive-header--compact) {
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|
||||||
.immersive-header__content {
|
.ih-content {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -324,17 +324,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep one search form while placing it below the hero copy on mobile.
|
// Keep one search form while placing it below the hero copy on mobile.
|
||||||
.immersive-header__nav,
|
.ih-nav,
|
||||||
.immersive-header__actions {
|
.ih-actions {
|
||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__brand {
|
.ih-brand {
|
||||||
grid-area: 1 / 1;
|
grid-area: 1 / 1;
|
||||||
margin-left: 8vw;
|
margin-left: 8vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__brand img {
|
.ih-brand img {
|
||||||
width: clamp(105px, 34vw, 145px);
|
width: clamp(105px, 34vw, 145px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,30 +342,30 @@
|
|||||||
grid-area: 1 / 2;
|
grid-area: 1 / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__account {
|
.ih-account {
|
||||||
grid-area: 1 / 3;
|
grid-area: 1 / 3;
|
||||||
margin-right: calc(8vw - 0.75rem);
|
margin-right: calc(8vw - 0.75rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__timer {
|
.ih-timer {
|
||||||
grid-area: 2 / 1 / auto / -1;
|
grid-area: 2 / 1 / auto / -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__copy {
|
.ih-copy {
|
||||||
grid-area: 3 / 1 / auto / -1;
|
grid-area: 3 / 1 / auto / -1;
|
||||||
margin: 1.25rem 0 0;
|
margin: 1.25rem 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__eyebrow {
|
.ih-eyebrow {
|
||||||
font-size: clamp(18px, 5.5vw, 24px);
|
font-size: clamp(18px, 5.5vw, 24px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__title {
|
.ih-title {
|
||||||
font-size: clamp(40px, 12vw, 56px);
|
font-size: clamp(40px, 12vw, 56px);
|
||||||
line-height: 0.7;
|
line-height: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__description {
|
.ih-description {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
font-size: clamp(11px, 3vw, 14px);
|
font-size: clamp(11px, 3vw, 14px);
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
@@ -373,14 +373,14 @@
|
|||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search {
|
.ih-search {
|
||||||
grid-area: 4 / 1 / auto / -1;
|
grid-area: 4 / 1 / auto / -1;
|
||||||
width: 74%;
|
width: 74%;
|
||||||
max-width: 28rem;
|
max-width: 28rem;
|
||||||
margin: 0.5rem auto 0;
|
margin: 0.5rem auto 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search-error {
|
.ih-search-error {
|
||||||
right: auto;
|
right: auto;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -395,11 +395,11 @@
|
|||||||
--carousel-offset: -9vw;
|
--carousel-offset: -9vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop-image {
|
.ih-backdrop-image {
|
||||||
object-position: center 42%;
|
object-position: center 42%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop {
|
.ih-backdrop {
|
||||||
// Keep the fade tied to the hero, independent of the content below it.
|
// Keep the fade tied to the hero, independent of the content below it.
|
||||||
align-self: start;
|
align-self: start;
|
||||||
height: 12.5rem;
|
height: 12.5rem;
|
||||||
@@ -407,7 +407,7 @@
|
|||||||
mask-image: linear-gradient(#000 calc(100% - 8px), transparent 100%);
|
mask-image: linear-gradient(#000 calc(100% - 8px), transparent 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__backdrop::after {
|
.ih-backdrop::after {
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
180deg,
|
180deg,
|
||||||
rgba(0, 0, 0, 0.25) 0%,
|
rgba(0, 0, 0, 0.25) 0%,
|
||||||
@@ -420,7 +420,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:host ::ng-deep .immersive-header:not(.immersive-header--compact) {
|
:host ::ng-deep .immersive-header:not(.immersive-header--compact) {
|
||||||
.immersive-header__search .form-control {
|
.ih-search .form-control {
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
padding: 0.25rem 2.5rem 0.25rem 0.75rem;
|
padding: 0.25rem 2.5rem 0.25rem 0.75rem;
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
@@ -439,12 +439,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__search .input-search-icon {
|
.ih-search .input-search-icon {
|
||||||
color: #666;
|
color: #666;
|
||||||
right: 0.75rem;
|
right: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.immersive-header__account .icon-btn {
|
.ih-account .icon-btn {
|
||||||
min-width: 44px;
|
min-width: 44px;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
|
|
||||||
|
|||||||
@@ -274,21 +274,21 @@ describe('StoreLayoutComponent', () => {
|
|||||||
expect(header.componentInstance.headerType()).toBe('immersive');
|
expect(header.componentInstance.headerType()).toBe('immersive');
|
||||||
expect(element.querySelector('app-standard-store-header')).toBeNull();
|
expect(element.querySelector('app-standard-store-header')).toBeNull();
|
||||||
expect(element.querySelector('app-immersive-store-header')).not.toBeNull();
|
expect(element.querySelector('app-immersive-store-header')).not.toBeNull();
|
||||||
expect(element.querySelector('.immersive-header__eyebrow')?.textContent).toContain(
|
expect(element.querySelector('.ih-eyebrow')?.textContent).toContain(
|
||||||
'Encendé tu',
|
'Encendé tu',
|
||||||
);
|
);
|
||||||
expect(element.querySelector('.immersive-header__title')?.textContent).toContain('experiencia');
|
expect(element.querySelector('.ih-title')?.textContent).toContain('experiencia');
|
||||||
expect(element.querySelector('.immersive-header__description')?.textContent).toContain(
|
expect(element.querySelector('.ih-description')?.textContent).toContain(
|
||||||
'Reservá tu entrada',
|
'Reservá tu entrada',
|
||||||
);
|
);
|
||||||
const backdropImage = element.querySelector<HTMLImageElement>(
|
const backdropImage = element.querySelector<HTMLImageElement>(
|
||||||
'.immersive-header__backdrop-image',
|
'.ih-backdrop-image',
|
||||||
);
|
);
|
||||||
expect(backdropImage?.getAttribute('src')).toBe(tenant.header_bg_image);
|
expect(backdropImage?.getAttribute('src')).toBe(tenant.header_bg_image);
|
||||||
expect(backdropImage?.getAttribute('loading')).toBe('eager');
|
expect(backdropImage?.getAttribute('loading')).toBe('eager');
|
||||||
expect(backdropImage?.getAttribute('fetchpriority')).toBe('high');
|
expect(backdropImage?.getAttribute('fetchpriority')).toBe('high');
|
||||||
expect(backdropImage?.getAttribute('decoding')).toBe('async');
|
expect(backdropImage?.getAttribute('decoding')).toBe('async');
|
||||||
const headerLogo = element.querySelector<HTMLImageElement>('.immersive-header__brand img');
|
const headerLogo = element.querySelector<HTMLImageElement>('.ih-brand img');
|
||||||
expect(headerLogo?.getAttribute('loading')).toBe('eager');
|
expect(headerLogo?.getAttribute('loading')).toBe('eager');
|
||||||
expect(headerLogo?.getAttribute('fetchpriority')).toBe('high');
|
expect(headerLogo?.getAttribute('fetchpriority')).toBe('high');
|
||||||
expect(headerLogo?.getAttribute('decoding')).toBe('async');
|
expect(headerLogo?.getAttribute('decoding')).toBe('async');
|
||||||
|
|||||||
@@ -62,13 +62,7 @@
|
|||||||
(click)="selectImage(idx)"
|
(click)="selectImage(idx)"
|
||||||
[attr.aria-label]="'Select image ' + (idx + 1)"
|
[attr.aria-label]="'Select image ' + (idx + 1)"
|
||||||
>
|
>
|
||||||
<img
|
<img [src]="image" alt="Product thumbnail" class="w-100 h-100 object-fit-cover" />
|
||||||
[src]="image"
|
|
||||||
alt="Product thumbnail"
|
|
||||||
loading="lazy"
|
|
||||||
decoding="async"
|
|
||||||
class="w-100 h-100 object-fit-cover"
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,49 +23,24 @@
|
|||||||
</p>
|
</p>
|
||||||
} @else {
|
} @else {
|
||||||
@for (group of catalog(); track group.id; let first = $first) {
|
@for (group of catalog(); track group.id; let first = $first) {
|
||||||
@if (first) {
|
<app-store-section [attr.id]="group.code" [title]="group.title">
|
||||||
<ng-container
|
<app-product-list
|
||||||
[ngTemplateOutlet]="catalogGroup"
|
[layout]="group.layout"
|
||||||
[ngTemplateOutletContext]="{ $implicit: group, prioritizeFirstImage: true }"
|
[groupLayout]="group.group_layout"
|
||||||
|
[items]="group.items"
|
||||||
|
[loading]="isGroupLoading(group.id)"
|
||||||
|
[loadImages]="!hasMainCarouselImages() || mainCarouselReady()"
|
||||||
|
[prioritizeFirstImage]="first && !hasMainCarouselImages()"
|
||||||
|
[unavailableVariantIds]="unavailableVariantIds()"
|
||||||
|
[savingProductIds]="savingProductIds()"
|
||||||
|
(buy)="onBuyProduct($event)"
|
||||||
|
(addToCart)="onAddToCart($event)"
|
||||||
|
(pageChange)="onPageChange(group.id, $event)"
|
||||||
/>
|
/>
|
||||||
} @else {
|
</app-store-section>
|
||||||
@defer (on viewport; prefetch on idle) {
|
|
||||||
<ng-container
|
|
||||||
[ngTemplateOutlet]="catalogGroup"
|
|
||||||
[ngTemplateOutletContext]="{ $implicit: group, prioritizeFirstImage: false }"
|
|
||||||
/>
|
|
||||||
} @placeholder {
|
|
||||||
<section
|
|
||||||
class="store-home__deferred-group-placeholder"
|
|
||||||
[attr.aria-label]="group.title"
|
|
||||||
></section>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<ng-template
|
|
||||||
#catalogGroup
|
|
||||||
let-group
|
|
||||||
let-prioritizeFirstImage="prioritizeFirstImage"
|
|
||||||
>
|
|
||||||
<app-store-section [attr.id]="group.code" [title]="group.title">
|
|
||||||
<app-product-list
|
|
||||||
[layout]="group.layout"
|
|
||||||
[groupLayout]="group.group_layout"
|
|
||||||
[items]="group.items"
|
|
||||||
[loading]="isGroupLoading(group.id)"
|
|
||||||
[loadImages]="!hasMainCarouselImages() || mainCarouselReady()"
|
|
||||||
[prioritizeFirstImage]="prioritizeFirstImage && !hasMainCarouselImages()"
|
|
||||||
[unavailableVariantIds]="unavailableVariantIds()"
|
|
||||||
[savingProductIds]="savingProductIds()"
|
|
||||||
(buy)="onBuyProduct($event)"
|
|
||||||
(addToCart)="onAddToCart($event)"
|
|
||||||
(pageChange)="onPageChange(group.id, $event)"
|
|
||||||
/>
|
|
||||||
</app-store-section>
|
|
||||||
</ng-template>
|
|
||||||
|
|
||||||
@if (additionalInfo(); as content) {
|
@if (additionalInfo(); as content) {
|
||||||
<app-store-section class="store-home__additional-info" title="Información adicional">
|
<app-store-section class="store-home__additional-info" title="Información adicional">
|
||||||
<div class="store-home__additional-info-content" [innerHTML]="content"></div>
|
<div class="store-home__additional-info-content" [innerHTML]="content"></div>
|
||||||
|
|||||||
@@ -15,13 +15,6 @@ app-store-section[id] {
|
|||||||
scroll-margin-top: 8rem;
|
scroll-margin-top: 8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-home__deferred-group-placeholder {
|
|
||||||
display: block;
|
|
||||||
min-height: clamp(24rem, 42vw, 34rem);
|
|
||||||
content-visibility: auto;
|
|
||||||
contain-intrinsic-size: auto 30rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
:host > .store-home__additional-info:not(:first-child) {
|
:host > .store-home__additional-info:not(:first-child) {
|
||||||
margin-top: clamp(3rem, 6vw, 5rem);
|
margin-top: clamp(3rem, 6vw, 5rem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
signal,
|
signal,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NgTemplateOutlet } from '@angular/common';
|
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { finalize, Subscription } from 'rxjs';
|
import { finalize, Subscription } from 'rxjs';
|
||||||
@@ -45,7 +44,6 @@ import {
|
|||||||
ProductListComponent,
|
ProductListComponent,
|
||||||
HeroBannerComponent,
|
HeroBannerComponent,
|
||||||
MainCarouselComponent,
|
MainCarouselComponent,
|
||||||
NgTemplateOutlet,
|
|
||||||
],
|
],
|
||||||
templateUrl: './store-home-page.component.html',
|
templateUrl: './store-home-page.component.html',
|
||||||
styleUrl: './store-home-page.component.scss',
|
styleUrl: './store-home-page.component.scss',
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<section class="carousel" role="region" [attr.aria-label]="ariaLabel()">
|
<section class="carousel" role="region" [attr.aria-label]="ariaLabel()">
|
||||||
<span
|
|
||||||
#sizeProbe
|
|
||||||
class="carousel__size-probe"
|
|
||||||
aria-hidden="true"
|
|
||||||
[style.width]="itemBasis()"
|
|
||||||
></span>
|
|
||||||
<div class="carousel__frame" [class.carousel__frame--with-controls]="hasMultipleItems()">
|
<div class="carousel__frame" [class.carousel__frame--with-controls]="hasMultipleItems()">
|
||||||
<div
|
<div
|
||||||
#viewport
|
#viewport
|
||||||
|
|||||||
@@ -4,17 +4,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.carousel {
|
.carousel {
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
&__size-probe {
|
|
||||||
position: absolute;
|
|
||||||
height: 0;
|
|
||||||
visibility: hidden;
|
|
||||||
pointer-events: none;
|
|
||||||
contain: strict;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__frame {
|
&__frame {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, signal, TemplateRef, viewChild } from '@angular/core';
|
import { Component, signal, TemplateRef, viewChild } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { CarouselComponent, CarouselItemContext } from './carousel.component';
|
import { CarouselComponent, CarouselItemContext } from './carousel.component';
|
||||||
|
|
||||||
interface TestItem {
|
interface TestItem {
|
||||||
@@ -16,7 +16,7 @@ interface TestItem {
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<app-carousel
|
<app-carousel
|
||||||
[items]="items()"
|
[items]="items"
|
||||||
[itemTemplate]="itemTemplate"
|
[itemTemplate]="itemTemplate"
|
||||||
[scrollStep]="120"
|
[scrollStep]="120"
|
||||||
[gap]="16"
|
[gap]="16"
|
||||||
@@ -28,11 +28,11 @@ interface TestItem {
|
|||||||
class TestHostComponent {
|
class TestHostComponent {
|
||||||
readonly circular = signal(false);
|
readonly circular = signal(false);
|
||||||
|
|
||||||
readonly items = signal<TestItem[]>([
|
readonly items: TestItem[] = [
|
||||||
{ id: 1, label: 'Primero' },
|
{ id: 1, label: 'Primero' },
|
||||||
{ id: 2, label: 'Segundo' },
|
{ id: 2, label: 'Segundo' },
|
||||||
{ id: 3, label: 'Tercero' },
|
{ id: 3, label: 'Tercero' },
|
||||||
]);
|
];
|
||||||
|
|
||||||
readonly carousel = viewChild.required(CarouselComponent<TestItem>);
|
readonly carousel = viewChild.required(CarouselComponent<TestItem>);
|
||||||
readonly itemTemplate =
|
readonly itemTemplate =
|
||||||
@@ -41,47 +41,8 @@ class TestHostComponent {
|
|||||||
|
|
||||||
describe('CarouselComponent', () => {
|
describe('CarouselComponent', () => {
|
||||||
let fixture: ComponentFixture<TestHostComponent>;
|
let fixture: ComponentFixture<TestHostComponent>;
|
||||||
let frames: Map<number, FrameRequestCallback>;
|
|
||||||
let resize: () => void;
|
|
||||||
let disconnect: ReturnType<typeof vi.fn>;
|
|
||||||
const flushLayout = () => {
|
|
||||||
const pending = [...frames.values()];
|
|
||||||
frames.clear();
|
|
||||||
pending.forEach((callback) => callback(0));
|
|
||||||
fixture.detectChanges();
|
|
||||||
};
|
|
||||||
const setDimensions = (width: number, basis: number) => {
|
|
||||||
const host = fixture.nativeElement.querySelector('app-carousel');
|
|
||||||
Object.defineProperty(host, 'clientWidth', { configurable: true, value: width });
|
|
||||||
const probe = fixture.nativeElement.querySelector('.carousel__size-probe');
|
|
||||||
probe.getBoundingClientRect = () => ({ width: basis }) as DOMRect;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
frames = new Map();
|
|
||||||
let frameId = 0;
|
|
||||||
vi.stubGlobal(
|
|
||||||
'requestAnimationFrame',
|
|
||||||
vi.fn((callback: FrameRequestCallback) => {
|
|
||||||
frames.set(++frameId, callback);
|
|
||||||
return frameId;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
vi.stubGlobal(
|
|
||||||
'cancelAnimationFrame',
|
|
||||||
vi.fn((id: number) => frames.delete(id)),
|
|
||||||
);
|
|
||||||
disconnect = vi.fn();
|
|
||||||
vi.stubGlobal(
|
|
||||||
'ResizeObserver',
|
|
||||||
class {
|
|
||||||
constructor(callback: () => void) {
|
|
||||||
resize = callback;
|
|
||||||
}
|
|
||||||
observe() {}
|
|
||||||
disconnect = disconnect;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TestHostComponent],
|
imports: [TestHostComponent],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -90,75 +51,6 @@ describe('CarouselComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
vi.unstubAllGlobals();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('agrupa las mediciones y no se realimenta al renderizar o navegar', async () => {
|
|
||||||
fixture.componentInstance.circular.set(true);
|
|
||||||
setDimensions(650, 200);
|
|
||||||
fixture.detectChanges();
|
|
||||||
resize();
|
|
||||||
resize();
|
|
||||||
expect(frames.size).toBe(1);
|
|
||||||
flushLayout();
|
|
||||||
await Promise.resolve();
|
|
||||||
expect(frames.size).toBe(0);
|
|
||||||
const carousel = fixture.componentInstance.carousel();
|
|
||||||
expect(carousel['itemsPerPage']()).toBe(2);
|
|
||||||
carousel.next();
|
|
||||||
fixture.detectChanges();
|
|
||||||
const track = fixture.nativeElement.querySelector('.carousel__track');
|
|
||||||
track.dispatchEvent(new TransitionEvent('transitionend', { propertyName: 'transform' }));
|
|
||||||
fixture.detectChanges();
|
|
||||||
await Promise.resolve();
|
|
||||||
resize(); // Same width, even if the new cards have a different height.
|
|
||||||
expect(frames.size).toBe(0);
|
|
||||||
expect(carousel['currentPage']()).toBe(1);
|
|
||||||
expect(carousel['itemWidth']()).toBe(269);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('recalcula al cambiar el ancho y la base responsive de las tarjetas', () => {
|
|
||||||
setDimensions(650, 200);
|
|
||||||
resize();
|
|
||||||
flushLayout();
|
|
||||||
setDimensions(350, 200);
|
|
||||||
resize();
|
|
||||||
flushLayout();
|
|
||||||
expect(fixture.componentInstance.carousel()['itemsPerPage']()).toBe(1);
|
|
||||||
setDimensions(350, 100);
|
|
||||||
resize();
|
|
||||||
flushLayout();
|
|
||||||
expect(fixture.componentInstance.carousel()['itemsPerPage']()).toBe(2);
|
|
||||||
expect(frames.size).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('actualiza productos y admite una lista vacía sin anchos inválidos', () => {
|
|
||||||
setDimensions(650, 200);
|
|
||||||
flushLayout();
|
|
||||||
fixture.componentInstance.items.set([]);
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(frames.size).toBe(1);
|
|
||||||
flushLayout();
|
|
||||||
const carousel = fixture.componentInstance.carousel();
|
|
||||||
expect(carousel['itemWidth']()).toBeNull();
|
|
||||||
expect(carousel['hasOverflow']()).toBe(false);
|
|
||||||
fixture.componentInstance.items.set([{ id: 4, label: 'Nuevo' }]);
|
|
||||||
fixture.detectChanges();
|
|
||||||
flushLayout();
|
|
||||||
expect(carousel['itemWidth']()).toBe(650);
|
|
||||||
expect(fixture.nativeElement.querySelectorAll('article')).toHaveLength(1);
|
|
||||||
expect(frames.size).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('cancela mediciones pendientes y desconecta el observador al destruirse', () => {
|
|
||||||
expect(frames.size).toBe(1);
|
|
||||||
fixture.destroy();
|
|
||||||
expect(frames.size).toBe(0);
|
|
||||||
expect(disconnect).toHaveBeenCalledOnce();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renderiza el template provisto para cada elemento', () => {
|
it('renderiza el template provisto para cada elemento', () => {
|
||||||
const articles = fixture.nativeElement.querySelectorAll('article');
|
const articles = fixture.nativeElement.querySelectorAll('article');
|
||||||
|
|
||||||
@@ -167,17 +59,6 @@ describe('CarouselComponent', () => {
|
|||||||
expect(articles[1].getAttribute('data-index')).toBe('1');
|
expect(articles[1].getAttribute('data-index')).toBe('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('permite inspeccionar las páginas antes de medir el viewport sin generar listas enormes', () => {
|
|
||||||
const carousel = fixture.componentInstance.carousel();
|
|
||||||
fixture.componentInstance.circular.set(true);
|
|
||||||
carousel['itemsPerPage'].set(Number.MAX_SAFE_INTEGER);
|
|
||||||
|
|
||||||
expect(carousel['circularPages']()).toEqual([]);
|
|
||||||
expect(carousel['createPage']('current', 0).items.map((entry) => entry.item.id)).toEqual([
|
|
||||||
1, 2, 3,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('expone una región accesible y controles con etiquetas', () => {
|
it('expone una región accesible y controles con etiquetas', () => {
|
||||||
const region = fixture.nativeElement.querySelector('[role="region"]');
|
const region = fixture.nativeElement.querySelector('[role="region"]');
|
||||||
const buttons = fixture.nativeElement.querySelectorAll('button');
|
const buttons = fixture.nativeElement.querySelectorAll('button');
|
||||||
@@ -218,7 +99,7 @@ describe('CarouselComponent', () => {
|
|||||||
|
|
||||||
it('usa todo el ancho y distribuye el espacio sobrante entre elementos completos', () => {
|
it('usa todo el ancho y distribuye el espacio sobrante entre elementos completos', () => {
|
||||||
const host = fixture.nativeElement.querySelector('app-carousel') as HTMLElement;
|
const host = fixture.nativeElement.querySelector('app-carousel') as HTMLElement;
|
||||||
const firstItem = fixture.nativeElement.querySelector('.carousel__size-probe') as HTMLElement;
|
const firstItem = fixture.nativeElement.querySelector('.carousel__item') as HTMLElement;
|
||||||
|
|
||||||
Object.defineProperty(host, 'clientWidth', {
|
Object.defineProperty(host, 'clientWidth', {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
@@ -231,7 +112,7 @@ describe('CarouselComponent', () => {
|
|||||||
}) as DOMRect,
|
}) as DOMRect,
|
||||||
);
|
);
|
||||||
|
|
||||||
flushLayout();
|
fixture.componentInstance.carousel().ngAfterViewInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const frame = fixture.nativeElement.querySelector('.carousel__frame') as HTMLElement;
|
const frame = fixture.nativeElement.querySelector('.carousel__frame') as HTMLElement;
|
||||||
@@ -247,7 +128,7 @@ describe('CarouselComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const host = fixture.nativeElement.querySelector('app-carousel') as HTMLElement;
|
const host = fixture.nativeElement.querySelector('app-carousel') as HTMLElement;
|
||||||
const firstItem = fixture.nativeElement.querySelector('.carousel__size-probe') as HTMLElement;
|
const firstItem = fixture.nativeElement.querySelector('.carousel__item') as HTMLElement;
|
||||||
|
|
||||||
Object.defineProperty(host, 'clientWidth', {
|
Object.defineProperty(host, 'clientWidth', {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
@@ -260,7 +141,7 @@ describe('CarouselComponent', () => {
|
|||||||
}) as DOMRect,
|
}) as DOMRect,
|
||||||
);
|
);
|
||||||
|
|
||||||
flushLayout();
|
fixture.componentInstance.carousel().ngAfterViewInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const pages = fixture.nativeElement.querySelectorAll('.carousel__page');
|
const pages = fixture.nativeElement.querySelectorAll('.carousel__page');
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
afterRenderEffect,
|
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
DestroyRef,
|
DestroyRef,
|
||||||
@@ -11,7 +10,6 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
input,
|
input,
|
||||||
signal,
|
signal,
|
||||||
untracked,
|
|
||||||
viewChild,
|
viewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
import { isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
||||||
@@ -47,15 +45,12 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
private readonly platformId = inject(PLATFORM_ID);
|
private readonly platformId = inject(PLATFORM_ID);
|
||||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||||
private readonly viewport = viewChild.required<ElementRef<HTMLElement>>('viewport');
|
private readonly viewport = viewChild.required<ElementRef<HTMLElement>>('viewport');
|
||||||
private readonly sizeProbe = viewChild.required<ElementRef<HTMLElement>>('sizeProbe');
|
|
||||||
private layoutFrame: number | null = null;
|
|
||||||
|
|
||||||
readonly items = input.required<readonly T[]>();
|
readonly items = input.required<readonly T[]>();
|
||||||
readonly itemTemplate = input.required<TemplateRef<CarouselItemContext<T>>>();
|
readonly itemTemplate = input.required<TemplateRef<CarouselItemContext<T>>>();
|
||||||
readonly trackBy = input<CarouselTrackBy<T>>((index) => index);
|
readonly trackBy = input<CarouselTrackBy<T>>((index) => index);
|
||||||
readonly scrollStep = input<number | null>(null);
|
readonly scrollStep = input<number | null>(null);
|
||||||
readonly gap = input(0);
|
readonly gap = input(0);
|
||||||
readonly itemBasis = input('16rem');
|
|
||||||
readonly circular = input(false);
|
readonly circular = input(false);
|
||||||
readonly ariaLabel = input('Carrusel');
|
readonly ariaLabel = input('Carrusel');
|
||||||
readonly previousLabel = input('Mostrar elementos anteriores');
|
readonly previousLabel = input('Mostrar elementos anteriores');
|
||||||
@@ -75,10 +70,6 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
);
|
);
|
||||||
protected readonly isCircularLayout = computed(() => this.circular() && this.pageCount() > 1);
|
protected readonly isCircularLayout = computed(() => this.circular() && this.pageCount() > 1);
|
||||||
protected readonly circularPages = computed<CarouselPage<T>[]>(() => {
|
protected readonly circularPages = computed<CarouselPage<T>[]>(() => {
|
||||||
if (!this.isCircularLayout()) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageCount = this.pageCount();
|
const pageCount = this.pageCount();
|
||||||
const currentPage = this.normalizePage(this.currentPage(), pageCount);
|
const currentPage = this.normalizePage(this.currentPage(), pageCount);
|
||||||
|
|
||||||
@@ -95,51 +86,27 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
() => !this.hasOverflow() || (!this.circular() && !this.canScrollNext()),
|
() => !this.hasOverflow() || (!this.circular() && !this.canScrollNext()),
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor() {
|
|
||||||
afterRenderEffect(() => {
|
|
||||||
this.items();
|
|
||||||
this.gap();
|
|
||||||
this.circular();
|
|
||||||
this.itemBasis();
|
|
||||||
this.itemTemplate();
|
|
||||||
// Layout outputs must never become dependencies of this effect.
|
|
||||||
untracked(() => this.scheduleLayout());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private scheduleLayout(): void {
|
|
||||||
if (this.destroyRef.destroyed || this.layoutFrame !== null) return;
|
|
||||||
this.layoutFrame = requestAnimationFrame(() => {
|
|
||||||
this.layoutFrame = null;
|
|
||||||
this.refreshLayout();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
if (!isPlatformBrowser(this.platformId)) {
|
if (!isPlatformBrowser(this.platformId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let previousWidth = -1;
|
const viewport = this.viewport().nativeElement;
|
||||||
let previousBasis = -1;
|
this.refreshLayout();
|
||||||
|
|
||||||
const resizeObserver =
|
const resizeObserver =
|
||||||
typeof ResizeObserver === 'undefined'
|
typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.refreshLayout());
|
||||||
? null
|
|
||||||
: new ResizeObserver(() => {
|
|
||||||
const width = this.host.nativeElement.clientWidth;
|
|
||||||
const basis = this.sizeProbe().nativeElement.getBoundingClientRect().width;
|
|
||||||
// Image loads and page rotation can change height, but not the layout inputs.
|
|
||||||
if (width === previousWidth && basis === previousBasis) return;
|
|
||||||
previousWidth = width;
|
|
||||||
previousBasis = basis;
|
|
||||||
this.scheduleLayout();
|
|
||||||
});
|
|
||||||
resizeObserver?.observe(this.host.nativeElement);
|
resizeObserver?.observe(this.host.nativeElement);
|
||||||
resizeObserver?.observe(this.sizeProbe().nativeElement);
|
|
||||||
|
const mutationObserver =
|
||||||
|
typeof MutationObserver === 'undefined'
|
||||||
|
? null
|
||||||
|
: new MutationObserver(() => this.refreshLayout());
|
||||||
|
mutationObserver?.observe(viewport, { childList: true, subtree: true });
|
||||||
|
|
||||||
this.destroyRef.onDestroy(() => {
|
this.destroyRef.onDestroy(() => {
|
||||||
resizeObserver?.disconnect();
|
resizeObserver?.disconnect();
|
||||||
if (this.layoutFrame !== null) cancelAnimationFrame(this.layoutFrame);
|
mutationObserver?.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,32 +218,24 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private refreshLayout(): void {
|
private refreshLayout(): void {
|
||||||
const itemCount = this.items().length;
|
const viewport = this.viewport().nativeElement;
|
||||||
|
const firstItem = viewport.querySelector<HTMLElement>('.carousel__item');
|
||||||
const availableWidth = this.host.nativeElement.clientWidth;
|
const availableWidth = this.host.nativeElement.clientWidth;
|
||||||
const availableViewportWidth = Math.max(
|
const availableViewportWidth = Math.max(
|
||||||
availableWidth - (this.hasMultipleItems() ? CarouselComponent.CONTROL_SLOT_WIDTH * 2 : 0),
|
availableWidth - (this.hasMultipleItems() ? CarouselComponent.CONTROL_SLOT_WIDTH * 2 : 0),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (itemCount === 0) {
|
if (!firstItem || availableViewportWidth <= 0) {
|
||||||
this.itemsPerPage.set(1);
|
|
||||||
this.currentPage.set(0);
|
|
||||||
this.transitionDirection.set(0);
|
|
||||||
this.itemWidth.set(null);
|
|
||||||
this.hasOverflow.set(false);
|
|
||||||
this.canScrollPrevious.set(false);
|
|
||||||
this.canScrollNext.set(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (availableViewportWidth <= 0) {
|
|
||||||
this.itemWidth.set(null);
|
this.itemWidth.set(null);
|
||||||
this.refreshNavigation();
|
this.refreshNavigation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Measure a stable CSS basis, never a card whose content/width we just changed.
|
const assignedWidth = firstItem.style.width;
|
||||||
const naturalItemWidth = this.sizeProbe().nativeElement.getBoundingClientRect().width;
|
firstItem.style.width = '';
|
||||||
|
const naturalItemWidth = firstItem.getBoundingClientRect().width;
|
||||||
|
firstItem.style.width = assignedWidth;
|
||||||
|
|
||||||
if (naturalItemWidth <= 0) {
|
if (naturalItemWidth <= 0) {
|
||||||
this.itemWidth.set(null);
|
this.itemWidth.set(null);
|
||||||
@@ -285,9 +244,9 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gap = this.resolvedGap();
|
const gap = this.resolvedGap();
|
||||||
const fittingItems = Math.min(
|
const fittingItems = Math.max(
|
||||||
itemCount,
|
1,
|
||||||
Math.max(1, Math.floor((availableViewportWidth + gap) / (naturalItemWidth + gap))),
|
Math.floor((availableViewportWidth + gap) / (naturalItemWidth + gap)),
|
||||||
);
|
);
|
||||||
const visibleItems = Math.min(fittingItems, this.items().length);
|
const visibleItems = Math.min(fittingItems, this.items().length);
|
||||||
const distributedItemWidth =
|
const distributedItemWidth =
|
||||||
@@ -299,12 +258,7 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
this.transitionDirection.set(0);
|
this.transitionDirection.set(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.itemWidth() !== distributedItemWidth) this.itemWidth.set(distributedItemWidth);
|
this.itemWidth.set(distributedItemWidth);
|
||||||
const normalizedPage = this.normalizePage(this.currentPage(), this.pageCount());
|
|
||||||
if (normalizedPage !== this.currentPage()) {
|
|
||||||
this.currentPage.set(normalizedPage);
|
|
||||||
this.transitionDirection.set(0);
|
|
||||||
}
|
|
||||||
if (this.circular()) {
|
if (this.circular()) {
|
||||||
const hasOverflow = this.items().length > fittingItems;
|
const hasOverflow = this.items().length > fittingItems;
|
||||||
this.hasOverflow.set(hasOverflow);
|
this.hasOverflow.set(hasOverflow);
|
||||||
@@ -316,20 +270,14 @@ export class CarouselComponent<T> implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createPage(slot: CarouselPage<T>['slot'], page: number): CarouselPage<T> {
|
private createPage(slot: CarouselPage<T>['slot'], page: number): CarouselPage<T> {
|
||||||
const sourceItems = this.items();
|
|
||||||
// Layout has not necessarily been measured when a computed value is inspected.
|
|
||||||
const pageSize = Math.min(this.itemsPerPage(), sourceItems.length);
|
|
||||||
if (pageSize === 0) {
|
|
||||||
return { slot, items: [] };
|
|
||||||
}
|
|
||||||
const pageCount = this.pageCount();
|
const pageCount = this.pageCount();
|
||||||
const normalizedPage = this.normalizePage(page, pageCount);
|
const normalizedPage = this.normalizePage(page, pageCount);
|
||||||
const start = normalizedPage * pageSize;
|
const start = normalizedPage * this.itemsPerPage();
|
||||||
const items: CarouselPageItem<T>[] = [];
|
const items: CarouselPageItem<T>[] = [];
|
||||||
|
|
||||||
for (let offset = 0; offset < pageSize; offset += 1) {
|
for (let offset = 0; offset < this.itemsPerPage(); offset += 1) {
|
||||||
const index = (start + offset) % sourceItems.length;
|
const index = (start + offset) % this.items().length;
|
||||||
items.push({ item: sourceItems[index], index });
|
items.push({ item: this.items()[index], index });
|
||||||
}
|
}
|
||||||
|
|
||||||
return { slot, items };
|
return { slot, items };
|
||||||
|
|||||||
@@ -67,9 +67,6 @@
|
|||||||
[itemTemplate]="productItem"
|
[itemTemplate]="productItem"
|
||||||
[trackBy]="trackProduct"
|
[trackBy]="trackProduct"
|
||||||
[gap]="24"
|
[gap]="24"
|
||||||
[itemBasis]="
|
|
||||||
effectiveLayout() === 'row' ? 'clamp(18rem, 70vw, 32rem)' : 'clamp(15rem, 30vw, 18rem)'
|
|
||||||
"
|
|
||||||
[circular]="true"
|
[circular]="true"
|
||||||
ariaLabel="Productos destacados"
|
ariaLabel="Productos destacados"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user