Skip to content

Commit b21c8c1

Browse files
committed
add mixin for applying disabled state
1 parent de99472 commit b21c8c1

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/material-experimental/mdc-button/_mdc-button.scss

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-background));
1212
}
1313

14+
// Wraps the content style in a selector for the disabled state.
15+
// MDC adds theme color by using :not(:disabled), so just using [disabled] once will not
16+
// override this, neither will it apply to anchor tags. This needs to override the
17+
// previously set theme color, so it must be ordered after the theme styles.
18+
@mixin _mat-button-apply-disabled-style() {
19+
&[disabled][disabled] {
20+
@content;
21+
}
22+
}
23+
1424
// Applies the disabled theme background color for raised buttons. Value is taken from
1525
// mixin `mdc-button--filled`
1626
@mixin _mat-button-disabled-background() {
@@ -54,7 +64,7 @@
5464
@include mdc-states-base-color(on-error, $query: $mat-theme-styles-query);
5565
}
5666

57-
&[disabled][disabled] {
67+
@include _mat-button-apply-disabled-style() {
5868
@include _mat-button-disabled-background();
5969
}
6070
}
@@ -68,23 +78,20 @@
6878
@include mdc-button-outline-color(error, $query: $mat-theme-styles-query);
6979
}
7080

71-
&[disabled][disabled] {
81+
@include _mat-button-apply-disabled-style() {
7282
@include mdc-theme-prop(border-color,
7383
mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-background));
7484
}
7585
}
7686

7787
.mat-mdc-raised-button {
78-
&[disabled][disabled] {
88+
@include _mat-button-apply-disabled-style() {
7989
@include mdc-elevation(0, $query: $mat-theme-styles-query);
8090
}
8191
}
8292

83-
// MDC adds theme color by using :not(:disabled), so just using [disabled] once will not
84-
// override this and also will not apply to anchor tags. This needs to override the
85-
// previously set theme color, so it must be ordered after the theme styles.
8693
.mat-mdc-button, .mat-mdc-raised-button, .mat-mdc-unelevated-button, .mat-mdc-outlined-button {
87-
&[disabled][disabled] {
94+
@include _mat-button-apply-disabled-style() {
8895
@include _mat-button-disabled-color();
8996
}
9097
}
@@ -117,7 +124,7 @@
117124
@include mdc-fab-ink-color(on-error, $query: $mat-theme-styles-query);
118125
}
119126

120-
&[disabled][disabled] {
127+
@include _mat-button-apply-disabled-style() {
121128
@include _mat-button-disabled-color();
122129
@include _mat-button-disabled-background();
123130
@include mdc-elevation(0, $query: $mat-theme-styles-query);
@@ -151,7 +158,7 @@
151158
@include mdc-icon-button-ink-color(error, $query: $mat-theme-styles-query);
152159
}
153160

154-
&[disabled][disabled] {
161+
@include _mat-button-apply-disabled-style() {
155162
@include _mat-button-disabled-color();
156163
}
157164
}

0 commit comments

Comments
 (0)