Skip to content

Commit 01da937

Browse files
committed
feat(api): add new options inline, horizontal and right
Also includes emitting value-change correctly.
1 parent 229535c commit 01da937

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/client/scripts/rb-checkbox.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ export class RbCheckbox extends FormControl(RbBase()) {
1616
formControl: this.shadowRoot.querySelector('input')
1717
});
1818
}
19-
updated(prevProps, prevState) { // :void (runs before viewReady())
20-
if (super.updated) super.updated(prevProps, prevState);
21-
if (!this.rb.view.isReady) return;
22-
if (prevProps.value === this.value) return;
23-
// runs after view updated (required)
24-
this.rb.events.emit(this, 'value-changed', {
25-
detail: { value: this.value }
26-
});
27-
}
2819

2920
/* Properties
3021
*************/
@@ -33,6 +24,9 @@ export class RbCheckbox extends FormControl(RbBase()) {
3324
...super.props,
3425
kind: props.string,
3526
label: props.string,
27+
inline: props.boolean,
28+
horizontal: props.boolean,
29+
right: props.boolean,
3630
sublabel: props.string,
3731
subtext: props.string,
3832
value: Object.assign({}, props.any, {
@@ -63,7 +57,16 @@ export class RbCheckbox extends FormControl(RbBase()) {
6357
}
6458
async setValue(value) { // :void
6559
this.value = !value;
66-
await this.validate();
60+
// await this.validate();
61+
}
62+
63+
/* Observer
64+
***********/
65+
updating(prevProps) { // :void
66+
if (prevProps.value === this.value) return;
67+
this.rb.events.emit(this, 'value-changed', {
68+
detail: { value: this.value }
69+
});
6770
}
6871

6972
/* Event Handlers

src/client/styles/rb-checkbox.scss

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@import 'main/checkbox.scss';
1515
@import 'main/subtext.scss';
1616
// In Order!
17+
@import 'main/layout.scss';
1718
@import 'main/states.scss';
1819
@import 'main/disabled.scss';
1920
}

src/client/views/rb-checkbox.html

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
?disabled="${props.disabled}"
33
class="
44
rb-checkbox
5+
${props.inline ? 'inline' : ''}
6+
${props.horizontal ? 'horizontal' : ''}
7+
${props.right ? 'right' : ''}
58
${props._valid ? 'valid' : 'invalid'}
69
">
710

0 commit comments

Comments
 (0)