Files
marketplaces/src/app/widgets/ui/product-carousel-widget.component.ts

38 lines
1.4 KiB
TypeScript
Raw Normal View History

import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
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';
@Component({
selector: 'app-product-carousel-widget',
standalone: true,
imports: [CommonModule, CatalogProductGridComponent],
template: `
<section class="product-carousel-widget">
@if (data?.title) {
<h2>{{ data?.title }}</h2>
}
@if (data?.products?.length) {
<app-catalog-product-grid [products]="data?.products ?? []" />
} @else if (data?.emptyMessage) {
<p class="product-carousel-widget__empty">{{ data?.emptyMessage }}</p>
}
</section>
`,
styles: [
`
.product-carousel-widget { display: grid; gap: 1rem; }
.product-carousel-widget__empty { margin: 0; color: var(--text-secondary, #667a77); }
`
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProductCarouselWidgetComponent {
@Input() section: SectionConfig | null = null;
@Input() data: ProductCollectionWidgetData | null = null;
@Output() productSelected = new EventEmitter<unknown>();
}