-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathApp.vue
62 lines (54 loc) · 1.59 KB
/
App.vue
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
<script setup lang="ts">
import HelloWorld from './components/HelloWorld.vue';
import { ref, watch, onMounted, type Ref } from 'vue';
import type { ComponentProps } from 'svelte';
import type { RangeSlider as RangeSliderType } from 'svelte-range-slider-pips';
import RangeSlider from 'svelte-range-slider-pips';
const values = ref([22, 44]); // values to bind to slider
const $node: Ref<HTMLElement | null> = ref(null); // dom reference for binding on mount
let MyRangeSlider: RangeSliderType; // slider instance reference
const sliderProps: ComponentProps<RangeSliderType> = {
values: values.value,
pips: true,
range: true
};
onMounted(() => {
if ($node.value) {
MyRangeSlider = new RangeSlider({
target: $node.value,
props: sliderProps
});
MyRangeSlider.$on('change', (e) => (values.value = e.detail.values));
watch(values, () => {
MyRangeSlider.$set({ values: values.value });
});
}
});
</script>
<template>
<header>
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<div class="wrapper">
<HelloWorld msg="You did it!" />
</div>
</header>
<div id="my-slider" ref="$node"></div>
{{ values }}
<button @click="() => (values = [...values.map((v) => v + 10)])">Add 10</button>
</template>
<style scoped>
header {
line-height: 1.5;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
}
</style>