Files
gods-eye-view/src/ui/rail/RailCard.vue
T
Sameh KhamisandManjunath Paparaju 40cbe52782 Vue kit: the small surfaces' buttons and glyphs are kit controls
Every hand-written <button> in the locale picker, phone tab bar, globe
actions (Clear, Share, Reset) and compass, imagery divider handle, scene
sharing dialog, layer group index, title logo, Exit clean view, the HUD's
cockpit entry, News card face, rail card header, layer row toggle, credits
line's Data attribution and the camera calibration chips is a ghost
UiButton keeping its id, classes, data-*, aria-* and listeners. Their
Material Symbols spans (tab icons, globe actions, compass needle, cockpit
entry, celestial ring sun and moon) are UiIcons with :size="null".

The Omnibar guide's extra rings, one per further target of a step, are now
drawn by OmnibarGuide.vue from view.subRings instead of being built in
script; startGuide() still reads them from the rendered tree and sets
their boxes each frame.

A UiButton's slot renders inside the button, so under an owner that
patches synchronously (News cards, rail cards, the credits line, the
Omnibar guide's Skip, Offer and Next) a change the button's attributes do
not carry would land a tick late. Those slots are given under a named
condition that is always true (v-if="redrawWithView"), which Vue redraws
with the view.

src/ui/kit/smallSurfacesControls.test.mjs pins it; docs/VUE-MIGRATION.md
describes the surface and the conditional slot.

Co-authored-by: Manjunath Paparaju <[email protected]>
2026-11-19 10:44:16 -08:00

79 lines
2.7 KiB
Vue

<script setup>
import { computed, onBeforeUnmount } from 'vue';
import RailCardBlocks from './RailCardBlocks.vue';
import UiBadge from '../kit/UiBadge.vue';
import UiButton from '../kit/UiButton.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);
// The header's contents are the slot of a UiButton, which renders inside the
// button: a new card alone would reach them only on a later tick, but the
// owner patches synchronously and measures at once. A slot given under a
// condition (`redrawWithView`, always true) is redrawn whenever this card is,
// so it keeps up.
const redrawWithView = true;
</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)"
><UiButton
class="rail-card-header"
:aria-controls="bodyId"
:aria-expanded="String(open)"
@click="select"
><template v-if="redrawWithView" #default
><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
><UiBadge
:class="`gev-status-badge--plain rail-card-badge${badgeClassName ? ` ${badgeClassName}` : ''}`"
:hidden="!card.badge"
>{{ card.badge || '' }}</UiBadge
></span
><span class="rail-card-disclosure" aria-hidden="true">{{
open ? '▾' : '▸'
}}</span
><span
:class="`rail-card-compact${card.compactStatus ? ' status' : ''}`"
:hidden="open"
>{{ card.compact || '' }}</span
></template
></UiButton
><div :id="bodyId" class="rail-card-body" :hidden="!open"
><RailCardBlocks
:blocks="card.blocks || []"
:card-id="card.id"
:on-params="onParams" /></div
></article>
</template>