File tree Expand file tree Collapse file tree 3 files changed +43
-23
lines changed Expand file tree Collapse file tree 3 files changed +43
-23
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ $md-mini-fab-padding: 8px !default;
6363 & [disabled ] {
6464 cursor : default ;
6565 }
66+
67+ & .md-button-focus {
68+ @include md-button-focus ();
69+ }
6670}
6771
6872// Applies styles to buttons with backgrounds: raised, fab, and mini-fab
@@ -85,11 +89,6 @@ $md-mini-fab-padding: 8px !default;
8589 @include md-elevation (8 );
8690 }
8791
88- & .md-button-focus {
89- background-color : md-color ($md-foreground , base , 0.12 );
90- @include md-button-theme (' background-color' , 600 );
91- }
92-
9392 & [disabled ] {
9493 box-shadow : none ;
9594 }
@@ -110,8 +109,4 @@ $md-mini-fab-padding: 8px !default;
110109 i , md-icon {
111110 padding : $padding 0 ;
112111 }
113-
114- & .md-button-focus {
115- background-color : md-color ($md-accent , 600 );
116- }
117112}
Original file line number Diff line number Diff line change 1-
2- // Applies specified coloring to three supported palettes
3- @mixin md-button-theme ($property , $color : ' default' , $opacity : 1 ) {
1+ /* * Applies a property to an md-button element for each of the supported palettes. */
2+ @mixin md-button-theme ($property , $color : ' default' , $opacity : 1 ) {
43 & .md-primary {
54 #{$property } : md-color ($md-primary , $color , $opacity );
65 }
1817 }
1918 }
2019}
20+
21+ /* * Applies a focus style to an md-button element for each of the supported palettes. */
22+ @mixin md-button-focus {
23+ & ::after {
24+ // The button spec calls for focus on raised buttons (and FABs) to be indicated with a
25+ // black, 12% opacity shade over the normal color (for both light and dark themes).
26+ // We do this by placing an :after psuedo-element with the appropriate shade over the button.
27+ position : absolute ;
28+ top : 0 ;
29+ left : 0 ;
30+ bottom : 0 ;
31+ right : 0 ;
32+ content : ' ' ;
33+ background-color : rgba (black , 0.12 );
34+ border-radius : inherit ;
35+ pointer-events : none ;
36+ }
37+
38+ & .md-primary ::after {
39+ background-color : md-color ($md-primary , 0.12 );
40+ }
41+
42+ & .md-accent ::after {
43+ background-color : md-color ($md-accent , 0.12 );
44+ }
45+
46+ & .md-warn ::after {
47+ background-color : md-color ($md-warn , 0.12 );
48+ }
49+ }
Original file line number Diff line number Diff line change 77[md-button ] {
88 @extend %md-button-base ;
99
10- & :hover , & .md-button-focus {
11- background-color : md-color ($md-foreground , base , 0.12 );
12- @include md-button-theme (' background-color' , 0.12 );
13- }
14-
1510 & [disabled ]:hover {
1611 & .md-primary , & .md-accent , & .md-warn , & :hover {
1712 background-color : transparent ;
4338 line-height : $md-icon-button-line-height ;
4439 border-radius : $md-icon-button-border-radius ;
4540
46- & .md-button-focus {
47- background-color : md-color ($md-foreground , base , 0.12 );
48- @include md-button-theme (' background-color' , 0.12 );
49- }
50-
5141 .md-button-wrapper > * {
5242 vertical-align : middle ;
5343 }
5444}
5545
46+ // Only flat buttons and icon buttons (not raised or fabs) have a hover style.
47+ [md-button ]:hover , [md-icon-button ]:hover {
48+ // Use the same visual treatment for hover as for focus.
49+ @include md-button-focus ();
50+ }
51+
5652// Applies a clearer border for high-contrast mode (a11y)
5753@media screen and (-ms-high-contrast : active ) {
5854 .md-raised-button , .md-fab , .md-mini-fab {
5955 border : 1px solid #fff ;
6056 }
61- }
57+ }
You can’t perform that action at this time.
0 commit comments