1
- @import " variables" ;
2
- @import " shadows" ;
3
-
4
- // TODO(jelbourn): This goes away.
5
- @import " default-theme" ;
6
-
7
- // TODO(jelbourn): Move variables and mixins into a partial file.
8
1
// TODO(jelbourn): Measure perf benefits for translate3d and will-change.
9
2
// TODO(jelbourn): Figure out if anchor hover underline actually happens in any browser.
10
3
4
+ @import " button-base" ;
11
5
12
- // Standard button sizing.
13
- $md-button-padding : 0 rem (0.600 ) !default ;
14
- $md-button-min-width : rem (8.800 ) !default ;
15
- $md-button-margin : rem (0.600 ) rem (0.800 ) !default ;
16
- $md-button-line-height : rem (3.60 ) !default ;
17
- $md-button-border-radius : 3px !default ;
18
-
19
- // FAB sizing.
20
- $md-fab-size : rem (5.600 ) !default ;
21
- $md-fab-line-height : rem (5.600 ) !default ;
22
- $md-fab-padding : rem (1.60 ) !default ;
23
- $md-fab-mini-size : rem (4.00 ) !default ;
24
- $md-fab-mini-line-height : rem (4.00 ) !default ;
25
-
26
- /* * Mixin to create distinct classes for fab positions, e.g. ".md-fab-position-bottom-right". */
27
- @mixin md-fab-position ($spot , $top : auto , $right : auto , $bottom : auto , $left : auto ) {
28
- .md-fab-position-#{$spot } {
29
- top : $top ;
30
- right : $right ;
31
- bottom : $bottom ;
32
- left : $left ;
33
- position : absolute ;
34
- }
35
- }
36
-
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. */
45
- @mixin md-button-base () {
46
- box-sizing : border-box ;
47
- position : relative ;
48
-
49
- // Reset browser <button> styles.
50
- background : transparent ;
51
- text-align : center ;
52
- overflow : hidden ;
53
- cursor : pointer ;
54
- user-select : none ;
55
- outline : none ;
56
- border : none ;
57
-
58
- // Make anchors render like buttons.
59
- display : inline-block ;
60
- white-space : nowrap ;
61
- text-decoration : none ;
62
- vertical-align : middle ;
63
-
64
- // Typography.
65
- font-size : $md-body-font-size-base ;
66
- font-weight : 500 ;
67
-
68
- // Sizing.
69
- padding : $md-button-padding ;
70
- margin : $md-button-margin ;
71
- min-width : $md-button-min-width ;
72
- line-height : $md-button-line-height ;
73
- border-radius : $md-button-border-radius ;
74
-
75
- // Animation.
76
- transition : background $swift-ease-out-duration $swift-ease-out-timing-function ,
77
- box-shadow $swift-ease-out-duration $swift-ease-out-timing-function ;
78
-
79
- // Hide the browser focus indicator, instead applying our own focus style on background-color.
80
- & :focus {
81
- outline : none ;
82
- }
83
-
84
- & :hover , & :focus {
85
- // Remove anchor underline again for more specific modifiers.
86
- text-decoration : none ;
87
- }
6
+ // TODO(kara): Replace attribute selectors with class selectors when possible
7
+ [md-button ] {
8
+ @extend %md-button-base ;
88
9
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
10
& :hover , & .md-button-focus {
92
- background : md-color ($md-background , background , 0.2 );
93
- }
94
-
95
- & .md-primary {
96
- color : md-color ($md-primary );
97
- }
98
-
99
- & .md-accent {
100
- color : md-color ($md-accent );
101
- }
102
-
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 ();
107
- }
108
- }
109
-
110
- /* * Base styles for raised buttons, including FABs. */
111
- @mixin md-raised-button () {
112
- @include md-button-base ();
113
-
114
- // Force hardware acceleration.
115
- transform : translate3d (0 , 0 , 0 );
116
-
117
- box-shadow : $md-shadow-bottom-z-1 ;
118
-
119
- & :active {
120
- box-shadow : $md-shadow-bottom-z-2 ;
121
- }
122
-
123
- & [disabled ] {
124
- box-shadow : none ;
125
- }
126
-
127
- & .md-primary {
128
- color : md-color ($md-primary , default-contrast );
129
- background-color : md-color ($md-primary );
130
-
131
- & :hover , & .md-button-focus {
132
- background-color : md-color ($md-primary , 600 );
133
- }
134
- }
135
-
136
- & .md-accent {
137
- color : md-color ($md-accent , default-contrast );
138
- background-color : md-color ($md-accent );
139
-
140
- & :hover , & .md-button-focus {
141
- background-color : md-color ($md-accent , A700 );
142
- }
11
+ background-color : md-color ($md-foreground , base , 0.12 );
12
+ @include md-button-theme (' background-color' , 0.12 );
143
13
}
144
14
145
- & .md-primary , & .md-accent {
146
- & [ disabled ] {
147
- @include md-button-disabled () ;
15
+ & [ disabled ] :hover {
16
+ & .md-primary , & .md-accent , & .md-warn , & :hover {
17
+ background-color : transparent ;
148
18
}
149
19
}
150
20
}
151
21
152
-
153
- [md-button ] {
154
- @include md-button-base ();
155
- }
156
-
157
22
[md-raised-button ] {
158
- @include md-raised-button ();
159
-
160
- color : md-color ($md-foreground , text );
161
- background-color : md-color ($md-background , background );
23
+ @extend %md-raised-button ;
162
24
}
163
25
164
26
[md-fab ] {
165
- @include md-raised-button ();
166
-
167
- z-index : $z-index-fab ;
168
-
169
- border-radius : 50% ;
170
- min-width : 0 ;
171
- width : $md-fab-size ;
172
- height : $md-fab-size ;
173
- line-height : $md-fab-line-height ;
174
- vertical-align : middle ;
27
+ @include md-fab ($md-fab-size , $md-fab-padding );
28
+ }
175
29
176
- & .md-mini {
177
- line-height : $md-fab-mini-line-height ;
178
- width : $md-fab-mini-size ;
179
- height : $md-fab-mini-size ;
180
- }
30
+ [md-mini-fab ] {
31
+ @include md-fab ($md-mini-fab-size , $md-mini-fab-padding )
181
32
}
182
33
183
- // Styles for high contrast mode.
34
+ // Applies a clearer border for high- contrast mode (a11y)
184
35
@media screen and (-ms-high-contrast : active ) {
185
- [md-raised ],
186
- [md-fab ] {
36
+ .md-raised-button , .md-fab , .md-mini-fab {
187
37
border : 1px solid #fff ;
188
38
}
189
- }
190
-
191
- $md-fab-pos-offset : ($md-fab-size - $md-fab-padding ) / 2 ;
192
- @include md-fab-position (bottom- right, auto , $md-fab-pos-offset , $md-fab-pos-offset , auto );
193
- @include md-fab-position (bottom- left, auto , auto , $md-fab-pos-offset , $md-fab-pos-offset );
194
- @include md-fab-position (top- right, $md-fab-pos-offset , $md-fab-pos-offset , auto , auto );
195
- @include md-fab-position (top- left, $md-fab-pos-offset , auto , auto , $md-fab-pos-offset );
39
+ }
0 commit comments