Skip to content

Commit bea6112

Browse files
authored
Merge branch 'master' into skeleton-toggle
2 parents b2ca1b1 + 86dd242 commit bea6112

File tree

10 files changed

+83
-3
lines changed

10 files changed

+83
-3
lines changed

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/input/input.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class TextInput {
2121
@Input() theme: "light" | "dark" = "dark";
2222

2323
@HostBinding("class.bx--text-input") inputClass = true;
24+
@HostBinding("class.bx--skeleton") @Input() skeleton = false;
2425
@HostBinding("class.bx--text-input--light") get isLightTheme() {
2526
return this.theme === "light";
2627
}

src/input/input.stories.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,21 @@ storiesOf("Input", module).addDecorator(
3333
props: {
3434
theme: select("Theme", ["dark", "light"], "dark")
3535
}
36+
}))
37+
.add("Skeleton", () => ({
38+
template: `
39+
<div style="width: 300px">
40+
<ibm-label skeleton="true">
41+
<input ibmText skeleton="true">
42+
</ibm-label>
43+
<br>
44+
<input ibmText skeleton="true">
45+
</div>
46+
<br><br>
47+
<div style="width: 160px">
48+
<ibm-label skeleton="true">
49+
<div ibmTextArea skeleton="true"></div>
50+
</ibm-label>
51+
</div>
52+
`
3653
}));

src/input/label.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ import {
3131
@Component({
3232
selector: "ibm-label",
3333
template: `
34-
<label [for]="labelInputID" class="bx--label"><ng-content></ng-content></label>
34+
<label
35+
[for]="labelInputID"
36+
class="bx--label"
37+
[ngClass]="{
38+
'bx--skeleton': skeleton
39+
}">
40+
<ng-content></ng-content>
41+
</label>
3542
<ng-content select="input,textarea,div"></ng-content>
3643
`
3744
})
@@ -55,6 +62,10 @@ export class Label implements AfterContentInit {
5562
* @memberof Label
5663
*/
5764
@Input() labelState: "success" | "warning" | "error" | "" = "";
65+
/**
66+
* Set to `true` for a loading label.
67+
*/
68+
@Input() skeleton = false;
5869

5970
@HostBinding("class.bx--form-item") labelClass = true;
6071

src/input/text-area.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class TextArea {
2121
@Input() theme: "light" | "dark" = "dark";
2222

2323
@HostBinding("class.bx--text-area") baseClass = true;
24+
@HostBinding("class.bx--skeleton") @Input() skeleton = false;
2425
@HostBinding("class.bx--text-area--light") get isLightTheme() {
2526
return this.theme === "light";
2627
}

src/radio/radio-group.component.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ export class RadioGroup implements OnInit, AfterContentInit, ControlValueAccesso
163163
this.markRadiosForCheck();
164164
}
165165

166+
/**
167+
* Returns the skeleton value in the `RadioGroup` if there is one.
168+
*/
169+
@Input()
170+
get skeleton(): any {
171+
return this._skeleton;
172+
}
173+
174+
/**
175+
* Sets the skeleton value for all `Radio` to the skeleton value of `RadioGroup`.
176+
*/
177+
set skeleton(value: any) {
178+
this._skeleton = value;
179+
this.updateChildren();
180+
}
181+
166182
/**
167183
* Binds 'radiogroup' value to the role attribute for `RadioGroup`.
168184
*/
@@ -181,6 +197,10 @@ export class RadioGroup implements OnInit, AfterContentInit, ControlValueAccesso
181197
* Reflects whether or not the input is disabled and cannot be selected.
182198
*/
183199
protected _disabled = false;
200+
/**
201+
* Reflects wheather or not the dropdown is loading.
202+
*/
203+
protected _skeleton = false;
184204
/**
185205
* The value of the selected option within the `RadioGroup`.
186206
*/
@@ -301,6 +321,8 @@ export class RadioGroup implements OnInit, AfterContentInit, ControlValueAccesso
301321
this.radios = updatedRadios;
302322
this.updateFocusableRadio();
303323
});
324+
325+
this.updateChildren();
304326
}
305327

306328
updateFocusableRadio() {
@@ -338,4 +360,10 @@ export class RadioGroup implements OnInit, AfterContentInit, ControlValueAccesso
338360
* Method set in registerOnChange to propagate changes back to the form.
339361
*/
340362
propagateChange = (_: any) => {};
363+
364+
protected updateChildren() {
365+
if (this.radios) {
366+
this.radios.toArray().forEach(child => child.skeleton = this.skeleton);
367+
}
368+
}
341369
}

src/radio/radio.component.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ describe("RadioComponent", () => {
6565
let fixture: ComponentFixture<Radio>;
6666
let de: DebugElement;
6767
let el: HTMLElement;
68-
let inputElement: HTMLElement;
6968

7069
beforeEach(() => {
7170
TestBed.configureTestingModule({
@@ -78,7 +77,6 @@ describe("RadioComponent", () => {
7877
component = fixture.componentInstance;
7978
de = fixture.debugElement.query(By.css("label"));
8079
el = de.nativeElement;
81-
inputElement = fixture.debugElement.query(By.css("input")).nativeElement;
8280
});
8381

8482
it("should work", () => {

src/radio/radio.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { RadioGroup } from "./radio-group.component";
3434
selector: "ibm-radio",
3535
template: `
3636
<input
37+
*ngIf="!skeleton"
3738
class="bx--radio-button"
3839
type="radio"
3940
#inputCheckbox
@@ -48,8 +49,12 @@ import { RadioGroup } from "./radio-group.component";
4849
(change)="onChange($event)"
4950
(click)="onClick($event)"
5051
[tabindex]="(checked || needsToBeFocusable ? 0 : -1)">
52+
<div *ngIf="skeleton" class="bx--radio-button bx--skeleton"></div>
5153
<label
5254
class="bx--radio-button__label"
55+
[ngClass]="{
56+
'bx--skeleton': skeleton
57+
}"
5358
[for]="id">
5459
<span class="bx--radio-button__appearance"></span>
5560
<ng-content></ng-content>
@@ -71,6 +76,10 @@ export class Radio extends Checkbox implements OnInit {
7176
*/
7277
static radioCount = 0;
7378

79+
/**
80+
* Set to `true` for a loading table.
81+
*/
82+
@Input() skeleton = false;
7483
/**
7584
* Returns the value/state of the `Radio`.
7685
* @readonly

src/radio/radio.stories.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ storiesOf("Radio", module).addDecorator(
2828
{ num: "four" }
2929
]
3030
}
31+
}))
32+
.add("Skeleton", () => ({
33+
template: `
34+
<ibm-radio-group skeleton="true">
35+
<ibm-radio></ibm-radio>
36+
</ibm-radio-group>
37+
`
3138
}));

0 commit comments

Comments
 (0)