slider.scss 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. //@import '../theme/variables.scss';
  2. @import "./animation.scss";
  3. @import "./variables.scss";
  4. $module: #{$prefix}-slider;
  5. .#{$module} {
  6. padding: $spacing-slider-paddingY $spacing-slider-paddingX;
  7. margin: $spacing-slider-margin;
  8. &-wrapper {
  9. box-sizing: border-box;
  10. position: relative;
  11. // margin: 15px 0px 15px 0px;
  12. height: $height-slider_wrapper;
  13. width: 100%;
  14. //padding-top: 12px;
  15. // min-width: 500px;
  16. display: inline-block;
  17. // vertical-align 默认值 baseline 会导致父级元素高度比子元素高 https://codepen.io/shijiame/pen/rNeraYg
  18. vertical-align: bottom;
  19. }
  20. &-rail {
  21. box-sizing: border-box;
  22. margin: $spacing-slider_rail-margin;
  23. padding: $spacing-slider_rail-padding;
  24. color: $color-slider_rail;
  25. font-size: $font-slider_rail-fontSize;
  26. font-variant: tabular-nums;
  27. line-height: $font-slider_rail-lineHeight;
  28. list-style: none;
  29. font-feature-settings: 'tnum';
  30. position: absolute;
  31. height: $height-slider_rail;
  32. cursor: pointer;
  33. touch-action: none;
  34. background-color: $color-slider_rail-bg-default;
  35. width: 100%;
  36. border-radius: $radius-slider_rail;
  37. top: $spacing-slider_rail-top;
  38. }
  39. &-handle {
  40. @include shadow-knob;
  41. // 不设置border-box会在点击时border向下偏移1px
  42. box-sizing: border-box;
  43. touch-action: none;
  44. position: absolute;
  45. width: $width-slider_handle;
  46. height: $width-slider_handle;
  47. margin-top: $spacing-slider_handle-marginTop;
  48. // margin-left: -11px;
  49. background-color: $color-slider_handle-bg-default; //$color-white;
  50. border: none;
  51. border-radius: 50%;
  52. cursor: pointer;
  53. transition: background-color $transition_duration_slider_handle-bg $transition_function-slider-handle-bg $transition_delay-slider_handle-bg;
  54. transform: scale($transform_scale-slider_handle);
  55. &:focus-visible {
  56. outline: $width-slider_handle-focus solid $color-slider_handle-focus;
  57. }
  58. }
  59. &-handle:hover {
  60. background-color: $color-slider_handle-bg-hover;
  61. }
  62. &-handle-clicked {
  63. border: solid $width-slider_handle_clicked $color-slider_handle-border-focus;
  64. cursor: grabbing;
  65. }
  66. &-track {
  67. height: $height-slider_track;
  68. background: $color-slider_track-bg-default;
  69. border-radius: $radius-slider_track;
  70. position: absolute;
  71. cursor: pointer;
  72. top: $spacing-slider_track-top;
  73. }
  74. &-tooltip {
  75. position: absolute;
  76. top: $spacing-slider_tooltip-top;
  77. // margin-left: -15px;
  78. }
  79. &-dots {
  80. width: 100%;
  81. background: transparent;
  82. }
  83. &-dot {
  84. position: absolute;
  85. top: $spacing-slider_dot-top;
  86. width: $width-slider_dot;
  87. height: $width-slider_dot;
  88. background-color: $color-slider_dot-bg-default;
  89. //border: 1px solid $color-control-bg-default;
  90. border-radius: 50%;
  91. cursor: pointer;
  92. }
  93. &-dot-active {
  94. background-color: $color-slider_dot-border-active;
  95. }
  96. &-marks {
  97. position: absolute;
  98. top: $spacing-slider_marks-top;
  99. left: $spacing-slider_marks-left;
  100. width: 100%;
  101. font-size: $font-slider_marks-fontSize;
  102. }
  103. &-mark {
  104. position: absolute;
  105. display: inline-block;
  106. color: $color-slider_mark-text-default;
  107. text-align: center;
  108. cursor: pointer;
  109. transform: translate(-50%, 0);
  110. }
  111. &-marks-reverse {
  112. position: absolute;
  113. top: $spacing-slider_marks-top;
  114. left: $spacing-slider_marks-left;
  115. width: 100%;
  116. font-size: $font-slider_marks-fontSize;
  117. }
  118. &-mark-reverse {
  119. position: absolute;
  120. display: inline-block;
  121. color: $color-slider_mark-text-default;
  122. text-align: center;
  123. cursor: pointer;
  124. transform: translate(-50%, 0) rotate(-180deg);
  125. }
  126. &-boundary {
  127. position: relative;
  128. font-size: $font-size-small;
  129. color: $color-slider-text-default;
  130. visibility: hidden;
  131. top: $spacing-slider_boundary-top;
  132. span {
  133. position: absolute;
  134. display: inline-block;
  135. }
  136. }
  137. &-boundary-min {
  138. left: $spacing-slider_boundary_min-left;
  139. }
  140. &-boundary-max {
  141. right: $spacing-slider_boundary_max-right;
  142. }
  143. &-boundary-show {
  144. visibility: visible;
  145. }
  146. }
  147. .#{$module}-vertical-wrapper {
  148. width: $height-slider_vertical_wrapper;
  149. height: 100%;
  150. .#{$module}-track {
  151. width: $height-slider_track;
  152. }
  153. .#{$module}-marks {
  154. height: 100%;
  155. margin-top: $spacing-slider_vertical_marks-marginTop;
  156. margin-left: $spacing-slider_vertical_marks-marginLeft;
  157. }
  158. .#{$module}-marks-reverse {
  159. height: 100%;
  160. margin-top: $spacing-slider_vertical_marks-marginTop;
  161. margin-left: $spacing-slider_vertical_marks-reverse-marginLeft;
  162. }
  163. .#{$module}-rail {
  164. width: $height-slider_rail;
  165. height: 100%;
  166. top: $spacing-slider_vertical_rail-top;
  167. }
  168. .#{$module}-handle {
  169. margin-top: $spacing-slider_vertical_handle-marginTop;
  170. margin-left: $spacing-slider_vertical_handle-marginLeft;
  171. }
  172. }
  173. .#{$module}-disabled {
  174. cursor: not-allowed;
  175. $color: $color-slider_disabled-text-default !important;
  176. .#{$module}-handle {
  177. cursor: not-allowed;
  178. @include shadow-0;
  179. border: $width-slider_handle_border_disabled $color-slider_handle_disabled-border solid;
  180. &:hover {
  181. background-color: $color-slider_handle_disabled-border-hover;
  182. }
  183. }
  184. .#{$module}-rail {
  185. cursor: not-allowed;
  186. }
  187. .#{$module}-track {
  188. cursor: not-allowed;
  189. background-color: $color-slider_track_disabled-bg;
  190. }
  191. .#{$module}-dot {
  192. cursor: not-allowed;
  193. background-color: $color-slider_dot-bg-default;
  194. border-color: $color-slider_dot-border;
  195. box-shadow: none;
  196. }
  197. }
  198. .#{$module}-handle-tooltip {
  199. text-align: center;
  200. }
  201. .#{$module}-reverse {
  202. transform: rotate(180deg);
  203. }