mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
Vue kit: UiSearchField for the Context and Layer Finder searches
UiSearchField is the search glyph, a search input with v-model and, with clearLabel, a UiCloseButton shown while text is typed that clears and refocuses. tag is div or label; attributes go to the frame, and inputId, inputClass, autocomplete and spellcheck to the input. Escape stops at the input and is emitted with its event; focus() focuses the input. search-field.css holds the declarations both skins had in common (the frame's flex row, the input's min-width, border and background), moved out of context-dock.css and layer-finder.css and loaded before them. The browser's cancel button stays each skin's own. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
1711b4b456
commit
52dd576769
12 files changed
+303
-23
No files matched your search
+16
-3
@@ -37,9 +37,9 @@ one-panel rule too. Share links continue to record which panels are open.
|
|||||||
## Component kit
|
## Component kit
|
||||||
|
|
||||||
`src/ui/kit/` holds the generic components: `UiRail`, `UiTooltip`, `UiIcon`,
|
`src/ui/kit/` holds the generic components: `UiRail`, `UiTooltip`, `UiIcon`,
|
||||||
`UiButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`, `UiSelect`,
|
`UiButton`, `UiCloseButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`,
|
||||||
`UiBadge` and `UiEmpty` so far, with more joining as the controls they serve
|
`UiSelect`, `UiSearchField`, `UiBadge` and `UiEmpty` so far, with more
|
||||||
are converted. One component
|
joining as the controls they serve are converted. One component
|
||||||
serves every use of a control, with props for the differences (`UiPanel`'s
|
serves every use of a control, with props for the differences (`UiPanel`'s
|
||||||
`sideways`, `glow`, `scroll`), rather than a copy per panel. The components
|
`sideways`, `glow`, `scroll`), rather than a copy per panel. The components
|
||||||
are styled by the existing stylesheet and custom properties, and they contain
|
are styled by the existing stylesheet and custom properties, and they contain
|
||||||
@@ -54,6 +54,7 @@ never copied:
|
|||||||
| `UiButton` `variant="primary"` | the action surface with a group's main-action accent | `src/ui/styles/action-button.css` |
|
| `UiButton` `variant="primary"` | the action surface with a group's main-action accent | `src/ui/styles/action-button.css` |
|
||||||
| `UiButton` `variant="icon"` | the 22px square glyph button of a panel's collapse toggle | `src/ui/styles/controls.css` |
|
| `UiButton` `variant="icon"` | the 22px square glyph button of a panel's collapse toggle | `src/ui/styles/controls.css` |
|
||||||
| `UiCloseButton` | a close, dismiss or clear button: a bare glyph (× with `glyph="times"`, the Material `close` symbol with `glyph="icon"`) with no padding, border or background of its own and a pointer; the site's feature class sets size, colour, hover and any surface, and `bare` leaves the look off for a skin that keeps the browser's padding | `src/ui/styles/close-button.css` |
|
| `UiCloseButton` | a close, dismiss or clear button: a bare glyph (× with `glyph="times"`, the Material `close` symbol with `glyph="icon"`) with no padding, border or background of its own and a pointer; the site's feature class sets size, colour, hover and any surface, and `bare` leaves the look off for a skin that keeps the browser's padding | `src/ui/styles/close-button.css` |
|
||||||
|
| `UiSearchField` | a search field: the Material `search` glyph and a search input in a flex row, the input bare (no border or background, free to shrink); the site's feature classes set the frame's size, surface and focus ring and the input's type and outline, and the browser's own cancel button is left to each skin | `src/ui/styles/search-field.css` |
|
||||||
| `UiChip` | the read-only chip (a pill of uppercase mono text); `selected` takes the accent | `src/ui/styles/chip.css` |
|
| `UiChip` | the read-only chip (a pill of uppercase mono text); `selected` takes the accent | `src/ui/styles/chip.css` |
|
||||||
| `UiEmpty` | the one-line empty state (dim mono text), its hint on a line below | `src/ui/styles/empty-state.css` |
|
| `UiEmpty` | the one-line empty state (dim mono text), its hint on a line below | `src/ui/styles/empty-state.css` |
|
||||||
| `UiBadge` | the read-only badge (`gev-status-badge`) | `src/ui/styles/status-badge.css` |
|
| `UiBadge` | the read-only badge (`gev-status-badge`) | `src/ui/styles/status-badge.css` |
|
||||||
@@ -107,6 +108,18 @@ clear button in the views is one (`src/ui/kit/closeButtons.test.mjs` pins
|
|||||||
it); Street Level's and the space mission's keep `bare`, since their skins
|
it); Street Level's and the space mission's keep `bare`, since their skins
|
||||||
keep the browser's padding. The close buttons built in script (credits, the
|
keep the browser's padding. The close buttons built in script (credits, the
|
||||||
Quebec CCTV overlay, the guide) are not converted yet.
|
Quebec CCTV overlay, the guide) are not converted yet.
|
||||||
|
`UiSearchField` takes `v-model`, a required `label` (the input's
|
||||||
|
accessible name), `placeholder` and `tag` (`div`, given `role="search"` by
|
||||||
|
the site, or `label`); attributes and classes go to the frame, and
|
||||||
|
`inputId`, `inputClass`, `autocomplete` and `spellcheck` to the input. With
|
||||||
|
`clearLabel` it shows a `UiCloseButton` (`clearClass`, its label as its tip)
|
||||||
|
while text is typed, which empties the field and focuses the input again.
|
||||||
|
Escape stops at the input and is emitted with its event, so a site that also
|
||||||
|
keeps the browser from clearing the field prevents it there; `focus()`
|
||||||
|
focuses the input. The Context search and the Layer Finder's are
|
||||||
|
`UiSearchField`s; the locale picker's combobox, the Omnibar's location
|
||||||
|
field and the Data Library's labelled search are other controls. Its kit rules hold the declarations both search
|
||||||
|
skins had in common, moved rather than copied, and load before them.
|
||||||
`UiSlider` keeps the native range input rather than drawing a
|
`UiSlider` keeps the native range input rather than drawing a
|
||||||
`role="slider"` track, so Core's keyboard, form behaviour and styling stay;
|
`role="slider"` track, so Core's keyboard, form behaviour and styling stay;
|
||||||
it takes `v-model`, `min`, `max`, `step` and `disabled`, emits a
|
it takes `v-model`, `min`, `max`, `step` and `disabled`, emits a
|
||||||
|
|||||||
@@ -1333,6 +1333,9 @@
|
|||||||
"src/ui/kit/UiCloseButton.test.mjs",
|
"src/ui/kit/UiCloseButton.test.mjs",
|
||||||
"src/ui/kit/closeButtons.test.mjs",
|
"src/ui/kit/closeButtons.test.mjs",
|
||||||
"src/ui/styles/close-button.css",
|
"src/ui/styles/close-button.css",
|
||||||
|
"src/ui/kit/UiSearchField.vue",
|
||||||
|
"src/ui/kit/UiSearchField.test.mjs",
|
||||||
|
"src/ui/styles/search-field.css",
|
||||||
"src/ui/styles/chip.css",
|
"src/ui/styles/chip.css",
|
||||||
"src/ui/styles/empty-state.css",
|
"src/ui/styles/empty-state.css",
|
||||||
"src/ui/rail/RailChips.vue",
|
"src/ui/rail/RailChips.vue",
|
||||||
|
|||||||
@@ -242,6 +242,7 @@
|
|||||||
"src/ui/kit/UiEmpty.vue",
|
"src/ui/kit/UiEmpty.vue",
|
||||||
"src/ui/kit/UiBadge.vue",
|
"src/ui/kit/UiBadge.vue",
|
||||||
"src/ui/kit/UiCloseButton.vue",
|
"src/ui/kit/UiCloseButton.vue",
|
||||||
|
"src/ui/kit/UiSearchField.vue",
|
||||||
"src/ui/stores/globeActions.js",
|
"src/ui/stores/globeActions.js",
|
||||||
"src/ui/views/panels/GlobeActions.vue",
|
"src/ui/views/panels/GlobeActions.vue",
|
||||||
"src/ui/views/panels/RenderFailure.vue",
|
"src/ui/views/panels/RenderFailure.vue",
|
||||||
|
|||||||
@@ -0,0 +1,136 @@
|
|||||||
|
import { after, before, test } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { installVueDom } from '../../testSupport/vueDom.mjs';
|
||||||
|
|
||||||
|
let mount;
|
||||||
|
let UiSearchField;
|
||||||
|
let uninstall;
|
||||||
|
before(async () => {
|
||||||
|
uninstall = installVueDom();
|
||||||
|
({ mount } = await import('@vue/test-utils'));
|
||||||
|
UiSearchField = (await import('./UiSearchField.vue')).default;
|
||||||
|
});
|
||||||
|
after(() => uninstall());
|
||||||
|
|
||||||
|
/** A field whose v-model writes back into its props, as a parent's would. */
|
||||||
|
function bound(props = {}, attrs = {}) {
|
||||||
|
const wrapper = mount(UiSearchField, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
label: 'Search layers',
|
||||||
|
modelValue: '',
|
||||||
|
...props,
|
||||||
|
'onUpdate:modelValue': (value) => wrapper.setProps({ modelValue: value }),
|
||||||
|
},
|
||||||
|
attrs,
|
||||||
|
});
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('a search field is the search glyph and a search input named by its label', () => {
|
||||||
|
const wrapper = bound({ placeholder: 'Search layers…' });
|
||||||
|
const root = wrapper.get('div');
|
||||||
|
assert.ok(root.classes().includes('ui-search-field'));
|
||||||
|
const icon = wrapper.get('span');
|
||||||
|
assert.equal(icon.text(), 'search');
|
||||||
|
assert.ok(icon.classes().includes('material-symbols-outlined'));
|
||||||
|
assert.equal(icon.attributes('aria-hidden'), 'true');
|
||||||
|
const input = wrapper.get('input');
|
||||||
|
assert.equal(input.attributes('type'), 'search');
|
||||||
|
assert.ok(input.classes().includes('ui-search-field__input'));
|
||||||
|
assert.equal(input.attributes('aria-label'), 'Search layers');
|
||||||
|
assert.equal(input.attributes('placeholder'), 'Search layers…');
|
||||||
|
for (const name of ['id', 'autocomplete', 'spellcheck'])
|
||||||
|
assert.equal(input.attributes(name), undefined, name);
|
||||||
|
assert.equal(wrapper.find('button').exists(), false);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('v-model shows the text and updates it as typed', async () => {
|
||||||
|
const wrapper = bound({ modelValue: 'radar' });
|
||||||
|
const input = wrapper.get('input');
|
||||||
|
assert.equal(input.element.value, 'radar');
|
||||||
|
await input.setValue('rain');
|
||||||
|
assert.deepEqual(wrapper.emitted('update:modelValue').at(-1), ['rain']);
|
||||||
|
assert.equal(wrapper.props('modelValue'), 'rain');
|
||||||
|
// A parent that empties its value, as closing a search does, empties the input.
|
||||||
|
await wrapper.setProps({ modelValue: '' });
|
||||||
|
assert.equal(input.element.value, '');
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the clear button shows only while text is typed, clears and refocuses', async () => {
|
||||||
|
const wrapper = bound({
|
||||||
|
clearLabel: 'Clear search',
|
||||||
|
clearClass: 'context-search__clear',
|
||||||
|
});
|
||||||
|
assert.equal(wrapper.find('button').exists(), false);
|
||||||
|
await wrapper.setProps({ modelValue: 'rain' });
|
||||||
|
const clear = wrapper.get('button');
|
||||||
|
assert.equal(clear.attributes('aria-label'), 'Clear search');
|
||||||
|
assert.equal(clear.attributes('title'), 'Clear search');
|
||||||
|
assert.ok(clear.classes().includes('context-search__clear'));
|
||||||
|
assert.ok(clear.classes().includes('ui-close-button'));
|
||||||
|
assert.equal(clear.get('span').text(), 'close');
|
||||||
|
await clear.trigger('click');
|
||||||
|
assert.deepEqual(wrapper.emitted('update:modelValue').at(-1), ['']);
|
||||||
|
assert.equal(document.activeElement, wrapper.get('input').element);
|
||||||
|
assert.equal(wrapper.find('button').exists(), false);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Escape is emitted with its event and stops at the input', async () => {
|
||||||
|
const wrapper = bound();
|
||||||
|
let bubbled = 0;
|
||||||
|
const onKey = () => bubbled++;
|
||||||
|
wrapper.element.addEventListener('keydown', onKey);
|
||||||
|
await wrapper.get('input').trigger('keydown', { key: 'Escape' });
|
||||||
|
const escapes = wrapper.emitted('escape');
|
||||||
|
assert.equal(escapes.length, 1);
|
||||||
|
assert.ok(escapes[0][0] instanceof Event);
|
||||||
|
assert.equal(escapes[0][0].defaultPrevented, false);
|
||||||
|
assert.equal(bubbled, 0);
|
||||||
|
await wrapper.get('input').trigger('keydown', { key: 'a' });
|
||||||
|
assert.equal(wrapper.emitted('escape').length, 1);
|
||||||
|
assert.equal(bubbled, 1);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('tag="label" frames the input in a label', () => {
|
||||||
|
const wrapper = bound({ tag: 'label' });
|
||||||
|
assert.equal(wrapper.element.tagName, 'LABEL');
|
||||||
|
assert.ok(wrapper.element.contains(wrapper.get('input').element));
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('attributes and classes pass through to the frame; the input takes its own', () => {
|
||||||
|
const wrapper = bound(
|
||||||
|
{
|
||||||
|
inputId: 'layer-finder-input',
|
||||||
|
inputClass: 'context-search__input',
|
||||||
|
autocomplete: 'off',
|
||||||
|
spellcheck: 'false',
|
||||||
|
},
|
||||||
|
{ class: 'context-search', role: 'search', 'data-x': '1' },
|
||||||
|
);
|
||||||
|
const root = wrapper.get('div');
|
||||||
|
assert.ok(root.classes().includes('context-search'));
|
||||||
|
assert.ok(root.classes().includes('ui-search-field'));
|
||||||
|
assert.equal(root.attributes('role'), 'search');
|
||||||
|
assert.equal(root.attributes('data-x'), '1');
|
||||||
|
const input = wrapper.get('input');
|
||||||
|
assert.equal(input.attributes('id'), 'layer-finder-input');
|
||||||
|
assert.ok(input.classes().includes('context-search__input'));
|
||||||
|
assert.ok(input.classes().includes('ui-search-field__input'));
|
||||||
|
assert.equal(input.attributes('autocomplete'), 'off');
|
||||||
|
assert.equal(input.attributes('spellcheck'), 'false');
|
||||||
|
assert.equal(input.attributes('role'), undefined);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('focus() focuses the input', () => {
|
||||||
|
const wrapper = bound();
|
||||||
|
wrapper.vm.focus();
|
||||||
|
assert.equal(document.activeElement, wrapper.get('input').element);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<script setup>
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import UiCloseButton from './UiCloseButton.vue';
|
||||||
|
|
||||||
|
// Core's search field: the Material `search` glyph, then an
|
||||||
|
// `<input type="search">` bound with v-model, and, when `clearLabel` is set,
|
||||||
|
// a UiCloseButton (the `close` symbol, its label as its tip) shown while
|
||||||
|
// text is typed, which empties the field and focuses the input again. `tag`
|
||||||
|
// is the frame: a `div` (give it role="search") or a `label`, which names
|
||||||
|
// the input by wrapping it. Attributes and classes pass through to the frame,
|
||||||
|
// so each site keeps its feature class; the input takes `inputId`,
|
||||||
|
// `inputClass`, `autocomplete` and `spellcheck`, and the clear button
|
||||||
|
// `clearClass`. Escape, pressed in the input, stops there and is emitted
|
||||||
|
// with its event, so a caller that also prevents the browser's own Escape
|
||||||
|
// does so. `focus()` focuses the input. The kit classes `ui-search-field`
|
||||||
|
// and `ui-search-field__input` (search-field.css) are the frame's flex row
|
||||||
|
// and the bare input; the browser's own cancel button is left as it is.
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: { type: String, default: '' },
|
||||||
|
/** The input's accessible name (aria-label). */
|
||||||
|
label: { type: String, required: true },
|
||||||
|
placeholder: { type: String, default: undefined },
|
||||||
|
tag: {
|
||||||
|
type: String,
|
||||||
|
default: 'div',
|
||||||
|
validator: (value) => ['div', 'label'].includes(value),
|
||||||
|
},
|
||||||
|
inputId: { type: String, default: undefined },
|
||||||
|
inputClass: { type: String, default: undefined },
|
||||||
|
autocomplete: { type: String, default: undefined },
|
||||||
|
spellcheck: { type: String, default: undefined },
|
||||||
|
/** The clear button's accessible name and tip; none without it. */
|
||||||
|
clearLabel: { type: String, default: undefined },
|
||||||
|
clearClass: { type: String, default: undefined },
|
||||||
|
});
|
||||||
|
const emit = defineEmits(['update:modelValue', 'escape']);
|
||||||
|
const input = ref(null);
|
||||||
|
// The input keeps Vue's native v-model, as both fields had.
|
||||||
|
const text = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (value) => emit('update:modelValue', value),
|
||||||
|
});
|
||||||
|
|
||||||
|
function focus() {
|
||||||
|
input.value?.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear() {
|
||||||
|
emit('update:modelValue', '');
|
||||||
|
focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ focus });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<component :is="props.tag" class="ui-search-field">
|
||||||
|
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||||
|
<input
|
||||||
|
:id="props.inputId"
|
||||||
|
ref="input"
|
||||||
|
v-model="text"
|
||||||
|
type="search"
|
||||||
|
class="ui-search-field__input"
|
||||||
|
:class="props.inputClass"
|
||||||
|
:placeholder="props.placeholder"
|
||||||
|
:aria-label="props.label"
|
||||||
|
:autocomplete="props.autocomplete"
|
||||||
|
:spellcheck="props.spellcheck"
|
||||||
|
@keydown.esc.stop="emit('escape', $event)"
|
||||||
|
/>
|
||||||
|
<UiCloseButton
|
||||||
|
v-if="props.clearLabel && props.modelValue"
|
||||||
|
:class="props.clearClass"
|
||||||
|
glyph="icon"
|
||||||
|
:label="props.clearLabel"
|
||||||
|
:title="props.clearLabel"
|
||||||
|
@click="clear"
|
||||||
|
/>
|
||||||
|
</component>
|
||||||
|
</template>
|
||||||
@@ -149,6 +149,45 @@ test('UiCloseButton wears the bare glyph look the guide’s close shares', () =>
|
|||||||
assert.match(rule.body, declaration);
|
assert.match(rule.body, declaration);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('UiSearchField owns the row and bare input both search skins drew', () => {
|
||||||
|
const frame = ruleWith('.ui-search-field');
|
||||||
|
assert.deepEqual(frame.selectors, ['.ui-search-field']);
|
||||||
|
assert.match(frame.body, /display:\s*flex;/);
|
||||||
|
assert.match(frame.body, /align-items:\s*center;/);
|
||||||
|
const input = ruleWith('.ui-search-field__input');
|
||||||
|
assert.deepEqual(input.selectors, ['.ui-search-field__input']);
|
||||||
|
for (const declaration of [
|
||||||
|
/min-width:\s*0;/,
|
||||||
|
/background:\s*none;/,
|
||||||
|
/border:\s*0;/,
|
||||||
|
])
|
||||||
|
assert.match(input.body, declaration);
|
||||||
|
// The browser's cancel button is each skin's own: Context hides it, the
|
||||||
|
// Layer Finder keeps it.
|
||||||
|
assert.ok(
|
||||||
|
!all.some((rule) =>
|
||||||
|
rule.selectors.some((s) =>
|
||||||
|
s.startsWith('.ui-search-field__input::-webkit-search-cancel-button'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// Each declaration lives once, in the kit's rule.
|
||||||
|
for (const [selector, kit] of [
|
||||||
|
['.context-search', frame],
|
||||||
|
['.layer-finder__field', frame],
|
||||||
|
['.context-search__input', input],
|
||||||
|
['.layer-finder__field input', input],
|
||||||
|
]) {
|
||||||
|
const feature = ruleWith(selector);
|
||||||
|
for (const property of kit.body.match(/[\w-]+(?=:)/g))
|
||||||
|
assert.doesNotMatch(
|
||||||
|
feature.body,
|
||||||
|
new RegExp(`(^|[\\s;])${property}:`),
|
||||||
|
`${selector} leaves ${property} to the kit`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('the kit’s skins load before the feature stylesheets that restyle them', () => {
|
test('the kit’s skins load before the feature stylesheets that restyle them', () => {
|
||||||
const at = (selector) => css.indexOf(selector);
|
const at = (selector) => css.indexOf(selector);
|
||||||
for (const [kit, feature] of [
|
for (const [kit, feature] of [
|
||||||
@@ -166,6 +205,10 @@ test('the kit’s skins load before the feature stylesheets that restyle them',
|
|||||||
['.ui-close-button,', '.context-search__clear {'],
|
['.ui-close-button,', '.context-search__clear {'],
|
||||||
['.ui-close-button,', '.key-setup-close {'],
|
['.ui-close-button,', '.key-setup-close {'],
|
||||||
['.ui-close-button,', '.gev-guide-close {'],
|
['.ui-close-button,', '.gev-guide-close {'],
|
||||||
|
['.ui-search-field {', '.context-search {'],
|
||||||
|
['.ui-search-field {', '.layer-finder__field {'],
|
||||||
|
['.ui-search-field__input {', '.context-search__input {'],
|
||||||
|
['.ui-search-field__input {', '.layer-finder__field input {'],
|
||||||
]) {
|
]) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
at(kit) >= 0 && at(feature) > at(kit),
|
at(kit) >= 0 && at(feature) > at(kit),
|
||||||
|
|||||||
@@ -97,14 +97,13 @@ body.mobile-shell .context-dock-btn {
|
|||||||
|
|
||||||
/* Context's own search field, under the header: narrows what the panel shows.
|
/* Context's own search field, under the header: narrows what the panel shows.
|
||||||
Sized and framed like the tab bar beneath it. */
|
Sized and framed like the tab bar beneath it. */
|
||||||
|
/* A UiSearchField (search-field.css). */
|
||||||
.context-search {
|
.context-search {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
display: flex;
|
|
||||||
flex: none;
|
flex: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
min-height: 34px;
|
min-height: 34px;
|
||||||
margin: 0 0 0.5rem;
|
margin: 0 0 0.5rem;
|
||||||
@@ -132,15 +131,12 @@ body.mobile-shell .context-dock-btn {
|
|||||||
|
|
||||||
.context-search__input {
|
.context-search__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
color: var(--text-primary, #e8eaed);
|
color: var(--text-primary, #e8eaed);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 0.74rem;
|
font-size: 0.74rem;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,9 @@
|
|||||||
margin: 0.2rem 0 0.5rem;
|
margin: 0.2rem 0 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A UiSearchField (search-field.css). */
|
||||||
.layer-finder__field {
|
.layer-finder__field {
|
||||||
display: flex;
|
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
align-items: center;
|
|
||||||
gap: 0.35rem;
|
gap: 0.35rem;
|
||||||
padding: 0 0.55rem;
|
padding: 0 0.55rem;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
@@ -103,11 +102,8 @@
|
|||||||
|
|
||||||
.layer-finder__field input {
|
.layer-finder__field input {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-width: 0;
|
|
||||||
color: rgba(236, 244, 248, 0.95);
|
color: rgba(236, 244, 248, 0.95);
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
background: none;
|
|
||||||
border: 0;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/* Core's search fields share their frame's row and their bare input: the
|
||||||
|
* kit's UiSearchField wears them as .ui-search-field and
|
||||||
|
* .ui-search-field__input. Each rule selects one class and loads before the
|
||||||
|
* feature stylesheets, so a feature rule still sets the frame's size,
|
||||||
|
* surface and focus ring and the input's type, colour, flex and outline. The
|
||||||
|
* browser's own cancel button is left to each skin. */
|
||||||
|
.ui-search-field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-search-field__input {
|
||||||
|
min-width: 0;
|
||||||
|
background: none;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ import ViewContext from './panels/ViewContext.vue';
|
|||||||
import SpaceMissionsPanel from './panels/SpaceMissionsPanel.vue';
|
import SpaceMissionsPanel from './panels/SpaceMissionsPanel.vue';
|
||||||
import RadioPanel from './panels/RadioPanel.vue';
|
import RadioPanel from './panels/RadioPanel.vue';
|
||||||
import UiButton from '../kit/UiButton.vue';
|
import UiButton from '../kit/UiButton.vue';
|
||||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
import UiSearchField from '../kit/UiSearchField.vue';
|
||||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||||
import { LAYER_TABS, TAB_AFFECTS, activeTab, availableTabs, contextReady, enabledLayerIds, setEnabledLayers, tabTarget } from '../contextLayerTabs.js';
|
import { LAYER_TABS, TAB_AFFECTS, activeTab, availableTabs, contextReady, enabledLayerIds, setEnabledLayers, tabTarget } from '../contextLayerTabs.js';
|
||||||
import { shownLayerName } from '../layerNames.js';
|
import { shownLayerName } from '../layerNames.js';
|
||||||
@@ -190,11 +190,7 @@ watch(
|
|||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
<div class="cyber-panel-body ui-scroll" data-rail-scroller>
|
<div class="cyber-panel-body ui-scroll" data-rail-scroller>
|
||||||
<div v-if="contextSearchOpen" class="context-search" role="search">
|
<UiSearchField v-if="contextSearchOpen" ref="searchInput" v-model="contextSearchText" class="context-search" role="search" input-class="context-search__input" :label="searchHint" :placeholder="searchHint" autocomplete="off" spellcheck="false" :clear-label="t('Clear search')" clear-class="context-search__clear" @escape="closeContextSearch" />
|
||||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
|
||||||
<input ref="searchInput" v-model="contextSearchText" type="search" class="context-search__input" :placeholder="searchHint" :aria-label="searchHint" autocomplete="off" spellcheck="false" @keydown.esc.stop="closeContextSearch" />
|
|
||||||
<UiCloseButton v-if="contextSearchText" class="context-search__clear" glyph="icon" :label="t('Clear search')" :title="t('Clear search')" @click="contextSearchText = ''; searchInput?.focus()" />
|
|
||||||
</div>
|
|
||||||
<div v-if="availableTabs.length" class="context-tabs" role="tablist" :aria-label="t('Context tabs')">
|
<div v-if="availableTabs.length" class="context-tabs" role="tablist" :aria-label="t('Context tabs')">
|
||||||
<button id="context-tab-btn-view" type="button" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'view' }" :aria-selected="String(activeTab === 'view')" aria-controls="context-tab-view" :tabindex="activeTab === 'view' ? 0 : -1" @click="activeTab = 'view'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
<button id="context-tab-btn-view" type="button" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'view' }" :aria-selected="String(activeTab === 'view')" aria-controls="context-tab-view" :tabindex="activeTab === 'view' ? 0 : -1" @click="activeTab = 'view'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||||
<span class="material-symbols-outlined" aria-hidden="true">visibility</span><span class="context-tabs__label">{{ t('Inspector') }}</span>
|
<span class="material-symbols-outlined" aria-hidden="true">visibility</span><span class="context-tabs__label">{{ t('Inspector') }}</span>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const finder = {
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
|
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
|
||||||
import { msg, t } from '../../../i18n/index.js';
|
import { msg, t } from '../../../i18n/index.js';
|
||||||
|
import UiSearchField from '../../kit/UiSearchField.vue';
|
||||||
|
|
||||||
// Search and filter for the Data Layers list. The rows are rendered elsewhere
|
// Search and filter for the Data Layers list. The rows are rendered elsewhere
|
||||||
// (LayerRows), so this works on the list as it stands: it marks rows that
|
// (LayerRows), so this works on the list as it stands: it marks rows that
|
||||||
@@ -246,10 +247,7 @@ if (props.part === 'buttons') {
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<div v-else-if="searching || narrowed" class="layer-finder__bar">
|
<div v-else-if="searching || narrowed" class="layer-finder__bar">
|
||||||
<label v-if="searching" class="layer-finder__field">
|
<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(); }" />
|
||||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
|
||||||
<input id="layer-finder-input" v-model="query" type="search" :placeholder="t('Search layers…')" :aria-label="t('Search layers')" @keydown.esc.stop.prevent="closeSearch" />
|
|
||||||
</label>
|
|
||||||
<button v-if="show !== 'all'" type="button" class="layer-finder__chip" @click="show = 'all'">
|
<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>
|
{{ show === 'on' ? t('On') : t('Off') }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
@import './src/ui/styles/foundation.css';
|
@import './src/ui/styles/foundation.css';
|
||||||
@import './src/ui/styles/action-button.css';
|
@import './src/ui/styles/action-button.css';
|
||||||
@import './src/ui/styles/close-button.css';
|
@import './src/ui/styles/close-button.css';
|
||||||
|
@import './src/ui/styles/search-field.css';
|
||||||
@import './src/ui/styles/form-field.css';
|
@import './src/ui/styles/form-field.css';
|
||||||
@import './src/ui/styles/status-badge.css';
|
@import './src/ui/styles/status-badge.css';
|
||||||
@import './src/ui/styles/chip.css';
|
@import './src/ui/styles/chip.css';
|
||||||
|
|||||||
Reference in new issue
Block a user