ng5-slider.scss 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. @mixin ng-deep($enableNgDeep: true) {
  2. @if $enableNgDeep {
  3. ::ng-deep {
  4. @content;
  5. }
  6. } @else {
  7. @content;
  8. }
  9. }
  10. @mixin rounded($radius: 2px) {
  11. -webkit-border-radius: $radius;
  12. -moz-border-radius: $radius;
  13. border-radius: $radius;
  14. }
  15. $enableNgDeep: true !default;
  16. $handleActiveColor: #451aff !default;
  17. $handleHoverColor: #fff !default;
  18. $labelTextColor: #55637d !default;
  19. $handleBgColor: #0db9f0 !default;
  20. $handleInnerColor: #fff !default;
  21. $handleDisabledColor: #d8e0f3 !default;
  22. $limitLabelTextColor: $labelTextColor !default;
  23. $barFillColor: $handleBgColor !default;
  24. $barDisabledFillColor: #8b91a2 !default;
  25. $barNormalColor: #d8e0f3 !default;
  26. $barLeftOutSelectionColor: #df002d !default;
  27. $barRightOutSelectionColor: #03a688 !default;
  28. $ticksColor: $barNormalColor !default;
  29. $selectedTicksColor: $barFillColor !default;
  30. $ticksWidth: 10px !default;
  31. $ticksHeight: 10px !default;
  32. $ticksValuePosition: -34px !default;
  33. $ticksLegendPosition: 24px !default;
  34. $ticksValuePositionOnVertical: 24px !default;
  35. $tickLegendMaxWidth: 50px !default;
  36. $handleSize: 32px !default;
  37. $handlePointerSize: 8px !default;
  38. $bubblePaddingVertical: 1px !default;
  39. $bubblePaddingHorizontal: 3px !default;
  40. $labelFontSize: 16px !default;
  41. $barDimension: 4px !default;
  42. $withLegendMargin: 40px !default;
  43. $sliderMargin: 15px !default;
  44. $sliderMarginWithLabel: 35px !default;
  45. $sliderVerticalMargin: 20px !default;
  46. $animationDuration: 0.3s !default;
  47. @include ng-deep($enableNgDeep) {
  48. .ng5-slider {
  49. display: inline-block;
  50. position: relative;
  51. height: $barDimension;
  52. width: 100%;
  53. margin: $sliderMarginWithLabel 0 $sliderMargin 0;
  54. vertical-align: middle;
  55. user-select: none;
  56. touch-action: pan-y;
  57. &.with-legend {
  58. margin-bottom: $withLegendMargin;
  59. }
  60. &[disabled] {
  61. cursor: not-allowed;
  62. .ng5-slider-pointer {
  63. cursor: not-allowed;
  64. background-color: $handleDisabledColor;
  65. }
  66. .ng5-slider-draggable {
  67. cursor: not-allowed;
  68. }
  69. .ng5-slider-selection {
  70. background: $barDisabledFillColor;
  71. }
  72. .ng5-slider-tick {
  73. cursor: not-allowed;
  74. &.ng5-slider-selected {
  75. background: $barDisabledFillColor;
  76. }
  77. }
  78. }
  79. .ng5-slider-span {
  80. white-space: nowrap;
  81. position: absolute;
  82. display: inline-block;
  83. }
  84. .ng5-slider-base {
  85. width: 100%;
  86. height: 100%;
  87. padding: 0;
  88. }
  89. .ng5-slider-bar-wrapper {
  90. left: 0;
  91. box-sizing: border-box;
  92. margin-top: -$handleSize / 2;
  93. padding-top: $handleSize / 2;
  94. width: 100%;
  95. height: $handleSize;
  96. z-index: 1;
  97. }
  98. .ng5-slider-draggable {
  99. cursor: move;
  100. }
  101. .ng5-slider-bar {
  102. left: 0;
  103. width: 100%;
  104. height: $barDimension;
  105. z-index: 1;
  106. background: $barNormalColor;
  107. @include rounded($barDimension / 2);
  108. }
  109. .ng5-slider-bar-wrapper.ng5-slider-transparent .ng5-slider-bar {
  110. background: transparent;
  111. }
  112. .ng5-slider-bar-wrapper.ng5-slider-left-out-selection .ng5-slider-bar {
  113. background: $barLeftOutSelectionColor;
  114. }
  115. .ng5-slider-bar-wrapper.ng5-slider-right-out-selection .ng5-slider-bar {
  116. background: $barRightOutSelectionColor;
  117. }
  118. .ng5-slider-selection {
  119. z-index: 2;
  120. background: $barFillColor;
  121. @include rounded($barDimension / 2);
  122. }
  123. .ng5-slider-pointer {
  124. cursor: pointer;
  125. width: $handleSize;
  126. height: $handleSize;
  127. top: -$handleSize / 2 + $barDimension / 2;
  128. background-color: $handleBgColor;
  129. z-index: 3;
  130. @include rounded($handleSize / 2);
  131. &:after {
  132. content: '';
  133. width: $handlePointerSize;
  134. height: $handlePointerSize;
  135. position: absolute;
  136. top: $handleSize / 2 - $handlePointerSize / 2;
  137. left: $handleSize / 2 - $handlePointerSize / 2;
  138. @include rounded($handlePointerSize / 2);
  139. background: $handleInnerColor;
  140. }
  141. &:hover:after {
  142. background-color: $handleHoverColor;
  143. }
  144. &.ng5-slider-active {
  145. z-index: 4;
  146. &:after {
  147. background-color: $handleActiveColor;
  148. }
  149. }
  150. }
  151. .ng5-slider-bubble {
  152. cursor: default;
  153. bottom: $handleSize / 2;
  154. padding: $bubblePaddingVertical $bubblePaddingHorizontal;
  155. color: $labelTextColor;
  156. font-size: $labelFontSize;
  157. &.ng5-slider-limit {
  158. color: $limitLabelTextColor;
  159. }
  160. }
  161. .ng5-slider-ticks {
  162. box-sizing: border-box;
  163. width: 100%;
  164. height: 0;
  165. position: absolute;
  166. left: 0;
  167. top: -($ticksHeight - $barDimension) / 2;
  168. margin: 0;
  169. z-index: 1;
  170. list-style: none;
  171. }
  172. .ng5-slider-ticks-values-under {
  173. .ng5-slider-tick-value {
  174. top: auto;
  175. bottom: $ticksValuePosition - 2;
  176. }
  177. }
  178. .ng5-slider-tick {
  179. text-align: center;
  180. cursor: pointer;
  181. width: $ticksWidth;
  182. height: $ticksHeight;
  183. background: $ticksColor;
  184. border-radius: 50%;
  185. position: absolute;
  186. top: 0;
  187. left: 0;
  188. margin-left: $handleSize / 2 - $ticksWidth / 2; // for centering
  189. &.ng5-slider-selected {
  190. background: $selectedTicksColor;
  191. }
  192. }
  193. .ng5-slider-tick-value {
  194. position: absolute;
  195. top: $ticksValuePosition;
  196. transform: translate(-50%, 0);
  197. }
  198. .ng5-slider-tick-legend {
  199. position: absolute;
  200. top: $ticksLegendPosition;
  201. transform: translate(-50%, 0);
  202. max-width: $tickLegendMaxWidth;
  203. white-space: normal;
  204. }
  205. &.vertical {
  206. position: relative;
  207. width: $barDimension;
  208. height: 100%;
  209. margin: 0 $sliderVerticalMargin;
  210. padding: 0;
  211. vertical-align: baseline;
  212. touch-action: pan-x;
  213. .ng5-slider-base {
  214. width: 100%;
  215. height: 100%;
  216. padding: 0;
  217. }
  218. .ng5-slider-bar-wrapper {
  219. top: auto;
  220. left: 0;
  221. margin: 0 0 0 (-$handleSize / 2);
  222. padding: 0 0 0 $handleSize / 2;
  223. height: 100%;
  224. width: $handleSize;
  225. }
  226. .ng5-slider-bar {
  227. bottom: 0;
  228. left: auto;
  229. width: $barDimension;
  230. height: 100%;
  231. }
  232. .ng5-slider-pointer {
  233. left: -$handleSize / 2 + $barDimension / 2 !important;
  234. top: auto;
  235. bottom: 0;
  236. }
  237. .ng5-slider-bubble {
  238. left: $handleSize / 2 !important;
  239. bottom: 0;
  240. }
  241. .ng5-slider-ticks {
  242. height: 100%;
  243. width: 0;
  244. left: -($ticksHeight - $barDimension) / 2;
  245. top: 0;
  246. z-index: 1;
  247. }
  248. .ng5-slider-tick {
  249. vertical-align: middle;
  250. margin-left: auto;
  251. margin-top: $handleSize / 2 - $ticksWidth / 2; // for centering
  252. }
  253. .ng5-slider-tick-value {
  254. left: $ticksValuePositionOnVertical;
  255. top: auto;
  256. transform: translate(0, -28%);
  257. }
  258. .ng5-slider-tick-legend {
  259. top: auto;
  260. right: $ticksLegendPosition;
  261. transform: translate(0, -28%);
  262. max-width: none;
  263. white-space: nowrap;
  264. }
  265. .ng5-slider-ticks-values-under {
  266. .ng5-slider-tick-value {
  267. bottom: auto;
  268. left: auto;
  269. right: $ticksValuePositionOnVertical;
  270. }
  271. }
  272. }
  273. * {
  274. transition: none;
  275. }
  276. &.animate {
  277. .ng5-slider-bar-wrapper {
  278. transition: all linear $animationDuration;
  279. }
  280. .ng5-slider-selection {
  281. transition: background-color linear $animationDuration;
  282. }
  283. .ng5-slider-pointer {
  284. transition: all linear $animationDuration;
  285. }
  286. .ng5-slider-bubble {
  287. transition: all linear $animationDuration;
  288. &.ng5-slider-limit {
  289. transition: opacity linear $animationDuration;
  290. }
  291. &.ng5-slider-combined {
  292. transition: opacity linear $animationDuration;
  293. }
  294. }
  295. .ng5-slider-tick {
  296. transition: background-color linear $animationDuration;
  297. }
  298. }
  299. }
  300. }
  301. .ng5-slider-inner-tooltip {
  302. height: 100%;
  303. }