_form-field-subscript.scss 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. @use '../core/tokens/m2/mat/form-field' as tokens-mat-form-field;
  2. @use '../core/style/vendor-prefixes';
  3. @use '../core/tokens/token-utils';
  4. @mixin private-form-field-subscript() {
  5. @keyframes _mat-form-field-subscript-animation {
  6. from {
  7. opacity: 0;
  8. transform: translateY(-5px);
  9. }
  10. to {
  11. opacity: 1;
  12. transform: translateY(0);
  13. }
  14. }
  15. // Wrapper for the hints and error messages.
  16. .mat-mdc-form-field-subscript-wrapper {
  17. box-sizing: border-box;
  18. width: 100%;
  19. position: relative;
  20. }
  21. .mat-mdc-form-field-hint-wrapper,
  22. .mat-mdc-form-field-error-wrapper {
  23. position: absolute;
  24. top: 0;
  25. left: 0;
  26. right: 0;
  27. padding: 0 16px;
  28. opacity: 1;
  29. transform: translateY(0);
  30. // Note: animation-duration gets set when animations are enabled.
  31. // This allows us to skip the animation on init.
  32. animation: _mat-form-field-subscript-animation 0ms cubic-bezier(0.55, 0, 0.55, 0.2);
  33. }
  34. .mat-mdc-form-field-subscript-dynamic-size {
  35. .mat-mdc-form-field-hint-wrapper,
  36. .mat-mdc-form-field-error-wrapper {
  37. position: static;
  38. }
  39. }
  40. .mat-mdc-form-field-bottom-align::before {
  41. content: '';
  42. display: inline-block;
  43. height: 16px;
  44. }
  45. .mat-mdc-form-field-bottom-align.mat-mdc-form-field-subscript-dynamic-size::before {
  46. content: unset;
  47. }
  48. .mat-mdc-form-field-hint-end {
  49. order: 1;
  50. }
  51. // Clears the floats on the hints. This is necessary for the hint animation to work.
  52. .mat-mdc-form-field-hint-wrapper {
  53. display: flex;
  54. }
  55. // Spacer used to make sure start and end hints have enough space between them.
  56. .mat-mdc-form-field-hint-spacer {
  57. flex: 1 0 1em;
  58. }
  59. // Single error message displayed beneath the form field underline.
  60. .mat-mdc-form-field-error {
  61. display: block;
  62. @include token-utils.use-tokens(tokens-mat-form-field.$prefix,
  63. tokens-mat-form-field.get-token-slots()) {
  64. @include token-utils.create-token-slot(color, error-text-color);
  65. }
  66. }
  67. // The subscript wrapper has a minimum height to avoid that the form-field
  68. // jumps when hints or errors are displayed.
  69. .mat-mdc-form-field-subscript-wrapper,
  70. .mat-mdc-form-field-bottom-align::before {
  71. @include token-utils.use-tokens(tokens-mat-form-field.$prefix,
  72. tokens-mat-form-field.get-token-slots()) {
  73. @include vendor-prefixes.smooth-font();
  74. @include token-utils.create-token-slot(font-family, subscript-text-font);
  75. @include token-utils.create-token-slot(line-height, subscript-text-line-height);
  76. @include token-utils.create-token-slot(font-size, subscript-text-size);
  77. @include token-utils.create-token-slot(letter-spacing, subscript-text-tracking);
  78. @include token-utils.create-token-slot(font-weight, subscript-text-weight);
  79. }
  80. }
  81. }