|
34 | 34 | @import "./variables"; |
35 | 35 | @import "./functions"; |
36 | 36 |
|
37 | | -@mixin mdc-text-field-shape-radius($radius, $rtl-reflexive: false) { |
| 37 | +/// |
| 38 | +/// Sets height of default text field variant. |
| 39 | +/// |
| 40 | +/// @param {Number} $height |
| 41 | +/// @access public |
| 42 | +/// |
| 43 | +@mixin mdc-text-field-height($height) { |
| 44 | + height: $height; |
| 45 | +} |
| 46 | + |
| 47 | +/// |
| 48 | +/// Sets height of outlined text field variant. |
| 49 | +/// |
| 50 | +/// @param {Number} $height |
| 51 | +/// @access public |
| 52 | +/// |
| 53 | +@mixin mdc-text-field-outlined-height($height) { |
| 54 | + $keyframe-name: text-field-outlined-#{$height}; |
| 55 | + $positionY: mdc-text-field-get-outlined-label-position-y($height); |
| 56 | + |
| 57 | + @include mdc-notched-outline-floating-label-float-position-absolute($positionY); |
| 58 | + @include mdc-floating-label-shake-keyframes($keyframe-name, $positionY); |
| 59 | + @include mdc-floating-label-shake-animation($keyframe-name); |
| 60 | + @include mdc-text-field-height($height); |
| 61 | +} |
| 62 | + |
| 63 | +/// |
| 64 | +/// Sets shape radius of default text field variant. |
| 65 | +/// |
| 66 | +/// @param {Number} $radius Shape radius value in `px` or in percentage. |
| 67 | +/// @param {Number} $text-field-height Height of default text field variant. Required only when `$radius` is in |
| 68 | +/// percentage unit and if text field has custom height. Defaults to `$mdc-text-field-height`. |
| 69 | +/// @param {Boolean} $rtl-reflexive Set to true to flip shape radius in RTL context. Defaults to `false`. |
| 70 | +/// |
| 71 | +@mixin mdc-text-field-shape-radius($radius, $text-field-height: $mdc-text-field-height, $rtl-reflexive: false) { |
38 | 72 | @if length($radius) > 2 { |
39 | 73 | @error "Invalid radius: '#{$radius}' component doesn't allow customizing all corners"; |
40 | 74 | } |
41 | 75 |
|
42 | 76 | $masked-radius: mdc-shape-mask-radius($radius, 1 1 0 0); |
43 | 77 |
|
44 | 78 | @include mdc-shape-radius( |
45 | | - mdc-shape-resolve-percentage-radius($mdc-text-field-height, $masked-radius), |
| 79 | + mdc-shape-resolve-percentage-radius($text-field-height, $masked-radius), |
46 | 80 | $rtl-reflexive |
47 | 81 | ); |
48 | 82 | } |
|
222 | 256 | } |
223 | 257 | } |
224 | 258 |
|
225 | | -@mixin mdc-text-field-outline-shape-radius($radius, $rtl-reflexive: false) { |
226 | | - $resolved-radius: nth(mdc-shape-resolve-percentage-radius($mdc-text-field-height, mdc-shape-prop-value($radius)), 1); |
| 259 | +/// |
| 260 | +/// Sets shape radius of outlined text field variant. |
| 261 | +/// |
| 262 | +/// @param {Number} $radius Shape radius value in `px` or in percentage. |
| 263 | +/// @param {Number} $text-field-height Height of outlined text field variant. Required only when `$radius` is in |
| 264 | +/// percentage unit and if text field has custom height. Defaults to `$mdc-text-field-height`. |
| 265 | +/// @param {Boolean} $rtl-reflexive Set to true to flip shape radius in RTL context. Defaults to `false`. |
| 266 | +/// |
| 267 | +@mixin mdc-text-field-outline-shape-radius($radius, $text-field-height: $mdc-text-field-height, $rtl-reflexive: false) { |
| 268 | + $resolved-radius: nth(mdc-shape-resolve-percentage-radius($text-field-height, mdc-shape-prop-value($radius)), 1); |
227 | 269 |
|
228 | 270 | @if (length(mdc-shape-prop-value($radius)) > 1) { |
229 | 271 | // stylelint-disable-next-line max-line-length |
|
249 | 291 | .mdc-floating-label { |
250 | 292 | @include mdc-rtl-reflexive-position(left, $mdc-text-field-label-offset); |
251 | 293 |
|
252 | | - top: 18px; |
| 294 | + top: 50%; |
| 295 | + transform: translateY(-50%); |
253 | 296 | pointer-events: none; |
254 | 297 | } |
255 | 298 |
|
| 299 | + // Include these mixins to override above `transform` property. |
| 300 | + //TODO: Remove these from here when floating label is center aligned in all position - this lowers specificity. |
| 301 | + @include mdc-floating-label-float-position($mdc-text-field-label-position-y); |
| 302 | + |
256 | 303 | &--textarea { |
257 | 304 | .mdc-floating-label { |
258 | 305 | @include mdc-rtl-reflexive-position(left, $mdc-notched-outline-padding); |
|
262 | 309 | &--outlined { |
263 | 310 | .mdc-floating-label { |
264 | 311 | @include mdc-rtl-reflexive-position(left, $mdc-notched-outline-padding); |
265 | | - |
266 | | - top: 17px; |
267 | 312 | } |
268 | 313 |
|
269 | 314 | &--with-leading-icon { |
|
299 | 344 | } |
300 | 345 |
|
301 | 346 | @mixin mdc-text-field-outlined-focused_ { |
302 | | - @include mdc-notched-outline-stroke-width(2px); |
| 347 | + @include mdc-notched-outline-stroke-width($mdc-text-field-outlined-stroke-width); |
303 | 348 | } |
304 | 349 |
|
305 | 350 | @mixin mdc-text-field-outlined-dense_ { |
|
331 | 376 | @include mdc-text-field-focused-outline-color(primary); |
332 | 377 | @include mdc-floating-label-shake-animation(text-field-outlined); |
333 | 378 | @include mdc-text-field-outline-shape-radius(small); |
334 | | - @include mdc-notched-outline-floating-label-float-position($mdc-text-field-outlined-label-position-y); |
| 379 | + @include mdc-notched-outline-floating-label-float-position-absolute($mdc-text-field-outlined-label-position-y); |
| 380 | + @include mdc-notched-outline-notch-offset($mdc-notched-outline-border-width); |
335 | 381 | @include mdc-states-base-color(transparent); |
336 | 382 | @include mdc-text-field-fill-color(transparent); |
337 | 383 |
|
|
349 | 395 | .mdc-text-field__icon { |
350 | 396 | z-index: 2; |
351 | 397 | } |
| 398 | + |
| 399 | + &.mdc-text-field--focused { |
| 400 | + @include mdc-notched-outline-notch-offset($mdc-text-field-outlined-stroke-width); |
| 401 | + } |
352 | 402 | } |
353 | 403 |
|
354 | 404 | @mixin mdc-text-field-hover-outline-color_($color) { |
|
404 | 454 | $mdc-text-field-icon-padding, |
405 | 455 | $mdc-text-field-input-padding |
406 | 456 | ); |
407 | | - @include mdc-notched-outline-floating-label-float-position($mdc-text-field-outlined-label-position-y, 32px); |
| 457 | + @include mdc-notched-outline-floating-label-float-position-absolute($mdc-text-field-outlined-label-position-y, 32px); |
408 | 458 | @include mdc-floating-label-shake-animation(text-field-outlined-leading-icon); |
409 | 459 |
|
410 | 460 | @include mdc-rtl { |
|
522 | 572 | @include mdc-text-field-outline-color($mdc-text-field-outlined-idle-border); |
523 | 573 | @include mdc-text-field-hover-outline-color($mdc-text-field-outlined-hover-border); |
524 | 574 | @include mdc-text-field-focused-outline-color(primary); |
525 | | - @include mdc-floating-label-shake-animation(text-field-outlined); |
| 575 | + @include mdc-floating-label-shake-animation(textarea); |
526 | 576 | @include mdc-text-field-outline-shape-radius(small); |
527 | 577 | @include mdc-states-base-color(transparent); |
528 | 578 | @include mdc-text-field-fill-color(transparent); |
529 | | - @include mdc-notched-outline-floating-label-float-position($mdc-text-field-outlined-label-position-y, 0%); |
| 579 | + @include mdc-notched-outline-floating-label-float-position($mdc-text-field-textarea-label-position-y); |
530 | 580 | @include mdc-text-field-character-counter-position(16px, 13px); |
531 | 581 |
|
532 | 582 | $padding-inset: 16px; |
|
544 | 594 | margin: $padding-inset/2 1px 1px 0; |
545 | 595 | padding: 0 $padding-inset $padding-inset; |
546 | 596 | border: none; |
| 597 | + line-height: 1.75rem; // 28sp |
547 | 598 | } |
548 | 599 |
|
549 | 600 | .mdc-text-field-character-counter + .mdc-text-field__input { |
|
553 | 604 |
|
554 | 605 | .mdc-floating-label { |
555 | 606 | top: 17px; |
556 | | - bottom: auto; |
557 | 607 | width: auto; |
558 | 608 | pointer-events: none; |
| 609 | + |
| 610 | + // Resets center aligning the floating label. |
| 611 | + &:not(.mdc-floating-label--float-above) { |
| 612 | + transform: none; |
| 613 | + } |
559 | 614 | } |
560 | 615 |
|
561 | 616 | &.mdc-text-field--focused { |
|
0 commit comments