Skip to content

Commit 4c4b692

Browse files
authored
Merge branch 'master' into skeleton-dropdown
2 parents e05b743 + 5c2fec5 commit 4c4b692

36 files changed

+496
-51
lines changed

src/accordion/accordion-item.component.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,29 @@ import {
2121
viewBox="0 0 7 12">
2222
<path fill-rule="nonzero" d="M5.569 5.994L0 .726.687 0l6.336 5.994-6.335 6.002L0 11.27z"/>
2323
</svg>
24-
<p class="bx--accordion__title">{{title}}</p>
24+
<p
25+
class="bx--accordion__title"
26+
[ngClass]="{
27+
'bx--skeleton__text': skeleton
28+
}">
29+
{{!skeleton ? title : null}}
30+
</p>
2531
</button>
2632
<div [id]="id" class="bx--accordion__content">
27-
<ng-content></ng-content>
33+
<ng-content *ngIf="!skeleton; else skeletonTemplate"></ng-content>
34+
<ng-template #skeletonTemplate>
35+
<p class="bx--skeleton__text" style="width: 90%"></p>
36+
<p class="bx--skeleton__text" style="width: 80%"></p>
37+
<p class="bx--skeleton__text" style="width: 95%"></p>
38+
</ng-template>
2839
</div>
2940
`
3041
})
3142
export class AccordionItem {
3243
static accordionItemCount = 0;
3344
@Input() title = `Title ${AccordionItem.accordionItemCount}`;
3445
@Input() id = `accordion-item-${AccordionItem.accordionItemCount}`;
46+
@Input() skeleton = false;
3547
@Output() selected = new EventEmitter();
3648

3749
@HostBinding("class.bx--accordion__item") itemClass = true;
@@ -45,7 +57,9 @@ export class AccordionItem {
4557
}
4658

4759
public toggleExpanded() {
48-
this.expanded = !this.expanded;
49-
this.selected.emit({id: this.id, expanded: this.expanded});
60+
if (!this.skeleton) {
61+
this.expanded = !this.expanded;
62+
this.selected.emit({id: this.id, expanded: this.expanded});
63+
}
5064
}
5165
}
Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { Component } from "@angular/core";
1+
import {
2+
Component,
3+
Input,
4+
ContentChildren,
5+
QueryList,
6+
AfterContentInit
7+
} from "@angular/core";
8+
import { AccordionItem } from "./accordion-item.component";
29

310
@Component({
411
selector: "ibm-accordion",
@@ -8,6 +15,28 @@ import { Component } from "@angular/core";
815
</ul>
916
`
1017
})
11-
export class Accordion {
18+
export class Accordion implements AfterContentInit {
19+
@ContentChildren(AccordionItem) children: QueryList<AccordionItem>;
1220

21+
protected _skeleton = false;
22+
23+
@Input()
24+
set skeleton(value: any) {
25+
this._skeleton = value;
26+
this.updateChildren();
27+
}
28+
29+
get skeleton(): any {
30+
return this._skeleton;
31+
}
32+
33+
ngAfterContentInit() {
34+
this.updateChildren();
35+
}
36+
37+
protected updateChildren() {
38+
if (this.children) {
39+
this.children.toArray().forEach(child => child.skeleton = this.skeleton);
40+
}
41+
}
1342
}

src/accordion/accordion.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ storiesOf("Accordion", module)
5252
],
5353
selected: action("item expanded")
5454
}
55+
}))
56+
.add("Skeleton", () => ({
57+
template: `
58+
<div style="width: 500px">
59+
<ibm-accordion skeleton="true">
60+
<ibm-accordion-item expanded="true"></ibm-accordion-item>
61+
<ibm-accordion-item></ibm-accordion-item>
62+
<ibm-accordion-item></ibm-accordion-item>
63+
<ibm-accordion-item></ibm-accordion-item>
64+
</ibm-accordion>
65+
</div>
66+
`
5567
}));

src/breadcrumb/breadcrumb-item.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
selector: "ibm-breadcrumb-item",
99
template: `
1010
<a class="bx--link"
11-
href="{{href}}"
12-
*ngIf="href; else content">
11+
href="{{skeleton ? href : '/#'}}"
12+
*ngIf="skeleton || href; else content">
1313
<ng-container *ngTemplateOutlet="content"></ng-container>
1414
</a>
1515
<ng-template #content>
@@ -19,5 +19,7 @@ import {
1919
export class BreadcrumbItemComponent {
2020
@Input() href: string;
2121

22+
@Input() skeleton = false;
23+
2224
@HostBinding("class.bx--breadcrumb-item") itemClass = true;
2325
}

src/breadcrumb/breadcrumb.component.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import {
22
Component,
3-
Input
3+
Input,
4+
ContentChildren,
5+
QueryList,
6+
AfterContentInit
47
} from "@angular/core";
58

69
import { BreadcrumbItem } from "./breadcrumb-item.interface";
10+
import { BreadcrumbItemComponent } from "./breadcrumb-item.component";
711

812
const 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
}

src/breadcrumb/breadcrumb.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,16 @@ storiesOf("Breadcrumb", module)
5757
threshold: number("threshold", 4),
5858
items: createBreadcrumbItems
5959
}
60+
}))
61+
.add("Skeleton", () => ({
62+
template: `
63+
<ibm-breadcrumb skeleton="true" [noTrailingSlash]="noTrailingSlash">
64+
<ibm-breadcrumb-item></ibm-breadcrumb-item>
65+
<ibm-breadcrumb-item></ibm-breadcrumb-item>
66+
<ibm-breadcrumb-item></ibm-breadcrumb-item>
67+
<ibm-breadcrumb-item></ibm-breadcrumb-item>
68+
</ibm-breadcrumb>`,
69+
props: {
70+
noTrailingSlash: boolean("noTrailingSlash", true)
71+
}
6072
}));

src/button/button.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Button implements OnInit {
3737
@HostBinding("class.bx--btn--ghost") ghost = false;
3838
@HostBinding("class.bx--btn--danger") danger = false;
3939
@HostBinding("class.bx--btn--danger--primary") dangerPrimary = false;
40+
@HostBinding("class.bx--skeleton") @Input() skeleton = false;
4041
@HostBinding("class.bx--btn--sm") smallSize = false;
4142

4243
ngOnInit() {

src/button/button.stories.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ storiesOf("Button", module)
2929
props: {
3030
size: select("Size of the buttons", ["normal", "sm"], "normal")
3131
}
32+
}))
33+
.add("Skeleton", () => ({
34+
template: `
35+
<button ibmButton skeleton="true"></button>
36+
&nbsp;
37+
<button ibmButton skeleton="true" size="sm"></button>
38+
`
3239
}));

src/checkbox/checkbox.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ export class CheckboxChange {
7070
[attr.aria-checked]="(indeterminate ? 'mixed' : checked)"
7171
(change)="onChange($event)"
7272
(click)="onClick($event)">
73-
<label [for]="id" class="bx--checkbox-label">
73+
<label
74+
[for]="id"
75+
class="bx--checkbox-label"
76+
[ngClass]="{
77+
'bx--skeleton' : skeleton
78+
}">
7479
<ng-content></ng-content>
7580
</label>
7681
`,
@@ -107,6 +112,10 @@ export class Checkbox implements ControlValueAccessor, AfterViewInit {
107112
* Set to `true` for a disabled checkbox.
108113
*/
109114
@Input() disabled = false;
115+
/**
116+
* Set to `true` for a loading checkbox.
117+
*/
118+
@Input() skeleton = false;
110119
/**
111120
* Sets the name attribute on the `input` element.
112121
*/

src/checkbox/checkbox.stories.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ storiesOf("Checkbox", module).addDecorator(
2828
onChange: action("Change fired!"),
2929
onIndeterminateChange: action("Indeterminate change fired!")
3030
}
31-
}));
31+
}))
32+
.add("Skeleton", () => ({
33+
template: `<ibm-checkbox skeleton="true"></ibm-checkbox>`
34+
}));

0 commit comments

Comments
 (0)