_floating-label.scss 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // Copyright 2018 Google Inc.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. // stylelint-disable selector-class-pattern --
  23. // Selector '.mdc-*' should only be used in this project.
  24. @use '@material/feature-targeting/feature-targeting';
  25. @use '@material/rtl/rtl';
  26. @use './floating-label-theme';
  27. @mixin core-styles($query: feature-targeting.all()) {
  28. @include static-styles($query);
  29. @include floating-label-theme.theme-styles($query);
  30. }
  31. @mixin static-styles($query: feature-targeting.all()) {
  32. $feat-structure: feature-targeting.create-target($query, structure);
  33. // postcss-bem-linter: define floating-label
  34. .mdc-floating-label {
  35. @include feature-targeting.targets($feat-structure) {
  36. position: absolute;
  37. @include rtl.ignore-next-line();
  38. left: 0;
  39. @include rtl.ignore-next-line();
  40. -webkit-transform-origin: left top;
  41. @include rtl.ignore-next-line();
  42. transform-origin: left top;
  43. line-height: 1.15rem;
  44. text-align: left;
  45. text-overflow: ellipsis;
  46. white-space: nowrap;
  47. cursor: text;
  48. overflow: hidden;
  49. /* @alternate */
  50. // Force the label into its own layer to prevent visible layer promotion adjustments
  51. // when the ripple is activated behind it.
  52. will-change: transform;
  53. @include rtl.rtl {
  54. @include rtl.ignore-next-line();
  55. right: 0;
  56. @include rtl.ignore-next-line();
  57. left: auto;
  58. @include rtl.ignore-next-line();
  59. -webkit-transform-origin: right top;
  60. @include rtl.ignore-next-line();
  61. transform-origin: right top;
  62. @include rtl.ignore-next-line();
  63. text-align: right;
  64. }
  65. }
  66. }
  67. .mdc-floating-label--float-above {
  68. @include feature-targeting.targets($feat-structure) {
  69. cursor: auto;
  70. }
  71. }
  72. .mdc-floating-label--required:not(.mdc-floating-label--hide-required-marker) {
  73. &::after {
  74. @include feature-targeting.targets($feat-structure) {
  75. @include rtl.ignore-next-line();
  76. margin-left: 1px;
  77. @include rtl.ignore-next-line();
  78. margin-right: 0px;
  79. content: '*';
  80. }
  81. }
  82. @include rtl.rtl {
  83. &::after {
  84. // Need to specify LTR/RTL manually since rtl mixins will add ::after[dir=rtl]
  85. // selector and that breaks some browsers
  86. @include feature-targeting.targets($feat-structure) {
  87. @include rtl.ignore-next-line();
  88. margin-left: 0;
  89. @include rtl.ignore-next-line();
  90. margin-right: 1px;
  91. }
  92. }
  93. }
  94. }
  95. }