Skip to content

Commit fbcf50b

Browse files
committed
feat(checkbox): add disabled state
1 parent 67d73ff commit fbcf50b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/checkbox/ux-checkbox-theme.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,26 @@ styles.checkbox.checked>.box>.background-box {
5454
transform: scale3d(1, 1, 1);
5555
border-radius: 0;
5656
}
57+
58+
styles.checkbox[disabled=""],
59+
styles.checkbox[disabled="true"] {
60+
pointer-events: none;
61+
cursor: default;
62+
}
63+
64+
styles.checkbox[disabled=""]>.box:hover,
65+
styles.checkbox[disabled="true"]>.box:hover {
66+
border: ${disabledBorder || $swatches.grey.p400} solid 2px;
67+
border-radius: 3px;
68+
}
69+
70+
styles.checkbox.checked[disabled=""]>.box,
71+
styles.checkbox.checked[disabled="true"]>.box {
72+
background-color: ${disabledBackground || $swatches.grey.p500};
73+
border: ${disabledBackground || $swatches.grey.p500} solid 2px;
74+
}
75+
76+
styles.checkbox[disabled=""]>.box>.background-box::after,
77+
styles.checkbox[disabled="true"]>.box>.background-box::after {
78+
border-color: ${disabledForeground || $swatches.white};
79+
}

src/checkbox/ux-checkbox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { processDesignAttributes } from '../designs/design-attributes';
99
@customElement('ux-checkbox')
1010
@processAttributes(processDesignAttributes)
1111
export class UxCheckbox implements Themable {
12-
@bindable public disabled = false;
12+
@bindable public disabled: any = null;
1313
@bindable public effect = null;
1414
@bindable public matcher = (a: any, b: any) => a === b;
1515
@bindable public model: any;
@@ -59,6 +59,10 @@ export class UxCheckbox implements Themable {
5959
}
6060

6161
public toggleCheckbox() {
62+
if (this.disabled === true || this.disabled === '') {
63+
return;
64+
}
65+
6266
const elementValue = this.model ? this.model : this.value;
6367

6468
if (Array.isArray(this.checked)) {

0 commit comments

Comments
 (0)