Skip to content

Commit 510e804

Browse files
committed
Merge branch 'master' of https://github.com/IBM/carbon-components-angular into storybook-styles
2 parents d572d38 + 688ab7e commit 510e804

21 files changed

+310
-20
lines changed

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+
}));

src/code-snippet/code-snippet.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ export enum SnippetType {
3131
3232
<ng-template #notInline>
3333
<div class="bx--snippet-container" [attr.aria-label]="translations.CODE_SNIPPET_TEXT">
34-
<pre><ng-container *ngTemplateOutlet="codeTemplate"></ng-container></pre>
34+
<ng-container *ngIf="skeleton">
35+
<span *ngIf="display === 'single'; else multiSkeleton"></span>
36+
<ng-template #multiSkeleton>
37+
<span></span>
38+
<span></span>
39+
<span></span>
40+
</ng-template>
41+
</ng-container>
42+
<pre *ngIf="!skeleton"><ng-container *ngTemplateOutlet="codeTemplate"></ng-container></pre>
3543
</div>
3644
<button
45+
*ngIf="!skeleton"
3746
class="bx--snippet-button"
3847
[attr.aria-label]="translations.COPY_CODE"
3948
(click)="onCopyButtonClicked()"
@@ -118,6 +127,7 @@ export class CodeSnippet {
118127
@Input() feedbackTimeout = 2000;
119128

120129
@HostBinding("class.bx--snippet--expand") @Input() expanded = false;
130+
@HostBinding("class.bx--skeleton") @Input() skeleton = false;
121131

122132
@HostBinding("class.bx--snippet") snippetClass = true;
123133
@HostBinding("class.bx--snippet--single") get snippetSingleClass() {

src/code-snippet/code-snippet.stories.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@ storiesOf("CodeSnippet", module).addDecorator(
6666
inlineCode,
6767
theme: select("Theme", ["dark", "light"], "dark")
6868
}
69+
}))
70+
.add("Skeleton", () => ({
71+
template: `
72+
<div style="width: 800px">
73+
<ibm-code-snippet display="single" skeleton="true"></ibm-code-snippet>
74+
<br>
75+
<ibm-code-snippet display="multi" skeleton="true"></ibm-code-snippet>
76+
</div>
77+
`
6978
}));

src/number-input/number.component.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ describe("Number", () => {
8686
});
8787

8888
it("should display control buttons", () => {
89+
fixture.detectChanges();
8990
buttonUp = fixture.debugElement.queryAll(By.css("button"))[0].nativeElement;
9091
buttonDown = fixture.debugElement.queryAll(By.css("button"))[1].nativeElement;
9192
expect(buttonUp.className.includes("bx--number__control-btn")).toEqual(true);
@@ -95,6 +96,7 @@ describe("Number", () => {
9596
});
9697

9798
it("should increment value when button up is clicked", () => {
99+
fixture.detectChanges();
98100
buttonUp = fixture.debugElement.query(By.css(".up-icon")).nativeElement;
99101
component.value = 1;
100102
buttonUp.click();
@@ -103,6 +105,7 @@ describe("Number", () => {
103105
});
104106

105107
it("should not increment value if max is reached", () => {
108+
fixture.detectChanges();
106109
buttonUp = fixture.debugElement.query(By.css(".up-icon")).nativeElement;
107110
component.value = 100;
108111
component.max = 100;
@@ -112,6 +115,7 @@ describe("Number", () => {
112115
});
113116

114117
it("should decrement value when button down is clicked", () => {
118+
fixture.detectChanges();
115119
buttonUp = fixture.debugElement.query(By.css(".down-icon")).nativeElement;
116120
component.value = 1;
117121
buttonUp.click();
@@ -120,6 +124,7 @@ describe("Number", () => {
120124
});
121125

122126
it("should not decrement value min is reached", () => {
127+
fixture.detectChanges();
123128
buttonUp = fixture.debugElement.query(By.css(".down-icon")).nativeElement;
124129
component.value = 0;
125130
component.min = 0;

src/number-input/number.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ export class NumberChange {
3030
@Component({
3131
selector: "ibm-number",
3232
template: `
33+
<label *ngIf="skeleton && label" class="bx--label bx--skeleton"></label>
3334
<div
3435
data-numberinput
3536
class="bx--number"
3637
[ngClass]="{
3738
'bx--number--light': theme === 'light',
3839
'bx--number--nolabel': !label,
39-
'bx--number--helpertext': helperText
40+
'bx--number--helpertext': helperText,
41+
'bx--skeleton' : skeleton
4042
}">
41-
<label *ngIf="label" [for]="id" class="bx--label">{{label}}</label>
43+
<label *ngIf="!skeleton && label" [for]="id" class="bx--label">{{label}}</label>
4244
<input
4345
type="number"
4446
[id]="id"
@@ -47,7 +49,7 @@ export class NumberChange {
4749
[max]="max"
4850
[disabled]="disabled"
4951
[required]="required"/>
50-
<div class="bx--number__controls">
52+
<div *ngIf="!skeleton" class="bx--number__controls">
5153
<button
5254
class="bx--number__control-btn up-icon"
5355
(click)="onIncrement()">
@@ -90,6 +92,10 @@ export class Number implements ControlValueAccessor {
9092
* Set to `true` for a disabled number input.
9193
*/
9294
@Input() disabled = false;
95+
/**
96+
* Set to `true` for a loading number component.
97+
*/
98+
@Input() skeleton = false;
9399
/**
94100
* The unique id for the number component.
95101
*/

src/number-input/number.stories.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ storiesOf("Number", module).addDecorator(
2929
max: number("max", 100),
3030
disabled: boolean("disabled", false)
3131
}
32+
}))
33+
.add("Skeleton", () => ({
34+
template: `
35+
<div style="width: 75px;">
36+
<ibm-number [label]="label" skeleton="true"></ibm-number>
37+
</div>
38+
`,
39+
props: {
40+
label: text("label", "Number Input Label")
41+
}
3242
}));

src/pagination/pagination.component.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@ import { BehaviorSubject } from "rxjs";
3636
@Component({
3737
selector: "ibm-pagination",
3838
template: `
39-
<div class="bx--pagination">
40-
<div class="bx--pagination__left">
39+
<div
40+
class="bx--pagination"
41+
[ngClass]="{
42+
'bx--skeleton' : skeleton
43+
}">
44+
45+
<div *ngIf="skeleton" class="bx--pagination__left">
46+
<p class="bx--skeleton__text" style="width: 70px"></p>
47+
<p class="bx--skeleton__text" style="width: 35px"></p>
48+
<p class="bx--skeleton__text" style="width: 105px"></p>
49+
</div>
50+
51+
<div *ngIf="!skeleton" class="bx--pagination__left">
4152
<span class="bx--pagination__text">{{itemsPerPageText | async}}</span>
4253
<div class="bx--form-item">
4354
<div class="bx--select bx--select--inline">
@@ -76,7 +87,12 @@ import { BehaviorSubject } from "rxjs";
7687
{{totalItemsText | i18nReplace:{start: startItemIndex, end: endItemIndex, total: model.totalDataLength } | async}}
7788
</span>
7889
</div>
79-
<div class="bx--pagination__right bx--pagination--inline">
90+
91+
<div *ngIf="skeleton" class="bx--pagination__right bx--pagination--inline">
92+
<p class="bx--skeleton__text" style="width: 70px"></p>
93+
</div>
94+
95+
<div *ngIf="!skeleton" class="bx--pagination__right bx--pagination--inline">
8096
<span class="bx--pagination__text">{{totalPagesText | i18nReplace:{current: currentPage, last: lastPage} | async}}</span>
8197
<button
8298
class="bx--pagination__button bx--pagination__button--backward"
@@ -139,6 +155,10 @@ import { BehaviorSubject } from "rxjs";
139155
export class Pagination {
140156
static paginationCounter = 0;
141157

158+
/**
159+
* Set to `true` for a loading pagination component.
160+
*/
161+
@Input() skeleton = false;
142162
/**
143163
* `PaginationModel` with the information about pages you're controlling.
144164
*

src/pagination/pagination.stories.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import { PaginationModel } from "./pagination-model.class";
1818
template: `
1919
<ibm-pagination
2020
[model]="model"
21+
[skeleton]="skeleton"
2122
(selectPage)="selectPage($event)">
2223
</ibm-pagination>
2324
`
2425
})
2526
class PaginationStory implements OnInit {
2627
@Input() model = new PaginationModel();
28+
@Input() skeleton = false;
2729

2830
@Input() get totalDataLength() {
2931
return this.model.totalDataLength;
@@ -65,5 +67,13 @@ storiesOf("Pagination", module).addDecorator(
6567
props: {
6668
totalDataLength: number("totalDataLength", 105)
6769
}
70+
}))
71+
.add("Skeleton", () => ({
72+
template: `
73+
<app-pagination [totalDataLength]="totalDataLength" [skeleton]="true"></app-pagination>
74+
`,
75+
props: {
76+
totalDataLength: number("totalDataLength", 105)
77+
}
6878
}));
6979

src/progress-indicator/progress-indicator.component.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { Component, Input } from "@angular/core";
33
@Component({
44
selector: "ibm-progress-indicator",
55
template: `
6-
<ul data-progress data-progress-current class="bx--progress">
6+
<ul
7+
data-progress
8+
data-progress-current
9+
class="bx--progress"
10+
[ngClass]="{
11+
'bx--skeleton': skeleton
12+
}">
713
<li
814
class="bx--progress-step bx--progress-step--{{step.state}}"
915
*ngFor="let step of steps; let i = index">
@@ -27,5 +33,15 @@ import { Component, Input } from "@angular/core";
2733
`
2834
})
2935
export class ProgressIndicator {
36+
static skeletonSteps(stepCount: number) {
37+
const steps = [];
38+
for (let i = 0; i < stepCount; i++) {
39+
steps.push({"state": ["incomplete"]});
40+
}
41+
42+
return steps;
43+
}
44+
3045
@Input() steps = [];
46+
@Input() skeleton = false;
3147
}

0 commit comments

Comments
 (0)