2026-07-03 01:36:27 +04:00
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
2026-07-05 02:08:15 +04:00
|
|
|
import { SectionConfig } from '../../shared/models/config';
|
|
|
|
|
import { CatalogProductGridComponent } from '../../features/website/catalog/components/product-grid/product-grid.component';
|
|
|
|
|
import { ProductCollectionWidgetData } from '../contracts/widget-data.contract';
|
2026-07-03 01:36:27 +04:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-product-carousel-widget',
|
|
|
|
|
standalone: true,
|
2026-07-05 02:08:15 +04:00
|
|
|
imports: [CommonModule, CatalogProductGridComponent],
|
2026-07-03 01:36:27 +04:00
|
|
|
template: `
|
|
|
|
|
<section class="product-carousel-widget">
|
2026-07-05 02:08:15 +04:00
|
|
|
@if (data?.title) {
|
|
|
|
|
<h2>{{ data?.title }}</h2>
|
2026-07-03 01:36:27 +04:00
|
|
|
}
|
|
|
|
|
|
2026-07-05 02:08:15 +04:00
|
|
|
@if (data?.products?.length) {
|
|
|
|
|
<app-catalog-product-grid [products]="data?.products ?? []" />
|
|
|
|
|
} @else if (data?.emptyMessage) {
|
|
|
|
|
<p class="product-carousel-widget__empty">{{ data?.emptyMessage }}</p>
|
2026-07-03 01:36:27 +04:00
|
|
|
}
|
|
|
|
|
</section>
|
|
|
|
|
`,
|
|
|
|
|
styles: [
|
|
|
|
|
`
|
2026-07-05 02:50:53 +04:00
|
|
|
.product-carousel-widget { display: grid; gap: 1rem; }
|
2026-07-05 02:08:15 +04:00
|
|
|
.product-carousel-widget__empty { margin: 0; color: var(--text-secondary, #667a77); }
|
2026-07-03 01:36:27 +04:00
|
|
|
`
|
|
|
|
|
],
|
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
|
|
})
|
|
|
|
|
export class ProductCarouselWidgetComponent {
|
2026-07-05 02:08:15 +04:00
|
|
|
@Input() section: SectionConfig | null = null;
|
|
|
|
|
@Input() data: ProductCollectionWidgetData | null = null;
|
2026-07-03 01:36:27 +04:00
|
|
|
|
2026-07-05 02:08:15 +04:00
|
|
|
@Output() productSelected = new EventEmitter<unknown>();
|
2026-07-03 01:36:27 +04:00
|
|
|
}
|