mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(kit): render the remaining ranges with UiSlider
UiSlider merges a caller's own input, change and blur handlers with its own, leaves the input alone on a null model, and gains unstyled for a range drawn as the browser's own. The rail card setting, observation timeline, imagery opacity, Street Level date and Bhote Koshi split and progress ranges now render through it. The timeline and the setting ranges put the handle back once their owner has answered, since a drag that ends where the slider last rendered leaves its model unchanged. The radio tuner keeps its own input: its owner moves the handle back to the selected station without changing the slot.
This commit is contained in:
1 parent
b9ecb9b9f5
commit
2e43bd9985
12 files changed
+200
-54
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { vRangeValue } from './rangeValue.js';
|
||||
import RailChips from './RailChips.vue';
|
||||
import UiSlider from '../kit/UiSlider.js';
|
||||
|
||||
// One setting: a chip group and an optional range. The handle's value is held
|
||||
// until the owner's next update; a range that commits on change keeps it
|
||||
@@ -57,12 +57,23 @@ function rangeParams(input) {
|
||||
return { params: { [current.param]: next } };
|
||||
}
|
||||
|
||||
// The handle shows the value again once the owner has answered: an owner
|
||||
// that clamps or refuses may leave the slider's model where it last
|
||||
// rendered, and then it would not render.
|
||||
function place(input) {
|
||||
if (!range.value) return;
|
||||
const next = String(value.value);
|
||||
if (input.value !== next) input.value = next;
|
||||
}
|
||||
|
||||
function onInput(event) {
|
||||
const params = rangeParams(event.target);
|
||||
if (!params) return;
|
||||
// The readout follows the handle at once, whether or not the owner redraws.
|
||||
draft.value = { range: range.value, value: Number(event.target.value) };
|
||||
if (!range.value.commitOnChange) props.dispatch(params);
|
||||
if (range.value.commitOnChange) return;
|
||||
props.dispatch(params);
|
||||
place(event.target);
|
||||
}
|
||||
|
||||
function onChange(event) {
|
||||
@@ -71,6 +82,7 @@ function onChange(event) {
|
||||
// Committed: the next update shows the owner's value, as before.
|
||||
if (draft.value) draft.value = { ...draft.value, committed: true };
|
||||
if (params) props.dispatch(params);
|
||||
place(event.target);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -83,14 +95,13 @@ function onChange(event) {
|
||||
><span class="rail-card-setting-range-label" :hidden="!range.label">{{
|
||||
range.label || ''
|
||||
}}</span
|
||||
><input
|
||||
type="range"
|
||||
class="gev-quantitative-slider rail-card-setting-range"
|
||||
><UiSlider
|
||||
class="rail-card-setting-range"
|
||||
:data-range-id="range.id || setting.id"
|
||||
:min="String(Number(range.min))"
|
||||
:max="String(Number(range.max))"
|
||||
:step="String(Number(range.step))"
|
||||
v-range-value="String(value)"
|
||||
:model-value="String(value)"
|
||||
:disabled="Boolean(range.disabled)"
|
||||
:aria-label="range.ariaLabel || setting.label"
|
||||
:aria-valuetext="valueText"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
||||
import { vRangeValue } from './rangeValue.js';
|
||||
import { formatUtcDayMonth, t } from '../../i18n/index.js';
|
||||
import { utcClock } from './utcClock.js';
|
||||
import UiSlider from '../kit/UiSlider.js';
|
||||
|
||||
// Stable native transport with local preview and a coalesced 150 ms drag
|
||||
// commit. While the handle is dragged the slider keeps the ticks it was
|
||||
@@ -88,6 +88,13 @@ function preview(event) {
|
||||
if (typeof readout === 'string') shown.value = { ...shown.value, readout };
|
||||
if (timer === null) timer = setTimeout(commit, 150);
|
||||
}
|
||||
// The handle shows the shown index again. A drag that ends where it began
|
||||
// (an input and a cancel, or a refused commit, before the next render)
|
||||
// leaves the slider's model unchanged, so it would not render.
|
||||
const place = (input) => {
|
||||
const index = String(shown.value.index);
|
||||
if (input && input.value !== index) input.value = index;
|
||||
};
|
||||
function change(event) {
|
||||
if (props.state.disabled) return;
|
||||
const index = Number(event.target.value);
|
||||
@@ -95,12 +102,14 @@ function change(event) {
|
||||
dragging = false;
|
||||
commit();
|
||||
sync();
|
||||
place(event.target);
|
||||
}
|
||||
function reset() {
|
||||
function reset(event) {
|
||||
cancel();
|
||||
pending = null;
|
||||
dragging = false;
|
||||
sync();
|
||||
place(event?.target);
|
||||
}
|
||||
function blur(event) {
|
||||
if (dragging) change(event);
|
||||
@@ -122,13 +131,12 @@ const act = (fn) => {
|
||||
:disabled="disabled || state.index <= 0"
|
||||
@click="act(() => onStep(-1))"
|
||||
>‹</button
|
||||
><input
|
||||
type="range"
|
||||
:class="`gev-quantitative-slider${sliderClassName ? ` ${sliderClassName}` : ''}`"
|
||||
><UiSlider
|
||||
:class="sliderClassName || undefined"
|
||||
min="0"
|
||||
:max="String(Math.max(0, shown.ticks.length - 1))"
|
||||
step="1"
|
||||
v-range-value="String(shown.index)"
|
||||
:model-value="String(shown.index)"
|
||||
:disabled="disabled"
|
||||
:aria-label="t('Observed history')"
|
||||
:aria-valuetext="utc(shown.ticks[shown.index])"
|
||||
|
||||
Reference in new issue
Block a user