mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[EC-937] Pre-merge breadcrumbs into master (#4420)
original implementation from ef20ee1882 (https://github.com/bitwarden/clients/pull/3762)
This commit is contained in:
39
libs/components/src/breadcrumbs/breadcrumbs.component.ts
Normal file
39
libs/components/src/breadcrumbs/breadcrumbs.component.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Component, ContentChildren, Input, QueryList } from "@angular/core";
|
||||
|
||||
import { BreadcrumbComponent } from "./breadcrumb.component";
|
||||
|
||||
@Component({
|
||||
selector: "bit-breadcrumbs",
|
||||
templateUrl: "./breadcrumbs.component.html",
|
||||
})
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user