From 45947cd491b1e85bd89d96dc1065c5e6b77f988a Mon Sep 17 00:00:00 2001 From: Spythere Date: Fri, 13 Mar 2026 19:14:18 +0100 Subject: [PATCH] chore(filters): filter card responsiveness; slider appearance and functionality --- src/components/StationsView/FilterSlider.vue | 152 ++++++++++-------- .../StationsView/StationFilterCard.vue | 29 ++-- 2 files changed, 93 insertions(+), 88 deletions(-) diff --git a/src/components/StationsView/FilterSlider.vue b/src/components/StationsView/FilterSlider.vue index e07d855..c109c96 100644 --- a/src/components/StationsView/FilterSlider.vue +++ b/src/components/StationsView/FilterSlider.vue @@ -1,6 +1,7 @@ @@ -25,90 +28,113 @@ const props = defineProps({ required: true } }); + +// Change slider value that's the closest one to the mouse position on the slider track click +function moveCloserSliderToMousePos(e: MouseEvent) { + const { clientX, target } = e; + const { minRange, maxRange, step } = sliderGroupsOptions[props.sliderGroup][0]; + + const boundingRect = (target as HTMLElement).getBoundingClientRect(); + const mouseX = clientX - boundingRect.left; + + const leftSliderValue = filters[sliderGroupsOptions[props.sliderGroup][0].id]; + const rightSliderValue = filters[sliderGroupsOptions[props.sliderGroup][1].id]; + + let mouseValue = Math.round((maxRange - minRange) * (mouseX / boundingRect.width)); + + // Adjust mouse value to the closest step point (divide by 10, get rounded number, then multiply by step) + mouseValue = Math.round(mouseValue / step) * step; + + let sliderIndex = + Math.abs(leftSliderValue - mouseValue) < Math.abs(rightSliderValue - mouseValue) ? 0 : 1; + + filters[sliderGroupsOptions[props.sliderGroup][sliderIndex].id] = mouseValue; +} diff --git a/src/components/StationsView/StationFilterCard.vue b/src/components/StationsView/StationFilterCard.vue index 3ab3d60..dad09a2 100644 --- a/src/components/StationsView/StationFilterCard.vue +++ b/src/components/StationsView/StationFilterCard.vue @@ -137,7 +137,7 @@
-
+
@@ -593,38 +593,29 @@ h3.hours-section-header { margin-top: 1em; } -.slider-box { +.option-slider { display: grid; align-items: center; grid-template-columns: 250px 100px 1fr; gap: 0.25em; margin-bottom: 1em; - - &-value { - color: var(--clr-primary); - padding: 0.1em 0.2em; - text-align: center; - } } .slider-value { + color: var(--clr-primary); + padding: 0.1em 0.2em; text-align: center; + font-weight: bold; } @include responsive.smallScreen { - .slider-box { - display: flex; - flex-wrap: wrap; - justify-content: center; + .option-slider { + grid-template-columns: 1fr; + } - &-input { - width: 90%; - } - - &-content { - text-align: center; - } + .slider-content { + text-align: center; } .card_controls > button > p {