mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge pull request #1851 from bilawalsidhu/samehkhamis/kit-sweep-layer-finder
Vue kit: the layer finder's buttons and glyphs are kit controls
This commit is contained in:
5 files changed
+85
-20
No files matched your search
@@ -0,0 +1,2 @@
|
||||
- The Layer Finder's buttons and glyphs are now kit controls, with the same
|
||||
look and behaviour (manjunath22466, samehkhamis, #1851).
|
||||
+10
-1
@@ -84,7 +84,7 @@ adapter is gone.
|
||||
`UiButton` adds `pressedClass`, Core's class on a pressed toggle (most use
|
||||
`active`); its pressed classes toggle through `classList`, so a class other
|
||||
code adds (a voice highlight) survives a press. Not every pressed toggle in
|
||||
the views is one yet: the context view, the Layer Finder,
|
||||
the views is one yet: the context view,
|
||||
the Stories screens and a few panel buttons still hand-write theirs, and
|
||||
Bhote Koshi's cinematic button and the tilt-map button have owners that
|
||||
write their state into the DOM. Core's
|
||||
@@ -126,6 +126,15 @@ context view shows too). Their glyphs are `UiIcon`s with `:size="null"`,
|
||||
so entity-card.css and spot-conditions.css still size them
|
||||
(`src/ui/kit/entityCardControls.test.mjs` pins it). Ask GEV's chat bubble
|
||||
stays inline SVG, since no Material symbol the page loads draws it.
|
||||
The Layer Finder's buttons (Search, Filter, the filter menu's Status and
|
||||
Category options and the bar's two clear chips) are ghost `UiButton`s.
|
||||
Search and the options are pressed toggles; the options' pressed class is
|
||||
`active`, while Search keeps its own `active` binding, which also stays on
|
||||
while a query is typed. The Filter button opens a disclosure and carries
|
||||
`aria-expanded`, not `aria-pressed`. Every glyph its own template draws is
|
||||
a `UiIcon` with `:size="null"`, so `layer-finder.css` still sizes them
|
||||
(`src/ui/kit/layerFinderControls.test.mjs` pins it); the search field's
|
||||
magnifier is `UiSearchField`'s own span.
|
||||
`UiSelect` renders the bare native select (Core's labels sit outside it or
|
||||
come as an `aria-label`) with `v-model`, `options` and `disabled`;
|
||||
options that carry their own attributes come through the slot, a caller's
|
||||
|
||||
@@ -1343,6 +1343,7 @@
|
||||
"src/ui/kit/UiDialog.vue",
|
||||
"src/ui/kit/UiDialog.test.mjs",
|
||||
"src/ui/kit/dialogs.test.mjs",
|
||||
"src/ui/kit/layerFinderControls.test.mjs",
|
||||
"src/ui/kit/entityCardControls.test.mjs",
|
||||
"src/ui/kit/visualControls.test.mjs",
|
||||
"src/ui/kit/welcomeControls.test.mjs",
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// The Layer Finder's buttons and Material glyphs are the kit's: its template
|
||||
// hand-writes no <button>, aria-pressed, Material Symbols span or inline SVG.
|
||||
// Its search field is a UiSearchField.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script and style. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
||||
}
|
||||
const finder = template('LayerFinder.vue');
|
||||
|
||||
test('the Layer Finder hand-writes no button; each is a UiButton', () => {
|
||||
assert.deepEqual(finder.match(/<button\b/gi) ?? [], []);
|
||||
// Search, Filter, the Status and Category options, and the two chips.
|
||||
assert.equal(finder.match(/<UiButton\b/g)?.length, 6);
|
||||
assert.equal(finder.match(/<UiSearchField\b/g)?.length, 1);
|
||||
});
|
||||
|
||||
test('its pressed toggles leave aria-pressed to UiButton', () => {
|
||||
assert.deepEqual(finder.match(/aria-pressed/g) ?? [], []);
|
||||
const pressed = finder.match(/<UiButton\b[^>]*:pressed=[^>]*>/g) ?? [];
|
||||
// Search and the Status and Category options.
|
||||
assert.equal(pressed.length, 3);
|
||||
// Only the options' active class follows their pressed state; Search's
|
||||
// also stays on while a query is typed, so it keeps its own binding.
|
||||
assert.equal(
|
||||
pressed.filter((tag) => tag.includes('pressed-class="active"')).length,
|
||||
2,
|
||||
);
|
||||
assert.match(
|
||||
finder,
|
||||
/id="layer-finder-search-btn"[^>]*:class="\{ active: searching \|\| query \}"/,
|
||||
);
|
||||
});
|
||||
|
||||
test('the Layer Finder hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
assert.deepEqual(finder.match(/material-symbols-outlined/g) ?? [], []);
|
||||
assert.deepEqual(finder.match(/<svg\b/gi) ?? [], []);
|
||||
const icons = finder.match(/<UiIcon\b[^>]*>/g) ?? [];
|
||||
// Search, Filter, the two option radios and the two chips' close.
|
||||
assert.equal(icons.length, 6);
|
||||
// Without it the kit writes an 18px size that beats layer-finder.css.
|
||||
for (const icon of icons) assert.match(icon, /:size="null"/);
|
||||
});
|
||||
@@ -22,6 +22,8 @@ const finder = {
|
||||
<script setup>
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
|
||||
import { msg, t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSearchField from '../../kit/UiSearchField.vue';
|
||||
|
||||
// Search and filter for the Data Layers list. The rows are rendered elsewhere
|
||||
@@ -185,7 +187,8 @@ async function toggleFilter() {
|
||||
}
|
||||
function closeFilter({ refocus = false } = {}) {
|
||||
filtering.value = false;
|
||||
if (refocus) triggerEl.value?.focus();
|
||||
// The trigger is a UiButton; its root is the button.
|
||||
if (refocus) triggerEl.value?.$el?.focus();
|
||||
}
|
||||
function onMenuKey(event) {
|
||||
if (event.key === 'Escape') {
|
||||
@@ -223,37 +226,37 @@ if (props.part === 'buttons') {
|
||||
|
||||
<template>
|
||||
<template v-if="part === 'buttons'">
|
||||
<button id="layer-finder-search-btn" type="button" class="layer-finder__btn" :class="{ active: searching || query }" :aria-pressed="String(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||
</button>
|
||||
<UiButton id="layer-finder-search-btn" class="layer-finder__btn" :class="{ active: searching || query }" :pressed="Boolean(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
|
||||
<UiIcon name="search" :size="null" />
|
||||
</UiButton>
|
||||
<span ref="filterEl" class="layer-finder__filter">
|
||||
<button ref="triggerEl" type="button" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">filter_list</span>
|
||||
</button>
|
||||
<UiButton ref="triggerEl" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
|
||||
<UiIcon name="filter_list" :size="null" />
|
||||
</UiButton>
|
||||
<span v-if="filtering" id="layer-finder-menu" ref="menuEl" class="layer-finder__menu" role="group" :aria-label="t('Filter layers')" @keydown="onMenuKey">
|
||||
<span role="group" :aria-label="t('Status')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Status') }}</span>
|
||||
<button v-for="s in SHOWS" :key="s.id" type="button" :aria-pressed="String(show === s.id)" :class="{ active: show === s.id }" @click="show = s.id">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ show === s.id ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ t(s.label) }}
|
||||
</button>
|
||||
<UiButton v-for="s in SHOWS" :key="s.id" :pressed="show === s.id" pressed-class="active" @click="show = s.id">
|
||||
<UiIcon :name="show === s.id ? 'radio_button_checked' : 'radio_button_unchecked'" :size="null" />{{ t(s.label) }}
|
||||
</UiButton>
|
||||
</span>
|
||||
<span v-if="categories.length" role="group" :aria-label="t('Category')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Category') }}</span>
|
||||
<button v-for="c in categories" :key="c.key" type="button" :aria-pressed="String(category === c.key)" :class="{ active: category === c.key }" @click="pickCategory(c.key)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ category === c.key ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ c.label }}
|
||||
</button>
|
||||
<UiButton v-for="c in categories" :key="c.key" :pressed="category === c.key" pressed-class="active" @click="pickCategory(c.key)">
|
||||
<UiIcon :name="category === c.key ? 'radio_button_checked' : 'radio_button_unchecked'" :size="null" />{{ c.label }}
|
||||
</UiButton>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<div v-else-if="searching || narrowed" class="layer-finder__bar">
|
||||
<UiSearchField v-if="searching" v-model="query" tag="label" class="layer-finder__field" input-id="layer-finder-input" :label="t('Search layers')" :placeholder="t('Search layers…')" @escape="(event) => { event.preventDefault(); closeSearch(); }" />
|
||||
<button v-if="show !== 'all'" type="button" class="layer-finder__chip" @click="show = 'all'">
|
||||
{{ show === 'on' ? t('On') : t('Off') }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<button v-if="category" type="button" class="layer-finder__chip" @click="category = ''">
|
||||
{{ categoryLabel }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<UiButton v-if="show !== 'all'" class="layer-finder__chip" @click="show = 'all'">
|
||||
{{ show === 'on' ? t('On') : t('Off') }}<UiIcon name="close" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton v-if="category" class="layer-finder__chip" @click="category = ''">
|
||||
{{ categoryLabel }}<UiIcon name="close" :size="null" />
|
||||
</UiButton>
|
||||
<p v-if="narrowed && shown === 0" class="layer-finder__empty" role="status">{{ t('No layers match') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user