mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(ui): render rail cards and card blocks as components behind their builders
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.
This commit is contained in:
1 parent
d9fdcfc641
commit
dcecf5c34c
20 files changed
+754
-766
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount } from 'vue';
|
||||
import RailCardBlocks from './RailCardBlocks.vue';
|
||||
|
||||
// One keyed card: a disclosure header and its blocks. The owner decides
|
||||
// which card is open.
|
||||
const props = defineProps({
|
||||
card: { type: Object, required: true },
|
||||
cardClassName: { type: String, default: '' },
|
||||
badgeClassName: { type: String, default: '' },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
onOpen: { type: Function, default: () => {} },
|
||||
});
|
||||
const bodyId = `rail-card-body-${nextBodyId()}`;
|
||||
const open = computed(() => props.card.open !== false);
|
||||
// A removed card's header opens nothing.
|
||||
let live = true;
|
||||
onBeforeUnmount(() => {
|
||||
live = false;
|
||||
});
|
||||
const select = () => live && props.onOpen(props.card.id);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
let bodies = 0;
|
||||
const nextBodyId = () => ++bodies;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
:class="`rail-card${cardClassName ? ` ${cardClassName}` : ''}${open ? ' is-open' : ''}`"
|
||||
:data-card-id="card.id"
|
||||
:data-open="String(open)"
|
||||
><button
|
||||
class="rail-card-header"
|
||||
type="button"
|
||||
:aria-controls="bodyId"
|
||||
:aria-expanded="String(open)"
|
||||
@click="select"
|
||||
><span class="rail-card-labels"
|
||||
><span class="rail-card-heading"
|
||||
><span class="data-icon" aria-hidden="true" :hidden="!card.icon">{{
|
||||
card.icon || ''
|
||||
}}</span
|
||||
><span class="rail-card-title rail-card-nowrap" :title="card.title">{{
|
||||
card.title
|
||||
}}</span></span
|
||||
><span
|
||||
:class="`gev-status-badge gev-status-badge--plain rail-card-badge${badgeClassName ? ` ${badgeClassName}` : ''}`"
|
||||
:hidden="!card.badge"
|
||||
>{{ card.badge || '' }}</span
|
||||
></span
|
||||
><span class="rail-card-disclosure" aria-hidden="true">{{
|
||||
open ? '▾' : '▸'
|
||||
}}</span
|
||||
><span
|
||||
:class="`rail-card-compact${card.compactStatus ? ' status' : ''}`"
|
||||
:hidden="open"
|
||||
>{{ card.compact || '' }}</span
|
||||
></button
|
||||
><div :id="bodyId" class="rail-card-body" :hidden="!open"
|
||||
><RailCardBlocks
|
||||
:blocks="card.blocks || []"
|
||||
:card-id="card.id"
|
||||
:on-params="onParams" /></div
|
||||
></article>
|
||||
</template>
|
||||
Reference in new issue
Block a user