mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
The rail cards, card blocks, settings, chips and row lists are Vue components in src/ui/rail/. createRailCards() and createRailCardBlocks() keep their update and destroy API and patch the components synchronously with render(), so Weather and Recent imagery are unchanged. Controls of a removed block dispatch nothing, a released range keeps its value until the owner's next update, and range values are written only when they differ. Weather's remount state is keyed by its panel. Tests of rendered parts run on happy-dom.
40 lines
956 B
JavaScript
40 lines
956 B
JavaScript
import { h, render } from 'vue';
|
|
import RailCards from './rail/RailCards.vue';
|
|
|
|
/**
|
|
* Keyed cards with optional ordered blocks; the feature owns open-card choice.
|
|
* Renders the RailCards component into `container`, which it owns, and
|
|
* patches it synchronously on every update so the owner can measure at once.
|
|
*/
|
|
export function createRailCards({
|
|
container,
|
|
document = container?.ownerDocument,
|
|
cardClassName = '',
|
|
badgeClassName = '',
|
|
onParams = () => {},
|
|
onOpen = () => {},
|
|
} = {}) {
|
|
if (!document?.createElement || !container) return null;
|
|
let destroyed = false;
|
|
return {
|
|
update(cards = []) {
|
|
if (destroyed) return;
|
|
render(
|
|
h(RailCards, {
|
|
cards,
|
|
cardClassName,
|
|
badgeClassName,
|
|
onParams,
|
|
onOpen,
|
|
}),
|
|
container,
|
|
);
|
|
},
|
|
destroy() {
|
|
if (destroyed) return;
|
|
destroyed = true;
|
|
render(null, container);
|
|
},
|
|
};
|
|
}
|