dropdown.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'common/var' as *;
  5. $dropdown-item-line-height: () !default;
  6. $dropdown-item-line-height: map.merge(
  7. (
  8. 'large': 22px,
  9. 'default': 22px,
  10. 'small': 20px,
  11. ),
  12. $dropdown-item-line-height
  13. );
  14. $dropdown-item-padding: () !default;
  15. $dropdown-item-padding: map.merge(
  16. (
  17. 'large': 7px 20px,
  18. 'default': 5px 16px,
  19. 'small': 2px 12px,
  20. ),
  21. $dropdown-item-padding
  22. );
  23. $dropdown-item-divided-margin: () !default;
  24. $dropdown-item-divided-margin: map.merge(
  25. (
  26. 'large': 8px 0,
  27. 'default': 6px 0,
  28. 'small': 4px 0,
  29. ),
  30. $dropdown-item-divided-margin
  31. );
  32. $dropdown-caret-width: () !default;
  33. $dropdown-caret-width: map.merge($common-component-size, $dropdown-caret-width);
  34. $dropdown-divider-width: 1px !default;
  35. @include b(dropdown) {
  36. @include set-component-css-var('dropdown', $dropdown);
  37. display: inline-flex;
  38. position: relative;
  39. color: getCssVar('text-color', 'regular');
  40. font-size: getCssVar('font-size', 'base');
  41. line-height: 1;
  42. vertical-align: top;
  43. &.is-disabled {
  44. color: getCssVar('text-color', 'placeholder');
  45. cursor: not-allowed;
  46. }
  47. @include e(popper) {
  48. @include set-component-css-var('dropdown', $dropdown);
  49. // using attributes selector to override
  50. @include picker-popper(
  51. getCssVar('bg-color', 'overlay'),
  52. 1px solid getCssVar('border-color-light'),
  53. getCssVar('dropdown-menu-box-shadow')
  54. );
  55. .#{$namespace}-dropdown-menu {
  56. border: none;
  57. }
  58. #{& + '-selfdefine'} {
  59. outline: none;
  60. }
  61. @include b(scrollbar__bar) {
  62. z-index: calc(#{getCssVar('dropdown', 'menu-index')} + 1);
  63. }
  64. @include b(dropdown__list) {
  65. list-style: none;
  66. padding: 0;
  67. margin: 0;
  68. box-sizing: border-box;
  69. }
  70. }
  71. & .#{$namespace}-dropdown__caret-button {
  72. padding-left: 0;
  73. padding-right: 0;
  74. display: inline-flex;
  75. justify-content: center;
  76. align-items: center;
  77. width: map.get($dropdown-caret-width, 'default');
  78. border-left: none;
  79. > span {
  80. display: inline-flex;
  81. }
  82. &::before {
  83. content: '';
  84. position: absolute;
  85. display: block;
  86. width: 1px;
  87. top: -1px;
  88. bottom: -1px;
  89. left: 0;
  90. background: getCssVar('overlay-color', 'lighter');
  91. }
  92. &.#{$namespace}-button::before {
  93. background: getCssVar('border-color');
  94. opacity: 0.5;
  95. }
  96. & .#{$namespace}-dropdown__icon {
  97. font-size: inherit;
  98. padding-left: 0;
  99. }
  100. }
  101. .#{$namespace}-dropdown-selfdefine {
  102. // 自定义
  103. outline: none;
  104. }
  105. @each $size in (large, small) {
  106. @include m($size) {
  107. .#{$namespace}-dropdown__caret-button {
  108. width: map.get($dropdown-caret-width, $size);
  109. }
  110. }
  111. }
  112. }
  113. $dropdown-menu-padding-vertical: () !default;
  114. $dropdown-menu-padding-vertical: map.merge(
  115. (
  116. 'large': 8px,
  117. 'default': 6px,
  118. 'small': 4px,
  119. ),
  120. $dropdown-menu-padding-vertical
  121. );
  122. @include b(dropdown-menu) {
  123. position: relative;
  124. top: 0;
  125. left: 0;
  126. z-index: getCssVar('dropdown-menu-index');
  127. padding: map.get($dropdown-menu-padding-vertical, 'default')-$border-width 0;
  128. margin: 0;
  129. background-color: getCssVar('bg-color', 'overlay');
  130. border: none;
  131. border-radius: getCssVar('border-radius-base');
  132. box-shadow: none;
  133. list-style: none;
  134. @include e(item) {
  135. display: flex;
  136. align-items: center;
  137. white-space: nowrap;
  138. list-style: none;
  139. line-height: map.get($dropdown-item-line-height, 'default');
  140. padding: map.get($dropdown-item-padding, 'default');
  141. margin: 0;
  142. font-size: getCssVar('font-size', 'base');
  143. color: getCssVar('text-color', 'regular');
  144. cursor: pointer;
  145. outline: none;
  146. &:not(.is-disabled):hover,
  147. &:not(.is-disabled):focus {
  148. background-color: getCssVar('dropdown-menuItem-hover-fill');
  149. color: getCssVar('dropdown-menuItem-hover-color');
  150. }
  151. i {
  152. margin-right: 5px;
  153. }
  154. @include m(divided) {
  155. margin: map.get($dropdown-item-divided-margin, 'default');
  156. border-top: 1px solid getCssVar('border-color-lighter');
  157. }
  158. @include when(disabled) {
  159. cursor: not-allowed;
  160. color: getCssVar('text-color-disabled');
  161. }
  162. }
  163. @each $size in (large, small) {
  164. @include m($size) {
  165. padding: map.get($dropdown-menu-padding-vertical, $size)-$border-width 0;
  166. @include e(item) {
  167. padding: map.get($dropdown-item-padding, $size);
  168. line-height: map.get($dropdown-item-line-height, $size);
  169. font-size: map.get($input-font-size, $size);
  170. @include m(divided) {
  171. margin: map.get($dropdown-item-divided-margin, $size);
  172. }
  173. }
  174. }
  175. }
  176. }