This repository was archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy path_button-base.scss
297 lines (254 loc) · 8.11 KB
/
_button-base.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
//
// Copyright 2020 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// stylelint-disable selector-class-pattern --
// Selector '.mdc-*' should only be used in this project.
@use '@material/elevation/elevation';
@use '@material/elevation/elevation-theme';
@use '@material/feature-targeting/feature-targeting';
@use '@material/ripple/ripple-theme';
@use '@material/rtl/rtl';
@use '@material/dom/dom';
@use '@material/touch-target/touch-target';
@use '@material/focus-ring/focus-ring';
@use '@material/typography/typography';
@use './button-shared-theme';
@mixin static-styles($query: feature-targeting.all()) {
@include _static-styles-base($query: $query);
@include _typography-styles($query: $query);
}
@mixin _static-styles-base($query: feature-targeting.all()) {
$feat-structure: feature-targeting.create-target($query, structure);
@include touch-target.wrapper($query); // COPYBARA_COMMENT_THIS_LINE
// prettier-ignore
@include elevation.overlay-common($query); // COPYBARA_COMMENT_THIS_LINE
// postcss-bem-linter: define button
.mdc-button {
@include _root-structure($query);
// The icon CSS class overrides styles defined in the .material-icons CSS
// class, which is loaded separately so the order of CSS definitions is not
// guaranteed. Therefore, increase specifity by nesting this class to ensure
// overrides apply.
.mdc-button__icon {
@include feature-targeting.targets($feat-structure) {
@include _icon-structure;
}
}
.mdc-button__progress-indicator {
@include feature-targeting.targets($feat-structure) {
font-size: 0;
position: absolute;
@include rtl.ignore-next-line();
transform: translate(-50%, -50%);
top: 50%;
@include rtl.ignore-next-line();
left: 50%;
line-height: initial;
}
}
.mdc-button__label {
@include feature-targeting.targets($feat-structure) {
// Necessary such that label is stacked on top of ripple
// (since ripple is a positioned element, non-positioned elements
// appear under it).
position: relative;
}
}
.mdc-button__focus-ring {
@include focus-ring.focus-ring($query: $query);
@include feature-targeting.targets($feat-structure) {
display: none;
}
}
@include ripple-theme.focus {
.mdc-button__focus-ring {
@include dom.forced-colors-mode($exclude-ie11: true) {
@include feature-targeting.targets($feat-structure) {
display: block;
}
}
}
}
.mdc-button__touch {
@include touch-target.touch-target($query: $query);
}
}
.mdc-button__label + .mdc-button__icon {
@include feature-targeting.targets($feat-structure) {
@include icon-trailing;
}
}
svg.mdc-button__icon {
@include feature-targeting.targets($feat-structure) {
@include icon-svg;
}
}
.mdc-button--touch {
// Touch target doesn't change with height. It simply gets removed if
// density (height) changes. Therefore, it is a static style.
@include touch-target.margin(
$component-height: button-shared-theme.$height,
$query: $query
);
}
// postcss-bem-linter: end
}
@mixin _typography-styles($query) {
.mdc-button {
// Exclude properties declared in theme styles.
@include typography.typography(
button,
$exclude-props: (
font-size,
line-height,
font-weight,
letter-spacing,
text-transform
),
$query: $query
);
}
}
/// @deprecated Contains typography declarations now part of theme-styles.
@mixin deprecated-static-styles-without-ripple(
$query: feature-targeting.all()
) {
@include _deprecated-typography-styles($query: $query);
@include _static-styles-base($query: $query);
}
@mixin _deprecated-typography-styles($query) {
.mdc-button {
@include typography.typography(button, $query);
}
}
@mixin deprecated-base($query) {
@include base($query);
}
@mixin base($query) {
@include typography.typography(button, $query);
@include _root-structure($query: $query);
}
@mixin _root-structure($query) {
$feat-structure: feature-targeting.create-target($query, structure);
@include elevation-theme.overlay-surface-position($query: $query);
@include elevation-theme.overlay-dimensions(100%, $query: $query);
@include feature-targeting.targets($feat-structure) {
display: inline-flex;
// position: relative; already set in mdc-elevation-overlay-surface-position
align-items: center;
justify-content: center;
box-sizing: border-box;
min-width: 64px;
border: none;
outline: none;
/* @alternate */
line-height: inherit;
user-select: none;
-webkit-appearance: none;
// Even though `visible` is the default, IE 11 computes the property as
// `hidden` in some cases, unless it's explicitly defined here.
overflow: visible;
vertical-align: middle;
background: transparent;
}
&::-moz-focus-inner {
@include feature-targeting.targets($feat-structure) {
padding: 0;
border: 0;
}
}
// postcss-bem-linter: ignore
&:active {
@include feature-targeting.targets($feat-structure) {
outline: none;
}
}
&:hover {
@include feature-targeting.targets($feat-structure) {
cursor: pointer;
}
}
&:disabled {
@include feature-targeting.targets($feat-structure) {
cursor: default;
pointer-events: none;
}
}
&[hidden] {
@include feature-targeting.targets($feat-structure) {
display: none;
}
}
}
@mixin icon {
@include _icon-structure;
@include _icon-size(18px);
}
@mixin _icon-structure {
@include rtl.reflexive-box(margin, right, 8px);
display: inline-block;
position: relative;
vertical-align: top;
}
@mixin _icon-size($size-px) {
$icon-size: typography.px-to-rem($size-px);
font-size: $icon-size;
height: $icon-size;
width: $icon-size;
}
@mixin icon-trailing {
@include rtl.reflexive-box(margin, left, 8px);
}
@mixin icon-svg {
fill: currentColor;
}
@mixin icon-contained {
@include rtl.reflexive-property(margin, -4px, 8px);
}
@mixin icon-contained-trailing {
@include rtl.reflexive-property(margin, 8px, -4px);
}
@mixin raised-transition($query: feature-targeting.all()) {
$feat-animation: feature-targeting.create-target($query, animation);
@include feature-targeting.targets($feat-animation) {
transition: elevation-theme.transition-value();
}
}
/// @deprecated Private style mixin for partners; not available for public use.
@mixin deprecated-icon {
@include icon;
}
/// @deprecated Private style mixin for partners; not available for public use.
@mixin deprecated-icon-trailing {
@include icon-trailing;
}
/// @deprecated Private style mixin for partners; not available for public use.
@mixin deprecated-icon-svg {
@include icon-svg;
}
/// @deprecated Private style mixin for partners; not available for public use.
@mixin deprecated-icon-contained {
@include icon-contained;
}
/// @deprecated Private style mixin for partners; not available for public use.
@mixin deprecated-icon-contained-trailing {
@include icon-contained-trailing;
}