-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path_mixins.scss
339 lines (295 loc) · 7.87 KB
/
_mixins.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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
@mixin margin-selectors($before:1em, $after:1em, $start:0px, $end:0px) {
-webkit-margin-before: $before;
-webkit-margin-after: $after;
-webkit-margin-start: $start;
-webkit-margin-end: $end;
}
@mixin not-selectable($value:none) {
-webkit-touch-callout: $value;
-webkit-user-select: $value;
-khtml-user-select: $value;
-moz-user-select: $value;
-ms-user-select: $value;
user-select: $value;
}
@mixin input-placeholder-color($color) {
$pseudos: '::-webkit-input-placeholder', ':-moz-placeholder', '::-moz-placeholder',
':-ms-input-placeholder', '::-webkit-input-placeholder';
// It is important to export every pseudo within its own block, because otherwise the placeholder
// won't be set on the most browsers.
@each $pseudo in $pseudos {
&#{$pseudo} {
color: unquote($color);
}
}
}
@mixin pie-clearfix {
&:after {
content: '';
display: table;
clear: both;
}
}
@mixin md-shadow-bottom-z-1() {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
}
@mixin md-shadow-bottom-z-2() {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.4);
}
// Mixin for a "flat" input that can be used for components that contain an input
// (datepicker, autocomplete).
@mixin md-flat-input() {
font-size: 14px;
box-sizing: border-box;
border: none;
box-shadow: none;
outline: none;
background: transparent;
// The "clear X" that IE adds to input[type="search"]
&::-ms-clear {
display: none;
}
}
// Typography mixins
@mixin md-title() {
font-size: $title-font-size-base;
font-weight: 500;
letter-spacing: 0.005em;
}
@mixin md-body-1() {
font-size: $body-font-size-base;
font-weight: 400;
letter-spacing: 0.010em;
line-height: rem(2);
}
@mixin md-body-2() {
font-size: $body-font-size-base;
font-weight: 500;
letter-spacing: 0.010em;
line-height: rem(2.4);
}
@mixin md-subhead() {
font-size: $subhead-font-size-base;
font-weight: 400;
letter-spacing: 0.010em;
line-height: rem(2.4);
}
@function map-to-string($map) {
$map-str: '{';
$keys: map-keys($map);
$len: length($keys);
@for $i from 1 through $len {
$key: nth($keys, $i);
$value: map-get($map, $key);
$map-str: $map-str + '_' + $key + '_: _' + map-get($map, $key) + '_';
@if $i != $len {
$map-str: $map-str + ',';
}
}
@return $map-str + '}';
}
// This is a mixin, which fixes IE11's vertical alignment issue, when using `min-height`.
// See https://connect.microsoft.com/IE/feedback/details/816293/
@mixin ie11-min-height-flexbug($min-height) {
&::before {
content: '';
min-height: $min-height;
visibility: hidden;
display: inline-block;
}
}
// mixin definition ; sets LTR and RTL within the same style call
// @see https://css-tricks.com/almanac/properties/d/direction/
@mixin rtl($prop, $ltr-value, $rtl-value) {
#{$prop}: $ltr-value;
[dir=rtl] & {
#{$prop}: $rtl-value;
}
}
@mixin rtl-prop($ltr-prop, $rtl-prop, $value, $reset-value) {
#{$ltr-prop}: $value;
[dir=rtl] & {
#{$ltr-prop}: $reset-value;
#{$rtl-prop}: $value;
}
}
// To reverse padding (top left bottom right) -> (top right bottom left)
@function rtl-value($list) {
@if length($list) == 4 {
@return nth($list, 1) nth($list, 4) nth($list, 3) nth($list, 2)
}
@if length($list) == 5 {
@return nth($list, 1) nth($list, 4) nth($list, 3) nth($list, 2) nth($list, 5)
}
@return $list;
}
// Position a FAB button.
@mixin fab-position($spot, $top: auto, $right: auto, $bottom: auto, $left: auto) {
&.md-fab-#{$spot} {
top: $top;
right: $right;
bottom: $bottom;
left: $left;
position: absolute;
}
}
@mixin fab-all-positions() {
@include fab-position(bottom-right, auto, ($button-fab-width - $button-fab-padding)/2, ($button-fab-height - $button-fab-padding)/2, auto);
@include fab-position(bottom-left, auto, auto, ($button-fab-height - $button-fab-padding)/2, ($button-fab-width - $button-fab-padding)/2);
@include fab-position(top-right, ($button-fab-height - $button-fab-padding)/2, ($button-fab-width - $button-fab-padding)/2, auto, auto);
@include fab-position(top-left, ($button-fab-height - $button-fab-padding)/2, auto, auto, ($button-fab-width - $button-fab-padding)/2);
}
// This mixin allows a user to use the md-checkbox css outside of the
// md-checkbox directive.
// See src/components/select/select.scss for an example.
@mixin checkbox-container(
$checkedSelector: '.md-checked',
$width: $checkbox-width,
$height: $checkbox-height,
$border-width: $checkbox-border-width,
$border-radius: $checkbox-border-radius) {
.md-container {
position: absolute;
top: 50%;
transform: translateY(-50%);
box-sizing: border-box;
display: inline-block;
width: $width;
height: $height;
@include rtl(left, 0, auto);
@include rtl(right, auto, 0);
&:before {
box-sizing: border-box;
background-color: transparent;
border-radius: 50%;
content: '';
position: absolute;
display: block;
height: auto;
left: 0;
top: 0;
right: 0;
bottom: 0;
transition: all 0.5s;
width: auto;
}
&:after {
box-sizing: border-box;
content: '';
position: absolute;
top: -10px;
right: -10px;
bottom: -10px;
left: -10px;
}
.md-ripple-container {
position: absolute;
display: block;
width: auto;
height: auto;
left: -15px;
top: -15px;
right: -15px;
bottom: -15px;
}
}
// unchecked
.md-icon {
box-sizing: border-box;
transition: 240ms;
position: absolute;
top: 0;
left: 0;
width: $width;
height: $height;
border-width: $border-width;
border-style: solid;
border-radius: $border-radius;
}
&#{$checkedSelector} .md-icon {
border-color: transparent;
&:after {
box-sizing: border-box;
transform: rotate(45deg);
position: absolute;
left: $width / 3 - $border-width;
top: $width / 9 - $border-width;
display: table;
width: $width / 3;
height: $width * 2 / 3;
border-width: $border-width;
border-style: solid;
border-top: 0;
border-left: 0;
content: '';
}
}
// disabled
&[disabled] {
cursor: default;
}
&.md-indeterminate .md-icon {
&:after {
box-sizing: border-box;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: table;
width: $width * 0.6;
height: $border-width;
border-width: $border-width;
border-style: solid;
border-top: 0;
border-left: 0;
content: '';
}
}
}
// Mixin to create a primary checkbox.
// Used by the checkbox and select component.
@mixin checkbox-primary($checkedSelector: '.md-checked') {
.md-ripple {
color: '{{primary-600}}';
}
&#{$checkedSelector} .md-ripple {
color: '{{background-600}}';
}
.md-ink-ripple {
color: '{{foreground-2}}';
}
&#{$checkedSelector} .md-ink-ripple {
color: '{{primary-color-0.87}}';
}
&:not(.md-checked) .md-icon {
border-color: '{{foreground-2}}';
}
&#{$checkedSelector} .md-icon {
background-color: '{{primary-color-0.87}}';
}
&#{$checkedSelector}.md-focused .md-container:before {
background-color: '{{primary-color-0.26}}';
}
&#{$checkedSelector} .md-icon:after {
border-color: '{{primary-contrast-0.87}}';
}
& .md-indeterminate[disabled] {
.md-container {
color: '{{foreground-3}}';
}
}
}
@mixin dense($prop, $normal, $dense) {
#{$prop}: $normal;
.md-dense > &:not(.md-dense-disabled),
.md-dense :not(.md-dense-disabled) &:not(.md-dense-disabled) {
#{$prop}: $dense;
}
}
@mixin dense-rtl($prop, $ltr-normal, $rtl-normal, $ltr-dense, $rtl-dense) {
@include rtl($prop, $ltr-normal, $rtl-normal);
.md-dense > &:not(.md-dense-disabled),
.md-dense :not(.md-dense-disabled) &:not(.md-dense-disabled) {
@include rtl($prop, $ltr-dense, $rtl-dense);
}
}