Skip to content

Commit 475ec2d

Browse files
committed
update(checkbox): Add inline input
1 parent 3488f8e commit 475ec2d

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/checkbox/checkbox.component.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,18 @@ export class Checkbox implements ControlValueAccessor, AfterViewInit {
9494
*/
9595
static checkboxCount = 0;
9696

97-
@HostBinding("attr.class") class = "bx--checkbox-wrapper";
98-
9997
/**
10098
* Size of the checkbox.
10199
*/
102100
@Input() size: "sm" | "md" = "md";
103-
/**
104-
* Set to `true` for checkbox to be rendered with inline styles.
105-
*/
106-
@Input() inline: boolean;
107101
/**
108102
* Set to `true` for checkbox to be rendered with nested styles.
109103
*/
110104
@Input() nested: boolean;
105+
/**
106+
* Set to `true` for checkbox to be rendered without any classes on the host element.
107+
*/
108+
@Input() inline = false;
111109
/**
112110
* Set to `true` for a disabled checkbox.
113111
*/
@@ -190,6 +188,13 @@ export class Checkbox implements ControlValueAccessor, AfterViewInit {
190188
}
191189
}
192190

191+
@HostBinding("class.bx--checkbox-wrapper") get checkboxWrapperClass() {
192+
return !this.inline;
193+
}
194+
@HostBinding("class.bx--form-item") get formItemClass() {
195+
return !this.inline;
196+
}
197+
193198
/**
194199
* Emits event notifying other classes when a change in state occurs on a checkbox after a
195200
* click.
@@ -226,18 +231,6 @@ export class Checkbox implements ControlValueAccessor, AfterViewInit {
226231
Checkbox.checkboxCount++;
227232
}
228233

229-
/**
230-
* Creates a class name based on `@Input() size`, `@Input() inline`, and `@Input() nested`.
231-
* @return {string}
232-
*/
233-
public getVariantClass() {
234-
if (this.inline || this.nested) {
235-
return `checkbox${this.inline ? "--inline" : ""}${this.nested ? "--nested" : ""}${this.size !== "md" ? `-${this.size}` : ""}`;
236-
} else {
237-
return `checkbox${this.size !== "md" ? `--${this.size}` : ""}`;
238-
}
239-
}
240-
241234
/**
242235
* Toggle the selected state of the checkbox.
243236
* @memberof Checkbox

src/table/table.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ import { I18n } from "./../i18n/i18n.module";
175175
<th *ngIf="model.hasExpandableRows()"></th>
176176
<th *ngIf="!skeleton && showSelectionColumn" style="width: 10px;">
177177
<ibm-checkbox
178+
inline="true"
178179
[size]="size !== ('lg' ? 'sm' : 'md')"
179180
[(ngModel)]="selectAllCheckbox"
180181
[indeterminate]="selectAllCheckboxSomeSelected"
@@ -316,6 +317,7 @@ import { I18n } from "./../i18n/i18n.module";
316317
</td>
317318
<td *ngIf="!skeleton && showSelectionColumn">
318319
<ibm-checkbox
320+
inline="true"
319321
aria-label="Select row"
320322
[size]="size !== ('lg' ? 'sm' : 'md')"
321323
[(ngModel)]="model.rowsSelected[i]"

0 commit comments

Comments
 (0)