feat(shipwrecks): period picker like air accidents, sharper icons

- Replace the four era chips with the start and end year pickers the
  air-accidents layer uses (the same RowRange control, ported as is);
  the era colours stay as a legend under the row.
- Rasterize the boat marker at 144 px so large markers stay sharp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Itallo BrandãoandClaude Opus 5.5 committed 2026-11-05 04:49:36 -03:00
1 parent dcd0f2cccd
commit 112ffd4386
25 files changed
+439 -71

No files matched your search

+9
View File
@@ -1,6 +1,7 @@
<script setup>
import RailChips from '../rail/RailChips.vue';
import RailRowList from '../rail/RailRowList.vue';
import RowRange from './RowRange.vue';
import RowSlider from './RowSlider.vue';
import RowSwitch from './RowSwitch.vue';
import RowText from './RowText.vue';
@@ -15,6 +16,7 @@ defineProps({
onChip: { type: Function, default: () => {} },
onListItem: { type: Function, default: () => {} },
onSlider: { type: Function, default: () => {} },
onRange: { type: Function, default: () => {} },
});
</script>
@@ -68,6 +70,13 @@ defineProps({
:on-input="
(value) => onSlider(item.id, item.controls.slider.id, value)
"
/><RowRange
v-if="item.controls.range"
:range="item.controls.range"
:on-select="
(end, value) =>
onRange(item.id, item.controls.range.id, end, value)
"
/><span
v-for="(entry, index) in item.controls.legend"
:key="index"
+40
View File
@@ -0,0 +1,40 @@
<script setup>
// A row's start and end pickers on one line (e.g. the Air Accidents period).
// Both ends share one option list; `onSelect` reports which end moved
// ('from' or 'to') and the chosen option value.
defineProps({
range: { type: Object, required: true },
onSelect: { type: Function, default: () => {} },
});
</script>
<template>
<div class="data-toggle-range" :data-range-id="range.id"
><div class="data-toggle-slider-head"
><span class="data-toggle-slider-label">{{ range.label }}</span
><span class="data-toggle-slider-value gev-slider-value">{{
range.valueText
}}</span></div
><div class="data-toggle-range-ends"
><label
v-for="end in ['from', 'to']"
:key="end"
class="data-toggle-range-end"
><span class="data-toggle-range-caption">{{ range[end].label }}</span
><select
class="data-toggle-range-select"
:data-range-end="end"
:aria-label="range[end].ariaLabel || undefined"
:value="String(range[end].value)"
@change="onSelect(end, $event.target.value)"
><option
v-for="option in range.options"
:key="option.value"
:value="String(option.value)"
>{{ option.label }}</option
></select
></label
></div
></div
>
</template>
+59
View File
@@ -159,3 +159,62 @@ test('a row switch and slider render their markup and report choices', () => {
assert.equal(segments[1].classList.contains('active'), true);
render(null, container);
});
test('a row range renders start and end pickers and reports which end moved', () => {
document.body.replaceChildren();
const container = document.body.appendChild(document.createElement('div'));
const picks = [];
const item = {
...row(false),
key: 'air-accidents',
id: 'air-accidents',
controls: {
hidden: false,
chips: [],
segmented: null,
slider: null,
range: {
id: 'period',
label: 'Period',
valueText: '2010–2024',
from: { label: 'From', ariaLabel: 'First year', value: 2010 },
to: { label: 'To', ariaLabel: 'Last year', value: 2024 },
options: [2024, 2010, 2007].map((year) => ({
value: year,
label: String(year),
})),
},
legend: [],
info: null,
list: null,
},
};
render(
h(LayerRows, {
items: [item],
onRange: (id, rangeId, end, value) =>
picks.push([id, rangeId, end, value]),
}),
container,
);
const block = container.querySelector('.data-toggle-range');
assert.equal(block.dataset.rangeId, 'period');
assert.equal(
block.querySelector('.data-toggle-slider-value').textContent,
'2010–2024',
);
const [from, to] = block.querySelectorAll('select.data-toggle-range-select');
assert.equal(from.getAttribute('aria-label'), 'First year');
assert.equal(from.value, '2010');
assert.equal(to.value, '2024');
assert.deepEqual(
[...block.querySelectorAll('.data-toggle-range-caption')].map(
(caption) => caption.textContent,
),
['From', 'To'],
);
to.value = '2007';
to.dispatchEvent(new Event('change', { bubbles: true }));
assert.deepEqual(picks, [['air-accidents', 'period', 'to', '2007']]);
render(null, container);
});