Files
gods-eye-view/src/ui/credits/CreditsView.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

91 lines
3.7 KiB
Vue

<script setup>
import { t } from '../../i18n/index.js';
import UiButton from '../kit/UiButton.vue';
import UiCloseButton from '../kit/UiCloseButton.vue';
import CreditItem from './CreditItem.vue';
// The attribution line at the bottom left and the "Data attribution" list it
// opens, both at the end of `to` (the page's body), where the page's rules
// place them. The owner (src/ui/creditsView.js) computes the credits shown,
// keeps the list's open state and its focus, and takes the clicks and keys;
// `elements` receives the line's, the button's and the list's elements for
// it.
const props = defineProps({
to: { type: Object, required: true },
panelId: { type: String, required: true },
/** The credits on the line, once each. */
inline: { type: Array, required: true },
/** The credits in the list, once each. */
listed: { type: Array, required: true },
open: { type: Boolean, default: false },
/**
* The locale its words are in: a change words them again. The template
* never reads it; `t()` is not reactive, so a new value is what makes the
* view render again in the new language.
*/
locale: { type: String, default: '' },
elements: { type: Object, required: true },
onExpand: { type: Function, default: () => {} },
onClose: { type: Function, default: () => {} },
onKeydown: { type: Function, default: () => {} },
});
/** Between the line's credits, and before the list's button. */
const SEPARATOR = ' · ';
/** A credit's key: the same text and link are one credit. */
const key = (credit) => `${credit.text}\u0000${credit.href ?? ''}`;
// The list button's words are the slot of a UiButton, which renders inside
// the button: a locale that is not bound to a ref changes nothing the button
// reads, and the owner patches synchronously and reads the result at once. A
// slot given under a condition (`redrawWithView`, always true) is redrawn
// whenever this view is, so the words follow a new locale with the rest.
const redrawWithView = true;
/** Keep `name`'s element for the owner. */
const keep = (name) => (element) => {
props.elements[name] = element?.$el ?? element;
};
</script>
<template>
<Teleport :to="props.to"
><div id="gev-credits" :ref="keep('bar')" class="gev-credits" tabindex="-1"
><span :ref="keep('line')" class="gev-credits-line"
><template v-for="(credit, i) in props.inline" :key="key(credit)"
>{{ i ? SEPARATOR : '' }}<CreditItem :credit="credit" /></template
>{{ props.inline.length && props.listed.length ? SEPARATOR : '' }}</span
><UiButton
:ref="keep('expand')"
class="gev-credits-expand"
aria-haspopup="dialog"
:aria-controls="props.panelId"
:aria-expanded="String(props.open)"
:hidden="props.listed.length === 0"
@click="props.onExpand()"
><template v-if="redrawWithView" #default>{{
t('Data attribution')
}}</template></UiButton
></div
><div
:id="props.panelId"
:ref="keep('panel')"
class="gev-credits-panel"
role="dialog"
:aria-labelledby="`${props.panelId}-title`"
:hidden="!props.open"
@keydown="props.onKeydown($event)"
><div class="gev-credits-header"
><span class="gev-credits-title" :id="`${props.panelId}-title`">{{
t('Data provided by:')
}}</span
><UiCloseButton
:ref="keep('close')"
class="gev-credits-close"
bare
:label="t('Close data attribution')"
@click="props.onClose()" /></div
><ul class="gev-credits-list"
><li v-for="credit in props.listed" :key="key(credit)"
><CreditItem :credit="credit" /></li></ul></div
></Teleport>
</template>