Skip to content

Commit 65a2c28

Browse files
committed
sort dropdown update
1 parent 8309cbe commit 65a2c28

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed
Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
<template>
22
<!-- eslint-disable max-len -->
3-
<div class="inline-block focus:outline-none ml-2" @focusout="close" tabindex="1">
4-
<div v-bind:class="{'flex': true, 'items-center': true, 'justify-center': true, 'w-20': true, 'h-12': true, 'rounded-xl': true, 'border': true, 'border-gray-matcha': !closed, 'border border-gray-300': closed, 'px-12': true, 'py-2': true, 'focus:outline-none': true, 'cursor-pointer': true}" @click="toggle">
5-
<h1 v-bind:class="{ 'opacity-50': closed }">{{name}}</h1>
3+
<div class="focus:outline-none ml-2 flex-1 sm:flex-none" @focusout="close" tabindex="1">
4+
<div v-bind:class="{'filter-button': true, 'border-gray-matcha': !closed}" @click="toggle">
5+
<h1 v-bind:class="{ 'opacity-50': closed, 'noSelect': true, 'capitalize': true }">{{name}}</h1>
66
</div>
7-
<div id="sliderContainer" ref="afterClick" v-bind:class="{
8-
'h-16': true,
9-
'w-full': true,
10-
'max-w-xs': true,
11-
'mt-4': true,
12-
'flex': true,
13-
'items-center': true,
14-
'justify-center': true,
15-
'overflow-scroll': true,
16-
'rounded-md': true,
17-
'shadow-2xl': true,
18-
'absolute': true,
19-
'left-0': true,
20-
'rounded-md': true,
21-
'bg-white': true,
22-
'slider-bg': true,
23-
'hidden': closed}">
24-
<div ref="slider" class="focus:outline-none w-64"></div>
7+
<div ref="sliderDropdown" v-bind:class="{'slider-dropdown': true, 'hidden': closed}">
8+
<div class="flex my-4">
9+
<h1><span class="font-bold">{{this.slider.startMin}} {{this.unit}}</span> to <span class="font-bold">{{this.slider.startMax}} {{this.unit}}</span></h1>
10+
</div>
11+
<div ref="slider" class="w-64 mb-4"></div>
2512
</div>
2613
</div>
2714
</template>
@@ -31,7 +18,7 @@ import noUiSlider from 'nouislider';
3118
import 'nouislider/distribute/nouislider.css';
3219
3320
export default {
34-
props: ['options', 'name'],
21+
props: ['options', 'name', 'unit'],
3522
data: () => ({
3623
closed: true,
3724
slider: {
@@ -44,20 +31,21 @@ export default {
4431
},
4532
}),
4633
methods: {
47-
select(option) {
34+
select() {
4835
this.closed = true;
49-
this.$emit('sort', this.name, option);
36+
const { min } = this.slider;
37+
const { max } = this.slider;
38+
this.$emit('filter', this.name, { min, max });
5039
},
5140
toggle() {
5241
this.closed = !this.closed;
5342
if (!this.closed) {
5443
this.$nextTick(function () {
55-
this.$refs.afterClick.focus();
44+
this.$refs.sliderDropdown.focus();
5645
});
5746
}
5847
},
5948
close(event) {
60-
// console.log(event.currentTarget.id);
6149
if (!event.currentTarget.contains(event.relatedTarget)) {
6250
this.closed = true;
6351
}
@@ -72,15 +60,19 @@ export default {
7260
max: this.slider.max,
7361
},
7462
});
63+
this.$refs.slider.noUiSlider.on('update', (values) => {
64+
this.slider.startMin = parseInt(values[0], 10);
65+
this.slider.startMax = parseInt(values[1], 10);
66+
});
7567
},
7668
};
7769
</script>
7870

7971
<style>
80-
.noUi-handle, .slider-bg {
72+
.noUi-handle {
8173
outline: none;
8274
}
83-
.noUi-handle:focus, .slider-bg:focus {
75+
.noUi-handle:focus {
8476
outline: none;
8577
}
8678
</style>

0 commit comments

Comments
 (0)