diff --git a/src/app/features/website/catalog/containers/catalog-container.component.html b/src/app/features/website/catalog/containers/catalog-container.component.html index 7be50fb..672c9a7 100644 --- a/src/app/features/website/catalog/containers/catalog-container.component.html +++ b/src/app/features/website/catalog/containers/catalog-container.component.html @@ -3,13 +3,12 @@ @if (catalogConfig().showBreadcrumbs && breadcrumb().length > 0) { - + } (() => + this.breadcrumb().map(category => ({ id: category.id, label: category.title })) + ); + + onBreadcrumbItemClick(item: BreadcrumbItem): void { + const category = this.breadcrumb().find(c => c.id === item.id); + if (category) { + this.selectCategory(category); + } + } + selectCategory(category: Category): void { this.router.navigate([`/${this.languageService.currentLanguage()}/catalog`, category.id]); } diff --git a/src/app/shared/ui/breadcrumb/breadcrumb.component.html b/src/app/shared/ui/breadcrumb/breadcrumb.component.html new file mode 100644 index 0000000..218376c --- /dev/null +++ b/src/app/shared/ui/breadcrumb/breadcrumb.component.html @@ -0,0 +1,7 @@ + diff --git a/src/app/shared/ui/breadcrumb/breadcrumb.component.scss b/src/app/shared/ui/breadcrumb/breadcrumb.component.scss new file mode 100644 index 0000000..47f1ce8 --- /dev/null +++ b/src/app/shared/ui/breadcrumb/breadcrumb.component.scss @@ -0,0 +1,19 @@ +.app-breadcrumb { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; + color: var(--text-secondary); + font-size: var(--font-size-md, 0.9375rem); + + button { + border: 0; + padding: 0; + background: transparent; + color: var(--primary-color); + font: inherit; + font-weight: var(--font-weight-bold, 700); + text-decoration: none; + cursor: pointer; + } +} diff --git a/src/app/shared/ui/breadcrumb/breadcrumb.component.ts b/src/app/shared/ui/breadcrumb/breadcrumb.component.ts new file mode 100644 index 0000000..d660d2e --- /dev/null +++ b/src/app/shared/ui/breadcrumb/breadcrumb.component.ts @@ -0,0 +1,26 @@ +import { ChangeDetectionStrategy, Component, input, output } from '@angular/core'; + +export interface BreadcrumbItem { + id: string | number; + label: string; +} + +/** + * Generic breadcrumb trail. Consumer owns navigation - this component only + * renders the trail and emits which item was clicked (root or a trail item). + */ +@Component({ + selector: 'app-breadcrumb', + standalone: true, + templateUrl: './breadcrumb.component.html', + styleUrl: './breadcrumb.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class BreadcrumbComponent { + readonly rootLabel = input.required(); + readonly items = input([]); + readonly ariaLabel = input(''); + + readonly rootClick = output(); + readonly itemClick = output(); +}