-
Notifications
You must be signed in to change notification settings - Fork 90
/
_inputrange.scss
146 lines (122 loc) · 3.66 KB
/
_inputrange.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Styling Cross-Browser Compatible Range Inputs with Sass
// Github: https://github.com/darlanrod/input-range-sass
// Author: Darlan Rod https://github.com/darlanrod
// Version 1.5.3
// MIT License
@use 'sass:math';
$track-color: #eceff1 !default;
$thumb-color: #607d8b !default;
$thumb-radius: 12px !default;
$thumb-height: 24px !default;
$thumb-width: 24px !default;
$thumb-shadow-size: 4px !default;
$thumb-shadow-blur: 4px !default;
$thumb-shadow-color: rgba(0, 0, 0, .2) !default;
$thumb-border-width: 2px !default;
$thumb-border-color: #eceff1 !default;
$track-width: 100% !default;
$track-height: 8px !default;
$track-shadow-size: 1px !default;
$track-shadow-blur: 1px !default;
$track-shadow-color: rgba(0, 0, 0, .2) !default;
$track-border-width: 2px !default;
$track-border-color: #cfd8dc !default;
$track-radius: 5px !default;
$contrast: 5% !default;
$ie-bottom-track-color: darken($track-color, $contrast) !default;
@mixin shadow($shadow-size, $shadow-blur, $shadow-color) {
box-shadow: $shadow-size $shadow-size $shadow-blur $shadow-color, 0 0 $shadow-size lighten($shadow-color, 5%);
}
@mixin track {
cursor: default;
height: $track-height;
transition: all .2s ease;
width: $track-width;
}
@mixin thumb {
@include shadow($thumb-shadow-size, $thumb-shadow-blur, $thumb-shadow-color);
background: $thumb-color;
border: $thumb-border-width solid $thumb-border-color;
border-radius: $thumb-radius;
box-sizing: border-box;
cursor: default;
height: $thumb-height;
width: $thumb-width;
}
[type='range'] {
-webkit-appearance: none;
background: transparent;
margin: math.div($thumb-height, 2) 0;
width: $track-width;
&::-moz-focus-outer {
border: 0;
}
&:focus {
outline: 0;
&::-webkit-slider-runnable-track {
background: lighten($track-color, $contrast);
}
&::-ms-fill-lower {
background: $track-color;
}
&::-ms-fill-upper {
background: lighten($track-color, $contrast);
}
}
&::-webkit-slider-runnable-track {
@include track;
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
background: $track-color;
border: $track-border-width solid $track-border-color;
border-radius: $track-radius;
}
&::-webkit-slider-thumb {
@include thumb;
-webkit-appearance: none;
margin-top: (math.div((-$track-border-width * 2 + $track-height), 2) - math.div($thumb-height, 2));
}
&::-moz-range-track {
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
@include track;
background: $track-color;
border: $track-border-width solid $track-border-color;
border-radius: $track-radius;
height: math.div($track-height, 2);
}
&::-moz-range-thumb {
@include thumb;
}
&::-ms-track {
@include track;
background: transparent;
border-color: transparent;
border-width: math.div($thumb-height, 2) 0;
color: transparent;
}
&::-ms-fill-lower {
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
background: $ie-bottom-track-color;
border: $track-border-width solid $track-border-color;
border-radius: ($track-radius * 2);
}
&::-ms-fill-upper {
@include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
background: $track-color;
border: $track-border-width solid $track-border-color;
border-radius: ($track-radius * 2);
}
&::-ms-thumb {
@include thumb;
margin-top: math.div($track-height, 4);
}
&:disabled {
&::-webkit-slider-thumb,
&::-moz-range-thumb,
&::-ms-thumb,
&::-webkit-slider-runnable-track,
&::-ms-fill-lower,
&::-ms-fill-upper {
cursor: not-allowed;
}
}
}