slider.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'mixins/var' as *;
  5. @use 'common/var' as *;
  6. $slider-height: () !default;
  7. $slider-height: map.merge(
  8. (
  9. 'large': 40px,
  10. 'default': 32px,
  11. 'small': 24px,
  12. ),
  13. $slider-height
  14. );
  15. @include b(slider) {
  16. @include set-component-css-var('slider', $slider);
  17. }
  18. @include b(slider) {
  19. width: 100%;
  20. height: map.get($slider-height, 'default');
  21. display: flex;
  22. align-items: center;
  23. @include e(runway) {
  24. flex: 1;
  25. height: getCssVar('slider-height');
  26. background-color: getCssVar('slider-runway-bg-color');
  27. border-radius: getCssVar('slider-border-radius');
  28. position: relative;
  29. cursor: pointer;
  30. &.show-input {
  31. margin-right: 30px;
  32. width: auto;
  33. }
  34. &.is-disabled {
  35. cursor: default;
  36. .#{$namespace}-slider__bar {
  37. background-color: getCssVar('slider-disabled-color');
  38. }
  39. .#{$namespace}-slider__button {
  40. border-color: getCssVar('slider-disabled-color');
  41. }
  42. .#{$namespace}-slider__button-wrapper {
  43. &:hover,
  44. &.hover {
  45. cursor: not-allowed;
  46. }
  47. &.dragging {
  48. cursor: not-allowed;
  49. }
  50. }
  51. .#{$namespace}-slider__button {
  52. &:hover,
  53. &.hover,
  54. &.dragging {
  55. transform: scale(1);
  56. }
  57. &:hover,
  58. &.hover {
  59. cursor: not-allowed;
  60. }
  61. &.dragging {
  62. cursor: not-allowed;
  63. }
  64. }
  65. }
  66. }
  67. @include e(input) {
  68. flex-shrink: 0;
  69. width: 130px;
  70. }
  71. @include e(bar) {
  72. height: getCssVar('slider-height');
  73. background-color: getCssVar('slider-main-bg-color');
  74. border-top-left-radius: getCssVar('slider-border-radius');
  75. border-bottom-left-radius: getCssVar('slider-border-radius');
  76. position: absolute;
  77. }
  78. @include e(button-wrapper) {
  79. height: getCssVar('slider-button-wrapper-size');
  80. width: getCssVar('slider-button-wrapper-size');
  81. position: absolute;
  82. z-index: 1;
  83. top: getCssVar('slider-button-wrapper-offset');
  84. transform: translateX(-50%);
  85. background-color: transparent;
  86. text-align: center;
  87. user-select: none;
  88. line-height: normal;
  89. outline: none;
  90. @include utils-vertical-center;
  91. &:hover,
  92. &.hover {
  93. cursor: grab;
  94. }
  95. &.dragging {
  96. cursor: grabbing;
  97. }
  98. }
  99. @include e(button) {
  100. display: inline-block;
  101. width: getCssVar('slider-button-size');
  102. height: getCssVar('slider-button-size');
  103. vertical-align: middle;
  104. border: solid 2px getCssVar('slider-main-bg-color');
  105. background-color: getCssVar('color-white');
  106. border-radius: 50%;
  107. box-sizing: border-box;
  108. transition: getCssVar('transition-duration-fast');
  109. user-select: none;
  110. &:hover,
  111. &.hover,
  112. &.dragging {
  113. transform: scale(1.2);
  114. }
  115. &:hover,
  116. &.hover {
  117. cursor: grab;
  118. }
  119. &.dragging {
  120. cursor: grabbing;
  121. }
  122. }
  123. @include e(stop) {
  124. position: absolute;
  125. height: getCssVar('slider-height');
  126. width: getCssVar('slider-height');
  127. border-radius: getCssVar('border-radius-circle');
  128. background-color: getCssVar('slider-stop-bg-color');
  129. transform: translateX(-50%);
  130. }
  131. @include e(marks) {
  132. top: 0;
  133. left: 12px;
  134. width: 18px;
  135. height: 100%;
  136. @include e(marks-text) {
  137. position: absolute;
  138. transform: translateX(-50%);
  139. font-size: 14px;
  140. color: getCssVar('color-info');
  141. margin-top: 15px;
  142. white-space: pre;
  143. }
  144. }
  145. @include when(vertical) {
  146. position: relative;
  147. display: inline-flex;
  148. width: auto;
  149. height: 100%;
  150. flex: 0;
  151. .#{$namespace}-slider__runway {
  152. width: getCssVar('slider-height');
  153. height: 100%;
  154. margin: 0 16px;
  155. }
  156. .#{$namespace}-slider__bar {
  157. width: getCssVar('slider-height');
  158. height: auto;
  159. border-radius: 0 0 3px 3px;
  160. }
  161. .#{$namespace}-slider__button-wrapper {
  162. top: auto;
  163. left: getCssVar('slider-button-wrapper-offset');
  164. transform: translateY(50%);
  165. }
  166. .#{$namespace}-slider__stop {
  167. transform: translateY(50%);
  168. }
  169. @include e(marks-text) {
  170. margin-top: 0;
  171. left: 15px;
  172. transform: translateY(50%);
  173. }
  174. }
  175. @each $size in (large, small) {
  176. @include m($size) {
  177. height: map.get($slider-height, $size);
  178. @include e(runway) {
  179. }
  180. }
  181. }
  182. }