-
Notifications
You must be signed in to change notification settings - Fork 1
/
slider.html
182 lines (150 loc) · 6.81 KB
/
slider.html
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>slider</title>
<script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.91/calcite.esm.js"></script>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/1.0.0-beta.91/calcite.css" />
<style>
h1,
calcite-slider {
margin-bottom: 5rem;
}
h2 {
margin-bottom: 2rem;
margin-top: 3rem;
}
body {
font-family: var(--calcite-sans-family);
font-size: var(--calcite-font-size-0);
color: var(--calcite-ui-text-1);
max-width: 1024px;
min-width: 280px;
width: 70vw;
padding: 0 var(--calcite-spacing-double);
margin: 0 auto;
background-color: var(--calcite-ui-background);
}
/* Theme Switcher */
#theme-label {
position: fixed;
top: 20px;
right: 20px;
z-index: 2;
background-color: var(--calcite-ui-background);
border: 1px solid;
border-color: var(--calcite-ui-border-1);
border-radius: var(--calcite-border-radius);
margin: 0;
padding: 10px;
}
#theme-label label {
margin: 0;
}
</style>
</head>
<body>
<main>
<!-- calcite-switch -->
<div id="theme-label">
<calcite-label layout="inline">
Toggle theme
<calcite-switch id="theme-switch"></calcite-switch>
</calcite-label>
</div>
<h1><code>slider</code></h1>
<h2>Test 1. Slider scale</h2>
<calcite-label>Small:
<calcite-slider scale="s" min="10000" max="100000" value="100000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
</calcite-label>
<calcite-label>Medium:
<calcite-slider scale="m" min="10000" max="100000" value="100000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
</calcite-label>
<calcite-label>Large:
<calcite-slider scale="l" min="10000" max="100000" value="100000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
</calcite-label>
<h2>Test 2. Disabled Slider</h2>
<calcite-slider disabled min="10000" max="100000" value="50000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
<h2>Test 3. Slider with Label Handle</h2>
<calcite-slider label-handles min="0" max="1000" value="1000" step="100" min-label="0" max-label="1000"></calcite-slider>
<h2>Test 4. Slider with Precise Handle</h2>
<calcite-slider precise min="10000" max="100000" value="100000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
<h2>Test 5. Slider with Precise Label Handle</h2>
<calcite-label>Label Handle:
<calcite-slider label-handles precise min="10000" max="100000" value="100000" step="1000" min-label="10000" max-label="100000"></calcite-slider>
</calcite-label>
<calcite-label>Label Handle with Decimal step:
<calcite-slider label-handles precise min="10000" max="100000" value="100000" step="1000.12" min-label="10000" max-label="100000"></calcite-slider>
</calcite-label>
<h2>Test 6. Slider with Ticks</h2>
<calcite-label>Ticks:
</calcite-label>
<calcite-label>Ticks with labeled handles:
<calcite-slider min="0" max="100" value="40" step="10" ticks="10" label-handles min-label="0" max-label="100"></calcite-slider>
</calcite-label>
<calcite-label>Labeled Ticks:
<calcite-slider min="0" max="100" value="40" step="10" ticks="10" label-handles label-ticks min-label="0" max-label="100"></calcite-slider>
</calcite-label>
<h2>Test 7. Slider with Ranges</h2>
<calcite-label>Range handles:
<calcite-slider min="10000" max="100000" min-value="10000" max-value="100000" step="1000" min-label="Temperature range (lower)" max-label="Temperature range (upper)"></calcite-slider>
</calcite-label>
<calcite-label>Range with labeled handles:
<calcite-slider label-handles min="10000" max="100000" min-value="10000" max-value="100000" step="1000" min-label="Temperature range (lower)" max-label="Temperature range (upper)"></calcite-slider>
</calcite-label>
<h2>Test 8. Slider with Histogram</h2>
<calcite-label>Histogram:
<calcite-slider min="0" max="100" value="60" step="1" class="js-histogram" min-label="Temperature range (lower)" max-label="Temperature range (upper>"></calcite-slider>
</calcite-label>
<calcite-label>Histogram with labeled handle:
<calcite-slider min="0" max="100" value="60" step="1" class="js-histogram" label-handles min-label="Temperature range (lower)" max-label="Temperature range (upper>"></calcite-slider>
</calcite-label>
<calcite-label>Histogram with color stops:
<calcite-slider min="0" max="100" value="60" step="1" class="js-histogram js-histogram-colors" min-label="Temperature range (lower)" max-label="Temperature range (upper>"></calcite-slider>
</calcite-label>
<calcite-label>Histogram disabled:
<calcite-slider disabled min="0" max="100" value="60" step="1" class="js-histogram" min-label="Temperature range (lower)" max-label="Temperature range (upper>"></calcite-slider>
</calcite-label>
<calcite-label>Range Histogram:
<calcite-slider class="js-histogram" min="0" max="100" min-value="50" max-value="85" step="1" min-label="Temperature range (lower)" max-label="Temperature range (upper)" scale="m"></calcite-slider>
</calcite-label>
</main>
</body>
<script>
window.onload = () => {
// Theme Switcher
const themeSwitch = document.getElementById("theme-switch");
themeSwitch.addEventListener("calciteSwitchChange", () => {
document.body.classList.toggle("calcite-theme-dark");
});
};
const histogram = [
[0, 0],
[20, 12],
[40, 25],
[60, 55],
[80, 10],
[100, 0]
];
[].slice.call(document.querySelectorAll(".js-histogram")).forEach(function (graphElement) {
graphElement.histogram = histogram;
});
const rainbow = ["red", "orange", "yellow", "green", "cyan", "blue", "violet"];
const colorStops = rainbow.map((color, i) => ({ offset: (1 / (rainbow.length - 1)) * i, color }));
document.querySelectorAll(".js-histogram-colors").forEach(function (graphElement) {
graphElement.histogramStops = colorStops;
});
document.querySelectorAll(".js-histogram-negative").forEach(
(slider) =>
(slider.histogram = [
[-100, 0],
[-80, 12],
[-60, 25],
[-40, 55],
[-20, 10],
[0, 0]
])
);
</script>
</html>