44// TODO(jelbourn): This goes away.
55@import " ../../core/style/default-theme" ;
66
7+ // TODO(jelbourn): Move variables and mixins into a partial file.
8+ // TODO(jelbourn): Measure perf benefits for translate3d and will-change.
9+ // TODO(jelbourn): Figure out if anchor hover underline actually happens in any browser.
10+
711
812// Standard button sizing.
913$md-button-padding : 0 rem (0.600 ) !default ;
@@ -19,7 +23,7 @@ $md-fab-padding: rem(1.60) !default;
1923$md-fab-mini-size : rem (4.00 ) !default ;
2024$md-fab-mini-line-height : rem (4.00 ) !default ;
2125
22- /* * Mixin to create distinct classes for fab positions, e.g. ".md-fab-bottom-right". */
26+ /* * Mixin to create distinct classes for fab positions, e.g. ".md-fab-position- bottom-right". */
2327@mixin md-fab-position ($spot , $top : auto , $right : auto , $bottom : auto , $left : auto ) {
2428 .md-fab-position-#{$spot } {
2529 top : $top ;
@@ -30,14 +34,17 @@ $md-fab-mini-line-height: rem(4.00) !default;
3034 }
3135}
3236
33- // Base styles for all buttons.
37+ /* * Styles for all disabled buttons. */
38+ @mixin md-button-disabled () {
39+ color : md-color ($md-foreground , disabled );
40+ background-color : transparent ;
41+ cursor : default ;
42+ }
43+
44+ /* * Base styles for all buttons. */
3445@mixin md-button-base () {
3546 box-sizing : border-box ;
3647 position : relative ;
37- display : inline-block ;
38-
39- font-size : $md-body-font-size-base ;
40- font-weight : 500 ;
4148
4249 // Reset browser <button> styles.
4350 background : transparent ;
@@ -48,9 +55,15 @@ $md-fab-mini-line-height: rem(4.00) !default;
4855 outline : none ;
4956 border : none ;
5057
51- // Apply nowrap and remove underline for anchor md-buttons.
58+ // Make anchors render like buttons.
59+ display : inline-block ;
5260 white-space : nowrap ;
5361 text-decoration : none ;
62+ vertical-align : middle ;
63+
64+ // Typography.
65+ font-size : $md-body-font-size-base ;
66+ font-weight : 500 ;
5467
5568 // Sizing.
5669 padding : $md-button-padding ;
@@ -60,18 +73,22 @@ $md-fab-mini-line-height: rem(4.00) !default;
6073 border-radius : $md-button-border-radius ;
6174
6275 // Animation.
63- // TODO(jelbourn): figure out where will-change would be beneficial.
64- transition : background $swift-ease-out-duration $swift-ease-out-timing-function ;
76+ transition : background $swift-ease- out-duration $swift-ease-out-timing-function ,
77+ box-shadow $swift-ease-out-duration $swift-ease-out-timing-function ;
6578
66- // Hide the default browser focus indicator.
79+ // Hide the browser focus indicator, instead applying our own focus style on background-color .
6780 & :focus {
6881 outline : none ;
6982 }
7083
7184 & :hover , & :focus {
7285 // Remove anchor underline again for more specific modifiers.
7386 text-decoration : none ;
87+ }
7488
89+ // Use a CSS class for focus style because we only want to render the focus style when
90+ // the focus originated from a keyboard event (see JS source for more details).
91+ & :hover , & .md-button-focus {
7592 background : md-color ($md-background , 500 , 0.2 );
7693 }
7794
@@ -83,10 +100,10 @@ $md-fab-mini-line-height: rem(4.00) !default;
83100 color : md-color ($md-accent );
84101 }
85102
86- & :disabled {
87- color : md-color ( $md-foreground , disabled );
88- background-color : transparent ;
89- cursor : default ;
103+ // Use the [disabled] attribute instead of the :disabled pseudo-class because anchors
104+ // cannot technically be : disabled.
105+ & [ disabled ] {
106+ @include md-button-disabled () ;
90107 }
91108}
92109
@@ -95,29 +112,40 @@ $md-fab-mini-line-height: rem(4.00) !default;
95112 @include md-button-base ();
96113
97114 // Force hardware acceleration.
98- // TODO(jelbourn): determine if this actually has an impact.
99115 transform : translate3d (0 , 0 , 0 );
100- box-shadow : $md-shadow-bottom-z-1 ;
101116
102- transition : background $swift-ease-out-duration $swift-ease-out-timing-function ,
103- box-shadow $swift-ease-out-duration $swift-ease-out-timing-function ;
117+ box-shadow : $md-shadow-bottom-z-1 ;
104118
105119 & :active {
106120 box-shadow : $md-shadow-bottom-z-2 ;
107121 }
108122
109- & : disabled {
123+ & [ disabled ] {
110124 box-shadow : none ;
111125 }
112126
113127 & .md-primary {
114128 color : md-color ($md-primary , default-contrast );
115129 background-color : md-color ($md-primary );
130+
131+ & :hover , & .md-button-focus {
132+ background-color : md-color ($md-primary , 600 );
133+ }
116134 }
117135
118136 & .md-accent {
119137 color : md-color ($md-accent , default-contrast );
120138 background-color : md-color ($md-accent );
139+
140+ & :hover , & .md-button-focus {
141+ background-color : md-color ($md-accent , A700 );
142+ }
143+ }
144+
145+ & .md-primary , & .md-accent {
146+ & [disabled ] {
147+ @include md-button-disabled ();
148+ }
121149 }
122150}
123151
@@ -145,8 +173,6 @@ $md-fab-mini-line-height: rem(4.00) !default;
145173 line-height : $md-fab-line-height ;
146174 vertical-align : middle ;
147175
148- // TODO(jelbourn): May need `background-clip: padding-box;` depending on ripple implementation.
149-
150176 & .md-mini {
151177 line-height : $md-fab-mini-line-height ;
152178 width : $md-fab-mini-size ;
0 commit comments