_select.scss 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* Select Field
  2. ========================================================================== */
  3. select { display: none; }
  4. select.browser-default { display: block; }
  5. select {
  6. background-color: $select-background;
  7. width: 100%;
  8. padding: $select-padding;
  9. border: $select-border;
  10. border-radius: $select-radius;
  11. height: $input-height;
  12. }
  13. .select-label {
  14. position: absolute;
  15. }
  16. .select-wrapper {
  17. &.valid .helper-text[data-success],
  18. &.invalid ~ .helper-text[data-error] {
  19. @extend %hidden-text;
  20. }
  21. &.valid {
  22. & > input.select-dropdown {
  23. @extend %valid-input-style;
  24. }
  25. & ~ .helper-text:after {
  26. @extend %custom-success-message;
  27. }
  28. }
  29. &.invalid {
  30. & > input.select-dropdown,
  31. & > input.select-dropdown:focus {
  32. @extend %invalid-input-style;
  33. }
  34. & ~ .helper-text:after {
  35. @extend %custom-error-message;
  36. }
  37. }
  38. &.valid + label,
  39. &.invalid + label {
  40. width: 100%;
  41. pointer-events: none;
  42. }
  43. & + label:after {
  44. @extend %input-after-style;
  45. }
  46. position: relative;
  47. input.select-dropdown {
  48. &:focus {
  49. border-bottom: 1px solid $input-focus-color;
  50. }
  51. position: relative;
  52. cursor: pointer;
  53. background-color: transparent;
  54. border: none;
  55. border-bottom: $input-border;
  56. outline: none;
  57. height: $input-height;
  58. line-height: $input-height;
  59. width: 100%;
  60. font-size: $input-font-size;
  61. margin: $input-margin;
  62. padding: 0;
  63. display: block;
  64. user-select:none;
  65. z-index: 1;
  66. }
  67. .caret {
  68. position: absolute;
  69. right: 0;
  70. top: 0;
  71. bottom: 0;
  72. margin: auto 0;
  73. z-index: 0;
  74. fill: rgba(0,0,0,.87);
  75. }
  76. & + label {
  77. position: absolute;
  78. top: -26px;
  79. font-size: $label-font-size;
  80. }
  81. }
  82. // Disabled styles
  83. select:disabled {
  84. color: $input-disabled-color;
  85. }
  86. .select-wrapper.disabled {
  87. + label {
  88. color: $input-disabled-color;
  89. }
  90. .caret {
  91. fill: $input-disabled-color;
  92. }
  93. }
  94. .select-wrapper input.select-dropdown:disabled {
  95. color: $input-disabled-color;
  96. cursor: default;
  97. user-select: none;
  98. }
  99. .select-wrapper i {
  100. color: $select-disabled-color;
  101. }
  102. .select-dropdown li.disabled,
  103. .select-dropdown li.disabled > span,
  104. .select-dropdown li.optgroup {
  105. color: $select-disabled-color;
  106. background-color: transparent;
  107. }
  108. body.keyboard-focused {
  109. .select-dropdown.dropdown-content li:focus {
  110. background-color: $select-option-focus;
  111. }
  112. }
  113. .select-dropdown.dropdown-content {
  114. li {
  115. &:hover {
  116. background-color: $select-option-hover;
  117. }
  118. &.selected {
  119. background-color: $select-option-selected;
  120. }
  121. }
  122. }
  123. // Prefix Icons
  124. .prefix ~ .select-wrapper {
  125. margin-left: 3rem;
  126. width: 92%;
  127. width: calc(100% - 3rem);
  128. }
  129. .prefix ~ label { margin-left: 3rem; }
  130. // Icons
  131. .select-dropdown li {
  132. img {
  133. height: $dropdown-item-height - 10;
  134. width: $dropdown-item-height - 10;
  135. margin: 5px 15px;
  136. float: right;
  137. }
  138. }
  139. // Optgroup styles
  140. .select-dropdown li.optgroup {
  141. border-top: 1px solid $dropdown-hover-bg-color;
  142. &.selected > span {
  143. color: rgba(0, 0, 0, .7);
  144. }
  145. & > span {
  146. color: rgba(0, 0, 0, .4);
  147. }
  148. & ~ li.optgroup-option {
  149. padding-left: 1rem;
  150. }
  151. }