aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Slider.svelte
blob: 3c94d127554eea97dd4d050ff076a60eb27215a7 (plain) (blame)
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
<script>
	export let value,
		handle,
		min = 0,
		max = 100;
</script>

<input
	id="slider"
	type="range"
	{min}
	{max}
	bind:value
	class="px-0 py-0 my-5"
	style="--bgPercent: {((value - min) * 100) / (max - min)}%;"
	on:input={handle}
/>

<style>
	#slider {
		-webkit-appearance: none;
		width: 100%;
		height: 6px;
		border-radius: 5px;
		background: linear-gradient(
			to right,
			black 0%,
			black var(--bgPercent),
			#f5f7fa var(--bgPercent),
			#f5f7fa 100%
		);
		outline: none;
	}

	#slider:active {
		background-color: black;
	}

	#slider::-webkit-slider-thumb {
		-webkit-appearance: none;
		appearance: none;
		width: 30px;
		height: 30px;
		border-radius: 50%;
		background: black;
		cursor: pointer;
	}

	#slider::-moz-range-thumb {
		width: 30px;
		height: 30px;
		border-radius: 50%;
		background: black;
		cursor: pointer;
	}
</style>