mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge Core main into german/hal-644-ar: Arabic on the Vue UI
Main moved the UI to Vue views and Pinia stores, so the Arabic changes to the old DOM controllers now live in their views: the rail legend range comes from formatScaleRange (keeping units a source supplies as given), the voice timeout options are worded by Intl unit formatting in VoiceControl, and the scene editor's JSON fields stay left to right in SceneDialog. Main's CCTV status line, launch panel and calibration values keep the Arabic isolates and Western-digit formatting. isolate() and keepCodesWithValues() read the locale through getLocale(), which follows the page's vue-i18n instance, and the Intl formatters take intlLocale(getLocale()). A language switch now applies in place, and applyDocumentLanguage sets <html dir> on every switch, so the page mirrors without a reload. The icon rails and their tips are placed with logical properties, so they stay on the outer side of the mirrored stacks; Cyber's new stack offsets, padding and edge lines are logical too, and rtl.css moves Cyber's right stack to its new rail clearance. Main removed the Context mini radio, so its right-to-left rules and test go. The Arabic catalog gains main's new strings and drops the ones main no longer uses; the other catalogs keep main's new keys and the branch's landing labels.
This commit is contained in:
commit
bc5d038afd
630 files changed
+41141
-20956
No files matched your search
@@ -0,0 +1,208 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { formatScaleRange } from '../unitLabels.js';
|
||||
import RailCardSetting from './RailCardSetting.vue';
|
||||
import RailChips from './RailChips.vue';
|
||||
import RailRowList from './RailRowList.vue';
|
||||
|
||||
// Optional, ordered blocks without disclosure state. Every control is keyed.
|
||||
const props = defineProps({
|
||||
blocks: { type: Array, default: () => [] },
|
||||
cardId: { type: String, default: undefined },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
// Controls of removed blocks dispatch nothing: a detached element keeps its
|
||||
// last handler, which names a block the owner no longer lists.
|
||||
let live = true;
|
||||
onBeforeUnmount(() => {
|
||||
live = false;
|
||||
});
|
||||
|
||||
function dispatch(descriptor, block) {
|
||||
if (!live || !props.blocks.includes(block)) return;
|
||||
if (!descriptor || descriptor.disabled) return;
|
||||
if (descriptor.params) props.onParams(props.cardId, descriptor.params);
|
||||
else descriptor.onClick?.();
|
||||
}
|
||||
|
||||
const rootTag = (block) =>
|
||||
block.type === 'list' ? 'ol' : block.type === 'actions' ? 'footer' : 'div';
|
||||
const lines = (block) => block.lines || [{ id: block.id, text: block.text }];
|
||||
|
||||
function legendView(legend) {
|
||||
const colors = (legend?.colors || []).filter((color) =>
|
||||
/^#(?:[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color),
|
||||
);
|
||||
const visible = colors.length >= 2 && colors.length === legend.colors.length;
|
||||
const zeroVisible =
|
||||
visible &&
|
||||
legend.units === '°C' &&
|
||||
Number.isInteger(legend.zeroIndex) &&
|
||||
legend.zeroIndex >= 0 &&
|
||||
legend.zeroIndex < colors.length;
|
||||
return {
|
||||
colors,
|
||||
visible,
|
||||
categorical: Boolean(legend?.categorical),
|
||||
zeroVisible,
|
||||
// Styles are strings so an unchanged legend writes nothing; browsers
|
||||
// normalize the colors they read back.
|
||||
rampStyle: visible
|
||||
? `background: linear-gradient(to right, ${colors.join(',')})`
|
||||
: undefined,
|
||||
zeroStyle: zeroVisible
|
||||
? `left: ${(legend.zeroIndex / (colors.length - 1)) * 100}%`
|
||||
: undefined,
|
||||
scale: visible
|
||||
? formatScaleRange(
|
||||
legend.labels[0],
|
||||
legend.labels.at(-1),
|
||||
legend.units,
|
||||
legend.unitsVerbatim === true,
|
||||
)
|
||||
: '',
|
||||
labels: legend?.labels || [],
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-for="block in blocks" :key="`${block.id}:${block.type}`"
|
||||
><RailRowList
|
||||
v-if="block.type === 'list'"
|
||||
:list="block.list"
|
||||
:block-id="block.id"
|
||||
:on-select="(item) => dispatch(item, block)"
|
||||
/><component
|
||||
:is="rootTag(block)"
|
||||
v-else
|
||||
:class="`rail-card-${block.type}`"
|
||||
:data-block-id="block.id"
|
||||
:hidden="
|
||||
block.type === 'legend' ? !legendView(block.legend).visible : undefined
|
||||
"
|
||||
><RailCardBlocks
|
||||
v-if="block.type === 'settings'"
|
||||
:blocks="
|
||||
(block.settings || []).map((setting) => ({
|
||||
...setting,
|
||||
type: 'setting',
|
||||
}))
|
||||
"
|
||||
:card-id="cardId"
|
||||
:on-params="onParams"
|
||||
/><RailCardSetting
|
||||
v-else-if="block.type === 'setting'"
|
||||
:setting="block"
|
||||
:dispatch="(descriptor) => dispatch(descriptor, block)"
|
||||
/><template v-else-if="block.type === 'result'"
|
||||
><div class="rail-card-result-header"
|
||||
><span class="panel-title">{{ block.label }}</span
|
||||
><button
|
||||
class="data-toggle-chip"
|
||||
type="button"
|
||||
data-action-id="clear"
|
||||
:aria-label="t('Clear reading')"
|
||||
:title="t('Clear reading')"
|
||||
:hidden="!block.clear"
|
||||
@click="dispatch(block.clear, block)"
|
||||
>×</button
|
||||
></div
|
||||
><div class="rail-card-result-lines"
|
||||
><RailCardBlocks
|
||||
:blocks="[
|
||||
{ id: 'result-lines', type: 'lines', lines: block.lines },
|
||||
]"
|
||||
:card-id="cardId"
|
||||
:on-params="onParams" /></div></template
|
||||
><template v-else-if="block.type === 'legend'"
|
||||
><div
|
||||
class="rail-card-ramp"
|
||||
:hidden="
|
||||
!legendView(block.legend).visible ||
|
||||
legendView(block.legend).categorical
|
||||
"
|
||||
:style="legendView(block.legend).rampStyle"
|
||||
><span
|
||||
class="rail-card-zero"
|
||||
aria-hidden="true"
|
||||
:hidden="!legendView(block.legend).zeroVisible"
|
||||
:style="legendView(block.legend).zeroStyle"
|
||||
></span></div
|
||||
><div
|
||||
class="rail-card-scale"
|
||||
:hidden="legendView(block.legend).categorical"
|
||||
>{{ legendView(block.legend).scale }}</div
|
||||
><div
|
||||
class="rail-card-legend-entries"
|
||||
:hidden="!legendView(block.legend).categorical"
|
||||
><template v-if="legendView(block.legend).categorical"
|
||||
><div
|
||||
v-for="(color, index) in legendView(block.legend).colors"
|
||||
:key="index"
|
||||
class="rail-card-legend-entry"
|
||||
:data-color="color"
|
||||
><span
|
||||
class="rail-card-legend-swatch"
|
||||
:style="`background: ${color}`"
|
||||
></span
|
||||
><span>{{
|
||||
legendView(block.legend).labels[index] || ''
|
||||
}}</span></div
|
||||
></template
|
||||
></div
|
||||
></template
|
||||
><template v-else-if="block.type === 'actions'"
|
||||
><template
|
||||
v-for="action in block.actions || []"
|
||||
:key="`${action.id}:${action.href ? 'a' : 'button'}`"
|
||||
><a
|
||||
v-if="action.href"
|
||||
class="data-toggle-chip"
|
||||
:data-action-id="action.id"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
:href="action.href"
|
||||
:title="action.title || undefined"
|
||||
@click="dispatch(action, block)"
|
||||
>{{ action.label }}</a
|
||||
><button
|
||||
v-else
|
||||
:class="[
|
||||
'data-toggle-chip',
|
||||
{ active: action.pressed, 'is-reserved': action.reserved },
|
||||
]"
|
||||
type="button"
|
||||
:data-action-id="action.id"
|
||||
:title="action.title || undefined"
|
||||
:disabled="Boolean(action.disabled)"
|
||||
:aria-pressed="
|
||||
action.pressed === undefined
|
||||
? undefined
|
||||
: String(Boolean(action.pressed))
|
||||
"
|
||||
:aria-hidden="
|
||||
action.reserved === undefined
|
||||
? undefined
|
||||
: String(Boolean(action.reserved))
|
||||
"
|
||||
@click="dispatch(action, block)"
|
||||
>{{ action.label }}</button
|
||||
><span class="rail-card-action-hint" :hidden="!action.hint">{{
|
||||
action.hint || ''
|
||||
}}</span></template
|
||||
></template
|
||||
><template v-else
|
||||
><div
|
||||
v-for="line in lines(block)"
|
||||
:key="line.id"
|
||||
:class="`rail-card-line${line.muted ? ' muted' : ''}`"
|
||||
:data-line-id="line.id"
|
||||
>{{ String(line.text ?? '') }}</div
|
||||
></template
|
||||
></component
|
||||
></template
|
||||
>
|
||||
</template>
|
||||
Reference in new issue
Block a user