mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Put news on the globe, with a feed panel in the right rail
Events ▸ News draws the last 24 hours of reports from curated hotspots (Ukraine–Russia, Israel–Gaza–Lebanon, Iran–Hormuz, Yemen–Red Sea, Sudan, Sahel) and developing situations elsewhere, from any server that answers the `/api/news` read routes. - Globe: one marker per merged event, clamped to the ground and culled at the horizon; one beacon per hotspot when zoomed out and a pulsing beacon for a developing situation; hotspot outlines with disputed areas dotted and labelled by who administers and who claims them; picture cards for at most ten major or fast-growing events with two or more sources, never overlapping, switchable off. - Panel: hotspot chips, a severity filter (significant and above by default), categories, minor news off by default, and a scrolling list of event cards with picture, headline, place, sources, age and the sides that reported it. "In view" lists what is near the map below 3,000 km once the camera settles. A card flies the globe to its event and opens it with a link to the publisher. Reduced motion stops the pulse and the flights. - Core serves no news itself: the local server proxies GEV_NEWS_ORIGIN when it is set, and answers 503 unavailable otherwise, so the layer reads "not configured" once instead of retrying. - Share token 9 (enabled-only); voice stays off for this layer.
This commit is contained in:
1 parent
2d9d518946
commit
5bb489d1fb
48 files changed
+3394
-53
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import NewsFeed from './news/NewsFeed.vue';
|
||||
|
||||
const LAYER_ID = 'news';
|
||||
const LOAD_MORE_MARGIN_PX = 160;
|
||||
// Remounting must not reopen a panel the reader already collapsed.
|
||||
const appearedPanels = new WeakSet();
|
||||
const set = (node, key, value) => {
|
||||
if (node[key] !== value) node[key] = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* The News rail panel (`#news-panel`): it renders the `feed` view the news
|
||||
* layer publishes through its row controls, shows itself only while the
|
||||
* layer is on, and acts only through setLayerParams. Near the bottom of its
|
||||
* scroller it asks for the next older page, once per page.
|
||||
*/
|
||||
export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
|
||||
const document = container?.ownerDocument;
|
||||
if (!document?.createElement) return null;
|
||||
const panel = container.closest?.('#news-panel');
|
||||
const count = panel?.querySelector('#news-panel-count');
|
||||
const onParams = (params) =>
|
||||
setLayerParams(LAYER_ID, params, { origin: 'user' });
|
||||
let view = null;
|
||||
let destroyed = false;
|
||||
let requestedAt = -1;
|
||||
|
||||
function render() {
|
||||
if (destroyed) return;
|
||||
renderVue(h(NewsFeed, { view, onParams }), container);
|
||||
const hidden = !view;
|
||||
if (panel) set(panel, 'hidden', hidden);
|
||||
if (count) set(count, 'textContent', String(view?.items.length ?? 0));
|
||||
if (!hidden && panel && !appearedPanels.has(panel)) {
|
||||
appearedPanels.add(panel);
|
||||
// First appearance opens the panel unless a stored or shared collapse
|
||||
// choice exists (marked by the panel chrome when it restored the state).
|
||||
const preference = panel.dataset?.collapsedPreference;
|
||||
if (
|
||||
panel.classList?.contains('collapsed') &&
|
||||
(preference === undefined || preference === 'default')
|
||||
)
|
||||
panel.querySelector('[data-collapse-target="news-panel"]')?.click();
|
||||
}
|
||||
}
|
||||
|
||||
const onScroll = () => {
|
||||
if (!view?.hasMore || view.loading) return;
|
||||
const remaining =
|
||||
container.scrollHeight - container.scrollTop - container.clientHeight;
|
||||
if (remaining > LOAD_MORE_MARGIN_PX) return;
|
||||
if (requestedAt === view.items.length) return;
|
||||
requestedAt = view.items.length;
|
||||
onParams({ loadMore: true });
|
||||
};
|
||||
container.addEventListener?.('scroll', onScroll, { passive: true });
|
||||
|
||||
return {
|
||||
/** Show the layer's feed view, or hide the panel with null. */
|
||||
update(next) {
|
||||
view = next || null;
|
||||
render();
|
||||
},
|
||||
destroy() {
|
||||
destroyed = true;
|
||||
container.removeEventListener?.('scroll', onScroll);
|
||||
renderVue(null, container);
|
||||
if (panel) set(panel, 'hidden', true);
|
||||
if (count) set(count, 'textContent', '0');
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user