11import {
22 Component ,
3- Input
3+ Input ,
4+ ContentChildren ,
5+ QueryList ,
6+ AfterContentInit
47} from "@angular/core" ;
58
69import { BreadcrumbItem } from "./breadcrumb-item.interface" ;
10+ import { BreadcrumbItemComponent } from "./breadcrumb-item.component" ;
711
812const MINIMUM_OVERFLOW_THRESHOLD = 4 ;
913
@@ -12,6 +16,7 @@ const MINIMUM_OVERFLOW_THRESHOLD = 4;
1216 template : `
1317 <nav #nav class="bx--breadcrumb"
1418 [ngClass]="{
19+ 'bx--skeleton' : skeleton,
1520 'bx--breadcrumb--no-trailing-slash' : noTrailingSlash
1621 }"
1722 [attr.aria-label]="ariaLabel">
@@ -50,14 +55,27 @@ const MINIMUM_OVERFLOW_THRESHOLD = 4;
5055 </ng-template>
5156 </nav>`
5257} )
53- export class Breadcrumb {
58+ export class Breadcrumb implements AfterContentInit {
59+ @ContentChildren ( BreadcrumbItemComponent ) children : QueryList < BreadcrumbItemComponent > ;
60+
5461 @Input ( ) items : Array < BreadcrumbItem > ;
5562
5663 @Input ( ) noTrailingSlash = false ;
5764
5865 @Input ( ) ariaLabel : string ;
5966
6067 protected _threshold : number ;
68+ protected _skeleton = false ;
69+
70+ @Input ( )
71+ set skeleton ( value : any ) {
72+ this . _skeleton = value ;
73+ this . updateChildren ( ) ;
74+ }
75+
76+ get skeleton ( ) : any {
77+ return this . _skeleton ;
78+ }
6179
6280 @Input ( )
6381 set threshold ( threshold : number ) {
@@ -71,6 +89,10 @@ export class Breadcrumb {
7189 return this . _threshold ;
7290 }
7391
92+ ngAfterContentInit ( ) {
93+ this . updateChildren ( ) ;
94+ }
95+
7496 get shouldShowContent ( ) : boolean {
7597 return ! this . items ;
7698 }
@@ -97,4 +119,10 @@ export class Breadcrumb {
97119 get last ( ) : BreadcrumbItem {
98120 return this . shouldShowOverflow ? this . items [ this . items . length - 1 ] : null ;
99121 }
122+
123+ protected updateChildren ( ) {
124+ if ( this . children ) {
125+ this . children . toArray ( ) . forEach ( child => child . skeleton = this . skeleton ) ;
126+ }
127+ }
100128}
0 commit comments