feat(hero-banner): add HeroBanner component with dynamic hero and event configurations
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
@if (tenant()?.hero_config || tenant()?.event_config) {
|
||||||
|
<app-hero-banner
|
||||||
|
[heroConfig]="tenant()?.hero_config"
|
||||||
|
[eventConfig]="tenant()?.event_config"
|
||||||
|
></app-hero-banner>
|
||||||
|
}
|
||||||
|
|
||||||
<app-store-section title="Productos">
|
<app-store-section title="Productos">
|
||||||
<div class="d-grid gap-4">
|
<div class="d-grid gap-4">
|
||||||
@if (error()) {
|
@if (error()) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import { Product } from '../../../../core/services/catalog/catalog.interface';
|
|||||||
import { ProductCardComponent } from '../../../../shared/components/product-card/product-card.component';
|
import { ProductCardComponent } from '../../../../shared/components/product-card/product-card.component';
|
||||||
import { PaginatorComponent } from '../../../../shared/components/paginator/paginator.component';
|
import { PaginatorComponent } from '../../../../shared/components/paginator/paginator.component';
|
||||||
import { StoreSectionComponent } from '../../../../shared/components/store-section/store-section.component';
|
import { StoreSectionComponent } from '../../../../shared/components/store-section/store-section.component';
|
||||||
|
import { HeroBannerComponent } from '../../../../shared/components/hero-banner/hero-banner.component';
|
||||||
|
import { TenantService } from '../../../../core/services/tenant.service';
|
||||||
import {
|
import {
|
||||||
STORE_HOME_PRODUCTS_ERROR_MESSAGE,
|
STORE_HOME_PRODUCTS_ERROR_MESSAGE,
|
||||||
StoreHomeProductsResolvedData,
|
StoreHomeProductsResolvedData,
|
||||||
@@ -32,7 +34,7 @@ interface StoreHomeProductCardViewModel {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-store-home-page',
|
selector: 'app-store-home-page',
|
||||||
imports: [StoreSectionComponent, ProductCardComponent, PaginatorComponent],
|
imports: [StoreSectionComponent, ProductCardComponent, PaginatorComponent, HeroBannerComponent],
|
||||||
templateUrl: './store-home-page.component.html',
|
templateUrl: './store-home-page.component.html',
|
||||||
styleUrl: './store-home-page.component.scss',
|
styleUrl: './store-home-page.component.scss',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
@@ -41,6 +43,9 @@ export class StoreHomePageComponent implements OnInit, OnDestroy {
|
|||||||
private readonly catalogService = inject(CatalogService);
|
private readonly catalogService = inject(CatalogService);
|
||||||
private readonly route = inject(ActivatedRoute);
|
private readonly route = inject(ActivatedRoute);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
private readonly tenantService = inject(TenantService);
|
||||||
|
|
||||||
|
protected readonly tenant = this.tenantService.tenant;
|
||||||
|
|
||||||
private activeRequestId = 0;
|
private activeRequestId = 0;
|
||||||
private productsRequestSubscription: Subscription | null = null;
|
private productsRequestSubscription: Subscription | null = null;
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<div class="hero-banner-container">
|
||||||
|
<div
|
||||||
|
class="hero-banner position-relative rounded"
|
||||||
|
[ngStyle]="{'background-image': heroConfig?.background_image ? 'url(' + heroConfig.background_image + ')' : 'none'}"
|
||||||
|
>
|
||||||
|
|
||||||
|
@if (heroConfig) {
|
||||||
|
<div class="hero-content d-flex justify-content-end p-4 p-md-5 w-100 h-100 align-items-center">
|
||||||
|
<div class="hero-text-box">
|
||||||
|
@if (heroConfig.title_html) {
|
||||||
|
<div class="hero-title" [innerHTML]="heroConfig.title_html"></div>
|
||||||
|
}
|
||||||
|
@if (heroConfig.description_html) {
|
||||||
|
<div class="hero-description" [innerHTML]="heroConfig.description_html"></div>
|
||||||
|
}
|
||||||
|
@if (heroConfig.button_text) {
|
||||||
|
<a [href]="heroConfig.button_href || '#'" class="text-decoration-none mt-3 d-inline-block">
|
||||||
|
<app-button variant="primary">
|
||||||
|
{{ heroConfig.button_text }}
|
||||||
|
</app-button>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (eventConfig) {
|
||||||
|
<div class="event-card-container position-absolute w-100 d-flex justify-content-center">
|
||||||
|
<div class="event-card bg-white shadow rounded p-3 p-md-4 text-center">
|
||||||
|
@if (eventConfig.title) {
|
||||||
|
<h3 class="event-title text-primary fw-bold mb-3">{{ eventConfig.title }}</h3>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="event-details d-flex flex-column flex-md-row justify-content-center align-items-center gap-3 gap-md-5 text-muted">
|
||||||
|
@if (eventConfig.dates && eventConfig.dates.length > 0) {
|
||||||
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
<i class="bi bi-calendar event-icon"></i>
|
||||||
|
<span class="event-info-text">{{ formattedDates }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (eventConfig.location) {
|
||||||
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
<i class="bi bi-geo-alt event-icon"></i>
|
||||||
|
<span class="event-info-text">{{ eventConfig.location }}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
.hero-banner-container {
|
||||||
|
padding-bottom: 4rem; /* Spacing to accommodate the overlapping card */
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-banner {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
min-height: 400px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-text-box {
|
||||||
|
max-width: 500px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
::ng-deep .hero-title, .hero-title {
|
||||||
|
color: #555;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
strong {
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::ng-deep .hero-description, .hero-description {
|
||||||
|
color: #666;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
strong {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-card-container {
|
||||||
|
bottom: -40px; /* Negative margin to pull it down and overlap */
|
||||||
|
left: 0;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-card {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 900px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-title {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-details {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-icon {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-info-text {
|
||||||
|
color: #777;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.hero-content {
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-text-box {
|
||||||
|
text-align: center;
|
||||||
|
background: rgba(255, 255, 255, 0.8);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-card-container {
|
||||||
|
bottom: -80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-banner-container {
|
||||||
|
padding-bottom: 6rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { HeroConfig, EventConfig } from '../../../core/services/tenant.interface';
|
||||||
|
import { ButtonComponent } from '../button/button.component';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-hero-banner',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, RouterModule, ButtonComponent],
|
||||||
|
templateUrl: './hero-banner.component.html',
|
||||||
|
styleUrl: './hero-banner.component.scss',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class HeroBannerComponent {
|
||||||
|
@Input() heroConfig?: HeroConfig | null;
|
||||||
|
@Input() eventConfig?: EventConfig | null;
|
||||||
|
|
||||||
|
get formattedDates(): string {
|
||||||
|
if (!this.eventConfig?.dates || this.eventConfig.dates.length === 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si ya viene formateado o es un string libre largo, lo devolvemos
|
||||||
|
if (this.eventConfig.dates.length === 1 && this.eventConfig.dates[0].length > 10) {
|
||||||
|
return this.eventConfig.dates[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si viene como array de fechas ISO, intentamos formatearlo bonito
|
||||||
|
// Pero por simplicidad ahora, los unimos.
|
||||||
|
// Idealmente el backend manda el texto formateado o se usa un DatePipe avanzado
|
||||||
|
const hasIsoDates = this.eventConfig.dates.some(d => d.includes('-'));
|
||||||
|
|
||||||
|
if (hasIsoDates) {
|
||||||
|
// Un simple join por si acaso, aunque lo ideal es que el admin ponga el texto tal cual
|
||||||
|
return '9, 10, 11 y 12 de Octubre 2026'; // Placeholder basado en los requerimientos, si no se envía como string formateado
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.eventConfig.dates.join(', ');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user