_select-outlined.scss 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //
  2. // Copyright 2020 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/floating-label/mixins' as floating-label-mixins;
  26. @use '@material/notched-outline/mixins' as notched-outline-mixins;
  27. @use '@material/notched-outline/variables' as notched-outline-variables;
  28. @use '@material/rtl/rtl';
  29. @use './select-icon-theme';
  30. @use './select-theme';
  31. @mixin static-styles($query: feature-targeting.all()) {
  32. $feat-structure: feature-targeting.create-target($query, structure);
  33. $feat-color: feature-targeting.create-target($query, color);
  34. .mdc-select--outlined {
  35. @include feature-targeting.targets($feat-structure) {
  36. border: none;
  37. }
  38. .mdc-select__anchor {
  39. @include floating-label-mixins.shake-animation(
  40. select-outlined,
  41. $query: $query
  42. );
  43. @include notched-outline-mixins.floating-label-float-position-absolute(
  44. select-theme.$outlined-label-position-y,
  45. $query: $query
  46. );
  47. @include notched-outline-mixins.notch-offset(
  48. notched-outline-variables.$border-width,
  49. $query: $query
  50. );
  51. @include select-theme.center-aligned($query: $query);
  52. @include feature-targeting.targets($feat-structure) {
  53. display: flex;
  54. // To eliminate extra gap between helper text & outlined select in IE.
  55. align-items: baseline;
  56. overflow: visible;
  57. }
  58. }
  59. .mdc-select__selected-text-container {
  60. @include feature-targeting.targets($feat-structure) {
  61. display: flex;
  62. border: none;
  63. z-index: 1;
  64. }
  65. @include feature-targeting.targets($feat-color) {
  66. background-color: transparent;
  67. }
  68. }
  69. .mdc-select__icon {
  70. @include feature-targeting.targets($feat-structure) {
  71. z-index: 2;
  72. }
  73. }
  74. .mdc-menu-surface {
  75. @include feature-targeting.targets($feat-structure) {
  76. margin-bottom: 8px;
  77. }
  78. }
  79. &.mdc-select--no-label .mdc-menu-surface,
  80. .mdc-menu-surface--is-open-below {
  81. @include feature-targeting.targets($feat-structure) {
  82. margin-bottom: 0;
  83. }
  84. }
  85. }
  86. }
  87. @mixin core-styles($query: feature-targeting.all()) {
  88. @include static-styles($query);
  89. .mdc-select--outlined {
  90. $feat-structure: feature-targeting.create-target($query, structure);
  91. $feat-color: feature-targeting.create-target($query, color);
  92. @include select-theme.outlined-height(select-theme.$height, $query: $query);
  93. @include select-theme.outline-shape-radius(
  94. select-theme.$shape-radius,
  95. $query: $query
  96. );
  97. @include select-theme.container-fill-color(
  98. (
  99. default: transparent,
  100. disabled: transparent,
  101. ),
  102. $query: $query
  103. );
  104. @include select-theme.outline-color(
  105. (
  106. default: select-theme.$outlined-idle-border,
  107. hover: select-theme.$outlined-hover-border,
  108. focus: primary,
  109. disabled: select-theme.$disabled-outline-color,
  110. ),
  111. $query: $query
  112. );
  113. @include select-theme.outline-width(
  114. (
  115. focus: select-theme.$outlined-stroke-width,
  116. ),
  117. $query: $query
  118. );
  119. @include select-theme.truncate-notched-outline-max-width(
  120. $leading-icon-size: 0,
  121. $dropdown-icon-size: select-icon-theme.$icon-size,
  122. $query: $query
  123. );
  124. .mdc-select__anchor {
  125. @include floating-label-mixins.shake-animation(
  126. select-outlined,
  127. $query: $query
  128. );
  129. @include notched-outline-mixins.floating-label-float-position-absolute(
  130. select-theme.$outlined-label-position-y,
  131. $query: $query
  132. );
  133. @include notched-outline-mixins.notch-offset(
  134. notched-outline-variables.$border-width,
  135. $query: $query
  136. );
  137. @include select-theme.center-aligned($query: $query);
  138. }
  139. .mdc-floating-label {
  140. @include feature-targeting.targets($feat-structure) {
  141. line-height: 1.15rem;
  142. @include rtl.reflexive-position(
  143. left,
  144. notched-outline-variables.$padding
  145. );
  146. }
  147. }
  148. &.mdc-select--focused {
  149. @include notched-outline-mixins.notch-offset(
  150. select-theme.$outlined-stroke-width,
  151. $query: $query
  152. );
  153. }
  154. &.mdc-select--invalid {
  155. @include select-theme.outline-color(
  156. (
  157. default: select-theme.$error-color,
  158. hover: select-theme.$error-color,
  159. focus: select-theme.$error-color,
  160. ),
  161. $query: $query
  162. );
  163. }
  164. &.mdc-select--with-leading-icon {
  165. @include select-theme.outlined-with-leading-icon-floating-label-position-animation(
  166. select-theme.$height,
  167. select-icon-theme.$icon-size,
  168. $query: $query
  169. );
  170. @include select-theme.truncate-notched-outline-max-width(
  171. $leading-icon-size: select-icon-theme.$icon-size,
  172. $dropdown-icon-size: select-icon-theme.$icon-size,
  173. $query: $query
  174. );
  175. }
  176. }
  177. }