Split the News panel into Conflicts and Local

Conflicts is the hotspots' significant news, on the map whenever the layer is
on. Local lists every report within 500 km of the view centre below 3,000 km,
and the map shows those instead while it is chosen. The section replaces the
"Include minor news" and "Show event cards" toggles: picture cards are always
on, and Local is what reads minor news. The Conflicts feed reads the same
whichever section is shown.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:30 +01:00
1 parent 4817d2a648
commit f72f79f48b
20 files changed
+280 -189

No files matched your search

+47 -27
View File
@@ -9,9 +9,10 @@ import NewsCard from './NewsCard.vue';
// The News panel: the window the server serves only (the last 24 hours, or
// fewer where the host serves less), or a shorter one chosen at the
// top (24/12/6/3/1 h). Hotspot chips, filters, the chosen
// event, "In view" (reports near the view centre while the camera is low)
// and a continuous feed, newest first. It renders the `feed` view the news
// top (24/12/6/3/1 h), and two sections. Conflicts: hotspot chips, the
// severity floor, the chosen event and a continuous feed, newest first.
// Local: every report near the view centre while the camera is low, which the
// map then shows instead of the hotspots' news. It renders the `feed` view the news
// layer publishes and acts only through `onParams`.
const props = defineProps({
view: { type: Object, default: null },
@@ -19,6 +20,16 @@ const props = defineProps({
});
const filters = computed(() => props.view?.filters ?? {});
const local = computed(() => filters.value.section === 'local');
const sections = computed(() =>
[
{ id: 'conflicts', label: t('Conflicts') },
{ id: 'local', label: t('Local') },
].map((chip) => ({
...chip,
active: (filters.value.section ?? 'conflicts') === chip.id,
})),
);
const chips = computed(() =>
(props.view?.hotspots ?? []).map((chip) => ({
id: chip.id,
@@ -59,10 +70,9 @@ const selectedId = computed(() => props.view?.selected?.id ?? null);
const selectedApart = computed(() => {
const chosen = props.view?.selected;
if (!chosen) return null;
const listed =
props.view.items.some((item) => item.id === chosen.id) ||
(props.view.inView.active &&
props.view.inView.items.some((item) => item.id === chosen.id));
const listed = local.value
? props.view.inView.items.some((item) => item.id === chosen.id)
: props.view.items.some((item) => item.id === chosen.id);
return listed ? null : chosen;
});
const status = computed(() => {
@@ -99,7 +109,22 @@ const clear = () => props.onParams({ clear: true });
<p v-else class="news-readout__window ui-mono">{{
t('Last {hours} h', { hours: view.windowHours })
}}</p>
<div class="news-readout__chips" role="group" :aria-label="t('Hotspots')">
<div
class="news-readout__sections"
role="group"
:aria-label="t('News sections')"
>
<RailChips
:chips="sections"
:on-select="(chip) => setFilter('section', chip.id)"
/>
</div>
<div
v-if="!local"
class="news-readout__chips"
role="group"
:aria-label="t('Hotspots')"
>
<RailChips
:chips="chips"
:on-select="(chip) => setFilter('hotspot', chip.id)"
@@ -107,6 +132,7 @@ const clear = () => props.onParams({ clear: true });
</div>
<div class="news-readout__filters">
<UiSelect
v-if="!local"
class="gev-field news-filter"
:aria-label="t('Severity')"
:model-value="String(filters.minSeverity ?? 2)"
@@ -120,20 +146,6 @@ const clear = () => props.onParams({ clear: true });
:options="categoryOptions"
@update:model-value="setFilter('category', $event)"
/>
<label class="news-toggle"
><input
type="checkbox"
:checked="filters.includeMinor === true"
@change="setFilter('includeMinor', $event.target.checked)"
/><span>{{ t('Include minor news') }}</span></label
>
<label class="news-toggle"
><input
type="checkbox"
:checked="filters.cards !== false"
@change="setFilter('cards', $event.target.checked)"
/><span>{{ t('Show event cards') }}</span></label
>
</div>
<NewsCard
@@ -146,12 +158,16 @@ const clear = () => props.onParams({ clear: true });
/>
<section
v-if="view.inView.active"
v-if="local"
class="news-readout__section"
:aria-label="t('In view')"
:aria-label="t('Local')"
>
<h3 class="news-readout__head ui-mono">{{ t('In view') }}</h3>
<p v-if="view.inView.error" class="news-readout__status">
<UiEmpty
v-if="!view.inView.active"
class="news-readout__empty"
:title="t('Zoom in to see local news')"
/>
<p v-else-if="view.inView.error" class="news-readout__status">
{{ view.inView.error }}
</p>
<UiEmpty
@@ -180,7 +196,11 @@ const clear = () => props.onParams({ clear: true });
</ol>
</section>
<section class="news-readout__section" :aria-label="t('Latest news')">
<section
v-else
class="news-readout__section"
:aria-label="t('Latest news')"
>
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
<ol
v-if="view.items.length"
+25 -15
View File
@@ -119,7 +119,7 @@ test('the panel shows the last 24 h as event cards and opens once', () => {
'Last 24 h',
);
assert.deepEqual(
[...panel.querySelectorAll('.data-toggle-chip[data-chip-id]')].map(
[...panel.querySelectorAll('.news-readout__chips [data-chip-id]')].map(
(chip) => chip.textContent,
),
['All 7', 'Ukraine–Russia 7'],
@@ -189,42 +189,52 @@ test('a card click flies there; open, it links the source and closes', () => {
news.destroy();
});
test('filters, In view and empty or failed reads', () => {
test('filters, the Local section and empty or failed reads', () => {
const { news, panel, calls } = fixture();
news.update(view());
assert.equal(panel.querySelector('[aria-label="In view"]'), null);
assert.equal(panel.querySelector('[aria-label="Local"]'), null);
assert.equal(panel.querySelector('.news-toggle'), null);
const severity = panel.querySelector('select[aria-label="Severity"]');
assert.equal(severity.value, '2');
severity.value = '3';
severity.dispatchEvent(new Event('change'));
assert.deepEqual(calls.at(-1)[1], { filters: { minSeverity: 3 } });
const [minor, cards] = panel.querySelectorAll('.news-toggle input');
assert.equal(minor.checked, false);
assert.equal(cards.checked, true);
cards.checked = false;
cards.dispatchEvent(new Event('change'));
assert.deepEqual(calls.at(-1)[1], { filters: { cards: false } });
panel.querySelector('[data-chip-id="ua-ru-war"]').click();
assert.deepEqual(calls.at(-1)[1], { filters: { hotspot: 'ua-ru-war' } });
panel.querySelector('[data-chip-id="local"]').click();
assert.deepEqual(calls.at(-1)[1], { filters: { section: 'local' } });
news.update(
view({
inView: { active: true, loading: false, error: null, items: [] },
items: [],
hasMore: false,
}),
);
const section = panel.querySelector('[aria-label="In view"]');
assert.match(
section.textContent,
/Nothing reported near here in the last 24 h/,
);
assert.match(
panel.textContent,
/No news matches these filters in the last 24 h/,
);
assert.equal(panel.querySelector('.news-readout__footer button'), null);
// Local: no hotspot chips or severity floor, and its own empty states.
const localView = (inView) =>
view({
filters: normalizeFilters({ section: 'local' }),
inView: { loading: false, error: null, items: [], ...inView },
});
news.update(localView({ active: false }));
const section = panel.querySelector('[aria-label="Local"]');
assert.match(section.textContent, /Zoom in to see local news/);
assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]'), null);
assert.equal(panel.querySelector('select[aria-label="Severity"]'), null);
assert.equal(panel.querySelector('[aria-label="Latest news"]'), null);
news.update(localView({ active: true }));
assert.match(
panel.querySelector('[aria-label="Local"]').textContent,
/Nothing reported near here in the last 24 h/,
);
news.update(view());
news.update(
view({ items: [], error: 'News feed unavailable', hasMore: false }),
);
+1
View File
@@ -116,6 +116,7 @@
letter-spacing: 0.12em;
text-transform: uppercase;
}
.news-readout__sections,
.news-readout__chips {
display: flex;
flex-wrap: wrap;