Files
gods-eye-view/src/ui/views/panels/DrawControls.vue
T
Sameh KhamisandManjunath Paparaju 35fb3684ba Vue kit: Draw's and Import's buttons and glyphs are kit controls
UTILITIES ▸ Draw and Import no longer hand-write a button or a Material
Symbols span. Clear and Import are ghost UiButtons (Draw already was), and
the Draw and Import glyphs are UiIcons that keep pp-icon, with
:size="null" so controls.css still sizes them. Draw's five colour swatches
(in the toolbar and in a drawn shape's row) are ghost UiButtons that keep
role="radio", aria-checked and their own active class; they are not
pressed toggles. A drawn shape's row (its swatch, show/hide, the
application's row actions and fly to) is on the kit too, beside the remove
UiCloseButton it already had; its glyphs are UiIcons with :size="null".
Show/hide keeps naming itself Show … / Hide … rather than becoming a
pressed toggle.

Template refs that now hold a component reach the button through $el:
the swatches' arrow-key focus and Import's focus fallback when the last
imported file goes.

The Street Level panel's controls were already kit controls (its ⤢ ⤡ and
⚠ are text characters), so its template is unchanged; the new guard test
pins it with Draw and Import.

src/ui/kit/drawControls.test.mjs pins it: no hand-written button, select,
checkbox, range or Material span in DrawControls, DrawSwatches,
DrawMarkList, GeoImport or StreetLevelPanel; the kit counts per file;
Draw a pressed toggle with active; the swatches radios rather than
pressed; :size="null" on every glyph; and the $el refs.
docs/VUE-MIGRATION.md describes the surface.

Co-authored-by: Manjunath Paparaju <[email protected]>
2026-11-19 12:24:55 -08:00

45 lines
2.5 KiB
Vue

<script setup>
import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import { t } from '../../../i18n/index.js';
import UiButton from '../../kit/UiButton.vue';
import UiIcon from '../../kit/UiIcon.vue';
import UiSegmented from '../../kit/UiSegmented.vue';
import { useDisplayStore } from '../../stores/display.js';
import DrawMarkList from './DrawMarkList.vue';
import DrawSwatches from './DrawSwatches.vue';
// UTILITIES ▸ Draw: the toggle, the shape and the colour for the next shape,
// the hint with Clear, and the drawn shapes' rows. The draw tool publishes
// what they show and answers them through the display store.
const display = useDisplayStore();
const { draw } = storeToRefs(display);
const act = (name, ...args) => display.act(name, ...args);
const drawShape = computed(() => draw.value?.shape ?? 'area');
// Icons, named for screen readers and tooltips.
const shapeOptions = computed(() => [
{ value: 'area', label: t('Area'), icon: 'pentagon', attrs: { 'data-shape': 'area' } },
{ value: 'line', label: t('Line'), icon: 'timeline', attrs: { 'data-shape': 'line' } },
{ value: 'pin', label: t('Pin'), icon: 'location_on', attrs: { 'data-shape': 'pin' } },
]);
</script>
<template>
<div class="pp-toggle-group" id="draw-group">
<UiButton class="pp-toggle-btn" :pressed="draw?.active ?? false" pressed-class="active" id="draw-toggle" @click="act('toggleDraw')" :title="t('Draw on the world — click vertices, double-click or Enter to finish, Esc to cancel')">
<UiIcon class="pp-icon" name="draw" :size="null" />
<span class="pp-label">{{ t('Draw') }}</span>
</UiButton>
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-mode-row">
<UiSegmented class="pp-mode-seg draw-shape-seg" item-class="pp-mode-btn" keyboard="none" :label="t('Shape to draw')" :options="shapeOptions" :model-value="drawShape" @update:model-value="act('setDrawShape', $event)" />
<DrawSwatches id="draw-colors" :label="t('Colour of the next shape')" :model-value="draw?.color ?? 'primary'" @update:model-value="act('setDrawColor', $event)" />
</div>
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-label-row">
<span class="draw-hint" id="draw-hint" aria-live="polite">{{ draw?.hint ?? '' }}</span>
<UiButton class="pp-mode-btn draw-clear-btn" id="draw-clear" @click="act('clearDraw')" :title="t('Remove every mark from the board')">{{ t('Clear') }}</UiButton>
</div>
<DrawMarkList />
</div>
</template>