File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ styles.button.raised {
5353 box-shadow : ${$design.elevation2dp };
5454}
5555
56- styles .button .raised . disabled , styles .button .fab . disabled {
56+ styles .button .raised : disabled , styles .button .fab : disabled {
5757 background-color : ${backgroundDisabled || $design.accentLight };
5858 color : ${foregroundDisabled || $design.accentLightForeground };
5959}
@@ -63,11 +63,21 @@ styles.button.raised:active {
6363 transition- delay: 0s;
6464}
6565
66+ styles .button .raised : disabled : active , styles .button .fab : disabled : active {
67+ box-shadow : ${$design.elevation2dp };
68+ transition- delay: 0s;
69+ }
70+
6671styles .button .raised : focus {
6772 box-shadow : ${$design.elevationFocus };
6873 transition- delay: 0s;
6974}
7075
76+ styles .button .raised : disabled : focus , styles .button .fab : disabled : focus {
77+ box-shadow : ${$design.elevation2dp };
78+ transition- delay: 0s;
79+ }
80+
7181
7282styles .button .flat , styles .button .icon {
7383 background-color : transparent;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export class UxButton implements Themable {
1212 @bindable public type = null ;
1313 @bindable public size = null ;
1414 @bindable public effect = null ;
15- @bindable public disabled = false ;
15+ @bindable public disabled : boolean | string = false ;
1616 @bindable public theme = null ;
1717
1818 public view : View ;
@@ -29,12 +29,35 @@ export class UxButton implements Themable {
2929 if ( this . theme ) {
3030 this . styleEngine . applyTheme ( this , this . theme ) ;
3131 }
32+
33+ // ensure we cast empty string as true
34+ if ( typeof this . disabled === 'string' && this . disabled === '' ) {
35+ this . disabled = true ;
36+ }
37+
38+ if ( this . disabled ) {
39+ this . button . setAttribute ( 'disabled' , '' ) ;
40+ }
41+
3242 }
3343
3444 public themeChanged ( newValue : any ) {
3545 this . styleEngine . applyTheme ( this , newValue ) ;
3646 }
3747
48+ public disabledChanged ( newValue : boolean | string ) {
49+ // ensure we cast empty string as true
50+ if ( typeof newValue === 'string' && newValue === '' ) {
51+ newValue = true ;
52+ }
53+
54+ if ( newValue ) {
55+ this . button . setAttribute ( 'disabled' , '' ) ;
56+ } else {
57+ this . button . removeAttribute ( 'disabled' ) ;
58+ }
59+ }
60+
3861 public onMouseDown ( e : MouseEvent ) {
3962 if ( this . button . classList . contains ( 'ripple' ) ) {
4063 if ( this . ripple === null ) {
You can’t perform that action at this time.
0 commit comments