1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-11 14:04:03 +00:00
Files
browser/libs/components/src/breadcrumbs/breadcrumbs.component.ts
Oscar Hinton 5a582dfc6f [CL-135] Migrate component library to standalone components (#12389)
* Migrate component library to standalone components

* Fix tests
2024-12-17 17:29:48 -05:00

48 lines
1.2 KiB
TypeScript

import { CommonModule } from "@angular/common";
import { Component, ContentChildren, Input, QueryList } from "@angular/core";
import { RouterModule } from "@angular/router";
import { IconButtonModule } from "../icon-button";
import { LinkModule } from "../link";
import { MenuModule } from "../menu";
import { BreadcrumbComponent } from "./breadcrumb.component";
@Component({
selector: "bit-breadcrumbs",
templateUrl: "./breadcrumbs.component.html",
standalone: true,
imports: [CommonModule, LinkModule, RouterModule, IconButtonModule, MenuModule],
})
export class BreadcrumbsComponent {
@Input()
show = 3;
private breadcrumbs: BreadcrumbComponent[] = [];
@ContentChildren(BreadcrumbComponent)
protected set breadcrumbList(value: QueryList<BreadcrumbComponent>) {
this.breadcrumbs = value.toArray();
}
protected get beforeOverflow() {
if (this.hasOverflow) {
return this.breadcrumbs.slice(0, this.show - 1);
}
return this.breadcrumbs;
}
protected get overflow() {
return this.breadcrumbs.slice(this.show - 1, -1);
}
protected get afterOverflow() {
return this.breadcrumbs.slice(-1);
}
protected get hasOverflow() {
return this.breadcrumbs.length > this.show;
}
}