UNPKG

4.46 kBSCSSView Raw
1// Copyright 2016 Palantir Technologies, Inc. All rights reserved.
2// Licensed under the Apache License, Version 2.0.
3
4@import "../tooltip/common";
5@import "./common";
6
7$handle-size: $pt-icon-size-standard !default;
8$track-size: $handle-size - $pt-grid-size !default;
9$label-offset: $handle-size + 4px !default;
10
11// retain legacy variable aliases so as to not break consumers
12$handle-height: $handle-size !default;
13$track-height: $track-size !default;
14
15.#{$ns}-slider {
16 @include slider-orientation($pt-input-height-large, $vertical: false);
17 cursor: default;
18 outline: none;
19 position: relative;
20 user-select: none;
21
22 &:hover {
23 cursor: pointer;
24 }
25
26 &:active {
27 cursor: grabbing;
28 }
29
30 &.#{$ns}-disabled {
31 cursor: not-allowed;
32 opacity: 0.5;
33 }
34
35 &.#{$ns}-slider-unlabeled {
36 height: $handle-size;
37 }
38}
39
40.#{$ns}-slider-track,
41.#{$ns}-slider-progress {
42 @include slider-track-orientation($handle-size, $track-size, $vertical: false);
43 position: absolute;
44}
45
46.#{$ns}-slider-track {
47 border-radius: $pt-border-radius;
48 overflow: hidden;
49}
50
51.#{$ns}-slider-progress {
52 background: rgba($gray1, 0.2);
53
54 .#{$ns}-dark & {
55 background: rgba($black, 0.5);
56 }
57
58 @each $intent, $color in $pt-intent-colors {
59 &.#{$ns}-intent-#{$intent} {
60 background-color: $color;
61 }
62 }
63}
64
65.#{$ns}-slider-handle {
66 @include pt-button();
67 border-radius: $pt-border-radius;
68 box-shadow: $button-box-shadow-overlay;
69 cursor: pointer;
70 height: $handle-size;
71 left: 0;
72 position: absolute;
73 top: 0;
74 width: $handle-size;
75
76 // ensure target handle's label always covers neighbors
77 &:focus {
78 z-index: 1;
79 }
80
81 &:hover {
82 @include pt-button-hover();
83 box-shadow: $button-box-shadow-overlay;
84 cursor: grab;
85 z-index: 2;
86 }
87
88 &.#{$ns}-active {
89 @include pt-button-active();
90 box-shadow: $button-box-shadow-overlay-active;
91 cursor: grabbing;
92 }
93
94 .#{$ns}-disabled & {
95 background: $gray5;
96 box-shadow: none;
97 // easy way to avoid lots of special cases to ignore mouse states when disabled:
98 pointer-events: none;
99 }
100
101 .#{$ns}-dark & {
102 @include pt-dark-button();
103
104 &,
105 &:hover {
106 background-color: $dark-gray5;
107 }
108
109 &.#{$ns}-active {
110 background-color: $dark-gray3;
111 }
112 }
113
114 .#{$ns}-dark .#{$ns}-disabled & {
115 background: $gray1;
116 border-color: $gray1;
117 box-shadow: none;
118 }
119
120 .#{$ns}-slider-label {
121 background: $tooltip-background-color;
122 border-radius: $pt-border-radius;
123 box-shadow: $pt-tooltip-box-shadow;
124 color: $tooltip-text-color;
125 margin-left: $handle-size / 2;
126
127 .#{$ns}-dark & {
128 background: $dark-tooltip-background-color;
129 box-shadow: $pt-dark-tooltip-box-shadow;
130 color: $dark-tooltip-text-color;
131 }
132
133 .#{$ns}-disabled & {
134 box-shadow: none;
135 }
136 }
137
138 &.#{$ns}-start,
139 &.#{$ns}-end {
140 width: $handle-size / 2;
141 }
142
143 &.#{$ns}-start {
144 border-bottom-right-radius: 0;
145 border-top-right-radius: 0;
146 }
147
148 &.#{$ns}-end {
149 border-bottom-left-radius: 0;
150 border-top-left-radius: 0;
151 margin-left: $handle-size / 2;
152
153 .#{$ns}-slider-label {
154 margin-left: 0;
155 }
156 }
157}
158
159.#{$ns}-slider-label {
160 @include slider-label-orientation($label-offset);
161 display: inline-block;
162 font-size: $pt-font-size-small;
163 line-height: 1;
164 padding: ($pt-grid-size / 5) ($pt-grid-size / 2);
165 position: absolute;
166 vertical-align: top;
167}
168
169.#{$ns}-slider.#{$ns}-vertical {
170 @include slider-orientation($pt-input-height-large, $vertical: true);
171
172 .#{$ns}-slider-track,
173 .#{$ns}-slider-progress {
174 @include slider-track-orientation($handle-size, $track-size, $vertical: true);
175 }
176
177 .#{$ns}-slider-progress {
178 top: auto;
179 }
180
181 .#{$ns}-slider-label {
182 @include slider-label-orientation($label-offset, $vertical: true);
183 }
184
185 .#{$ns}-slider-handle {
186 top: auto;
187
188 .#{$ns}-slider-label {
189 margin-left: 0;
190 margin-top: -$handle-size / 2;
191 }
192
193 &.#{$ns}-end,
194 &.#{$ns}-start {
195 height: $handle-size / 2;
196 margin-left: 0;
197 width: $handle-size;
198 }
199
200 &.#{$ns}-start {
201 border-bottom-right-radius: $pt-border-radius;
202 border-top-left-radius: 0;
203
204 .#{$ns}-slider-label {
205 transform: translate($label-offset);
206 }
207 }
208
209 &.#{$ns}-end {
210 border-bottom-left-radius: 0;
211 border-bottom-right-radius: 0;
212 border-top-left-radius: $pt-border-radius;
213 margin-bottom: $handle-size / 2;
214 }
215 }
216}