mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
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]>
62 lines
5.0 KiB
Vue
62 lines
5.0 KiB
Vue
<script setup>
|
|
import { storeToRefs } from 'pinia';
|
|
import { computed, shallowRef } from 'vue';
|
|
import { t, tn } from '../../../i18n/index.js';
|
|
import UiButton from '../../kit/UiButton.vue';
|
|
import UiDialog from '../../kit/UiDialog.vue';
|
|
import { vStatusText } from '../../rail/statusText.js';
|
|
import { useSceneSharingStore } from '../../stores/sceneSharing.js';
|
|
|
|
// One open scene sharing dialog, as src/ui/sceneSharing.js presents it. The
|
|
// parent keys this by dialog, so each one opens as a fresh modal: UiDialog
|
|
// opens it on mount and closes it on unmount.
|
|
const props = defineProps({ view: { type: Object, required: true } });
|
|
const { controls } = storeToRefs(useSceneSharingStore());
|
|
|
|
const bodyItems = computed(() => props.view.items.filter((item) => item.place === 'body'));
|
|
const footerItems = computed(() => props.view.items.filter((item) => item.place === 'footer'));
|
|
// Typing reaches the item before any republish, so a field is rewritten only
|
|
// when the owner changes its value, focused or not, as the old code did.
|
|
const statusText = computed(() => ({ text: props.view.status, seq: props.view.statusSeq }));
|
|
|
|
// The browser draws a file input's button and "no file" text in its own
|
|
// language. The native input is stretched, transparent, over the whole row
|
|
// (so click, focus and drops stay native) and translated text is drawn under.
|
|
const focusedFile = shallowRef(null);
|
|
const chosenText = (item) => {
|
|
const count = item.files.length;
|
|
// One file shows its name, like the browser's own picker did.
|
|
return count === 1
|
|
? item.files[0].name
|
|
: count
|
|
? tn(count, '{count} file selected', '{count} files selected')
|
|
: t('No file chosen');
|
|
};
|
|
const onFiles = (item, event) => controls.value?.setFiles(item.id, event.target.files ?? []);
|
|
|
|
const dialogStyle = { background: '#08141e', color: '#e3faff', border: '1px solid #397080', borderRadius: '6px', padding: '20px', width: 'min(720px,calc(100vw - 32px))', boxSizing: 'border-box', position: 'fixed', inset: '0', margin: 'auto', maxHeight: 'calc(100vh - 32px)', overflow: 'auto', font: '14px/1.5 sans-serif' };
|
|
const buttonStyle = { background: '#10242e', color: '#e3faff', border: '1px solid #397080', borderRadius: '3px', padding: '7px 11px', margin: '6px 6px 6px 0', cursor: 'pointer', font: 'inherit' };
|
|
const fieldStyle = (multiline) => ({ display: 'block', boxSizing: 'border-box', width: '100%', padding: '7px', margin: '6px 0 14px', color: '#e3faff', background: '#10242e', border: '1px solid #397080', font: multiline ? '12px monospace' : 'inherit' });
|
|
const fileInputStyle = { ...fieldStyle(false), position: 'absolute', inset: '0', width: '100%', height: '100%', margin: '0', padding: '0', border: '0', opacity: '0', cursor: 'pointer', zIndex: '1' };
|
|
const fileRowStyle = { display: 'flex', alignItems: 'center', gap: '10px', margin: '6px 0 14px', padding: '7px', background: '#10242e', border: '1px solid #397080' };
|
|
const chooserStyle = (focused) => ({ padding: '3px 9px', border: '1px solid #397080', borderRadius: '3px', background: '#08141e', cursor: 'pointer', outline: focused ? '2px solid #e3faff' : '' });
|
|
</script>
|
|
|
|
<template>
|
|
<UiDialog open data-director-dialog class="director-sharing-dialog" :aria-label="view.title" :style="dialogStyle" @dismiss="controls?.cancel()" @browser-close="controls?.cancel()">
|
|
<h2 style="margin-bottom: 12px">{{ view.title }}</h2>
|
|
<div>
|
|
<template v-for="item in bodyItems" :key="item.id">
|
|
<p v-if="item.kind === 'text'" style="margin: 8px 0">{{ item.value }}</p>
|
|
<UiButton v-else-if="item.kind === 'button'" :style="buttonStyle" :disabled="item.disabled" v-bind="item.hook ? { [item.hook]: '' } : {}" @click="controls?.click(item.id)">{{ item.label }}</UiButton>
|
|
<label v-else-if="item.type === 'file'" :style="{ display: 'block', position: 'relative' }">{{ item.label }}<input type="file" :aria-label="item.label" :multiple="item.multiple" :webkitdirectory="item.directory || undefined" :style="fileInputStyle" @change="onFiles(item, $event)" @focus="focusedFile = item.id" @blur="focusedFile = null" /><span aria-hidden="true" :style="fileRowStyle"><span :style="chooserStyle(focusedFile === item.id)">{{ t('Choose files') }}</span><span>{{ chosenText(item) }}</span></span></label>
|
|
<label v-else style="display: block">{{ item.label }}<textarea v-if="item.multiline" rows="9" dir="ltr" spellcheck="false" :aria-label="item.label" :style="fieldStyle(true)" :value="item.value" @input="controls?.setValue(item.id, $event.target.value)"></textarea><input v-else :type="item.type" :aria-label="item.label" :style="fieldStyle(false)" :value="item.value" @input="controls?.setValue(item.id, $event.target.value)" /></label>
|
|
</template>
|
|
</div>
|
|
<p role="status" v-status-text="statusText"></p>
|
|
<div>
|
|
<UiButton v-for="item in footerItems" :key="item.id" :style="buttonStyle" :disabled="item.disabled" :autofocus="item.autofocus || undefined" v-bind="item.hook ? { [item.hook]: '' } : {}" @click="controls?.click(item.id)">{{ item.label }}</UiButton>
|
|
</div>
|
|
</UiDialog>
|
|
</template>
|