diff --git a/changelog.d/1840-kit-close-button.md b/changelog.d/1840-kit-close-button.md
new file mode 100644
index 0000000000..0376fb405c
--- /dev/null
+++ b/changelog.d/1840-kit-close-button.md
@@ -0,0 +1,3 @@
+- Every close, dismiss and clear button in the views is now one kit
+ component, `UiCloseButton`, with the same look and behaviour as before
+ (manjunath22466, samehkhamis, #1840).
diff --git a/docs/VUE-MIGRATION.md b/docs/VUE-MIGRATION.md
index 3a8be5b0cb..24b2e2c63a 100644
--- a/docs/VUE-MIGRATION.md
+++ b/docs/VUE-MIGRATION.md
@@ -53,6 +53,7 @@ never copied:
| `UiButton` `variant="action"` | the action surface (`gev-action-button`); `tone="danger"` hovers red, `size="compact"` is the shot-row footprint (on this variant only) | `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` |
+| `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 sets its own padding and border | `src/ui/styles/close-button.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` |
| `UiBadge` | the read-only badge (`gev-status-badge`) | `src/ui/styles/status-badge.css` |
@@ -99,6 +100,13 @@ a `title` and `hint`, but Core's empty states are one line, so the title
is the text itself rather than a bold heading; the News feed, Scene shot
list, mission roster and imagery strip use it. The locale picker's and the mission tables'
empty rows stay a paragraph and table cells.
+`UiCloseButton` is a `UiButton` with a fixed glyph, a required `label` and
+no tip unless the site passes a `title`; attributes and classes pass through,
+so each site keeps its id, feature class and look. Every close, dismiss and
+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
+set their own padding and border. The close buttons built in script (credits, the
+Quebec CCTV overlay, the guide) are not converted yet.
`UiSlider` keeps the native range input rather than drawing a
`role="slider"` track, so Core's keyboard, form behaviour and styling stay;
it takes `v-model`, `min`, `max`, `step` and `disabled`, emits a
diff --git a/scripts/format-scope.json b/scripts/format-scope.json
index 1c5a01c0cc..89cb505b82 100644
--- a/scripts/format-scope.json
+++ b/scripts/format-scope.json
@@ -1329,6 +1329,10 @@
"src/ui/kit/UiBadge.test.mjs",
"src/ui/kit/UiEmpty.vue",
"src/ui/kit/kitStyles.test.mjs",
+ "src/ui/kit/UiCloseButton.vue",
+ "src/ui/kit/UiCloseButton.test.mjs",
+ "src/ui/kit/closeButtons.test.mjs",
+ "src/ui/styles/close-button.css",
"src/ui/styles/chip.css",
"src/ui/styles/empty-state.css",
"src/ui/rail/RailChips.vue",
diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json
index dbbfdf35bd..be5b54b3d9 100644
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@ -241,6 +241,7 @@
"src/ui/kit/UiSelect.js",
"src/ui/kit/UiEmpty.vue",
"src/ui/kit/UiBadge.vue",
+ "src/ui/kit/UiCloseButton.vue",
"src/ui/stores/globeActions.js",
"src/ui/views/panels/GlobeActions.vue",
"src/ui/views/panels/RenderFailure.vue",
@@ -1014,6 +1015,8 @@
"src/ui/kit/UiSelect.js",
"src/ui/kit/UiButton.vue",
"src/ui/kit/UiBadge.vue",
+ "src/ui/kit/UiCloseButton.vue",
+ "src/ui/kit/UiIcon.vue",
"src/ui/rail/fieldValue.js",
"src/ui/kit/UiSlider.js",
"src/ui/kit/UiSegmented.vue"
@@ -1602,6 +1605,7 @@
"src/ui/kit/UiSlider.js",
"src/ui/kit/UiButton.vue",
"src/ui/kit/UiBadge.vue",
+ "src/ui/kit/UiCloseButton.vue",
"src/ui/stores/globeActions.js",
"src/ui/stores/recording.js",
"src/ui/i18n.js",
@@ -5370,6 +5374,7 @@
"src/ui/kit/UiButton.vue",
"src/ui/kit/UiEmpty.vue",
"src/ui/kit/UiBadge.vue",
+ "src/ui/kit/UiCloseButton.vue",
"src/ui/stores/globeActions.js",
"src/ui/stores/recording.js",
"src/ui/i18n.js",
diff --git a/src/ui/kit/UiCloseButton.test.mjs b/src/ui/kit/UiCloseButton.test.mjs
new file mode 100644
index 0000000000..d2e11796e0
--- /dev/null
+++ b/src/ui/kit/UiCloseButton.test.mjs
@@ -0,0 +1,98 @@
+import { after, before, test } from 'node:test';
+import assert from 'node:assert/strict';
+import { installVueDom } from '../../testSupport/vueDom.mjs';
+
+let mount;
+let UiCloseButton;
+let uninstall;
+before(async () => {
+ uninstall = installVueDom();
+ ({ mount } = await import('@vue/test-utils'));
+ UiCloseButton = (await import('./UiCloseButton.vue')).default;
+});
+after(() => uninstall());
+
+function mountClose(props = {}, attrs = {}) {
+ return mount(UiCloseButton, {
+ attachTo: document.body,
+ props: { label: 'Close card', ...props },
+ attrs,
+ });
+}
+
+test('a close button is a button named by its label, with no tip of its own', () => {
+ const wrapper = mountClose();
+ const button = wrapper.get('button');
+ assert.equal(button.attributes('type'), 'button');
+ assert.equal(button.attributes('aria-label'), 'Close card');
+ assert.equal(button.attributes('title'), undefined);
+ assert.ok(button.classes().includes('ui-close-button'));
+ wrapper.unmount();
+});
+
+test('glyph="times" draws the × character', () => {
+ const wrapper = mountClose();
+ const button = wrapper.get('button');
+ assert.equal(button.element.innerHTML, '×');
+ wrapper.unmount();
+});
+
+test('glyph="icon" draws the Material close symbol, sized by the stylesheet', () => {
+ const wrapper = mountClose({ glyph: 'icon' });
+ const icon = wrapper.get('button > span');
+ assert.equal(wrapper.get('button').element.children.length, 1);
+ assert.equal(icon.text(), 'close');
+ assert.ok(icon.classes().includes('material-symbols-outlined'));
+ assert.equal(icon.attributes('aria-hidden'), 'true');
+ assert.equal(icon.attributes('style'), undefined);
+ wrapper.unmount();
+});
+
+test('attributes and classes pass through to the button', () => {
+ const wrapper = mountClose(
+ {},
+ {
+ id: 'gev-chat-close',
+ class: 'data-toggle-chip',
+ title: 'Clear reading',
+ 'data-action-id': 'clear',
+ 'aria-hidden': 'true',
+ disabled: true,
+ hidden: true,
+ },
+ );
+ const button = wrapper.get('button');
+ assert.equal(button.attributes('id'), 'gev-chat-close');
+ assert.ok(button.classes().includes('data-toggle-chip'));
+ assert.ok(button.classes().includes('ui-close-button'));
+ assert.equal(button.attributes('title'), 'Clear reading');
+ assert.equal(button.attributes('data-action-id'), 'clear');
+ assert.equal(button.attributes('aria-hidden'), 'true');
+ assert.equal(button.element.disabled, true);
+ assert.equal(button.element.hidden, true);
+ wrapper.unmount();
+});
+
+test('bare leaves the kit look off', () => {
+ const wrapper = mountClose({ bare: true }, { class: 'sl-viewer-x' });
+ const classes = wrapper.get('button').classes();
+ assert.ok(classes.includes('sl-viewer-x'));
+ assert.equal(classes.includes('ui-close-button'), false);
+ wrapper.unmount();
+});
+
+test('a click is emitted with its event', async () => {
+ const wrapper = mountClose();
+ await wrapper.get('button').trigger('click');
+ const clicks = wrapper.emitted('click');
+ assert.equal(clicks.length, 1);
+ assert.ok(clicks[0][0] instanceof Event);
+ wrapper.unmount();
+});
+
+test('a disabled close button emits no click', async () => {
+ const wrapper = mountClose({}, { disabled: true });
+ await wrapper.get('button').trigger('click');
+ assert.equal(wrapper.emitted('click'), undefined);
+ wrapper.unmount();
+});
diff --git a/src/ui/kit/UiCloseButton.vue b/src/ui/kit/UiCloseButton.vue
new file mode 100644
index 0000000000..febe762d68
--- /dev/null
+++ b/src/ui/kit/UiCloseButton.vue
@@ -0,0 +1,40 @@
+
+
+
+
+
diff --git a/src/ui/views/panels/EntityCard.vue b/src/ui/views/panels/EntityCard.vue
index 3ca7087c2f..77ae67c486 100644
--- a/src/ui/views/panels/EntityCard.vue
+++ b/src/ui/views/panels/EntityCard.vue
@@ -10,6 +10,7 @@ import AltitudeGraph from './AltitudeGraph.vue';
import { contextNeedle, contextSearchText, matchesContextSearch } from '../../contextSearch.js';
import RouteGlobe from './RouteGlobe.vue';
import CctvPreview from './CctvPreview.vue';
+import UiCloseButton from '../../kit/UiCloseButton.vue';
import { useCctvStore } from '../../stores/cctv.js';
import SpotConditions from './SpotConditions.vue';
import { shownLayerName } from '../../layerNames.js';
@@ -396,9 +397,7 @@ watch(
{{ layer.breakdown.basis }}
diff --git a/src/ui/views/panels/VoiceCard.vue b/src/ui/views/panels/VoiceCard.vue index 3b5e9537d9..b533bd067e 100644 --- a/src/ui/views/panels/VoiceCard.vue +++ b/src/ui/views/panels/VoiceCard.vue @@ -2,6 +2,7 @@ import { t } from '../../../i18n/index.js'; import { ASSISTANT_NAME } from '../../../voice/control.js'; import UiChip from '../../kit/UiChip.vue'; +import UiCloseButton from '../../kit/UiCloseButton.vue'; // Captions, plan and result, as VoiceCardControls (src/voice/voiceCard.js) // presents them. Captions update silently; the polite live region carries @@ -15,7 +16,7 @@ const emit = defineEmits(['dismiss']);{{ card.user.label }}{{ card.user.text }}
{{ card.pointer.kind }}: {{ card.pointer.text }}
diff --git a/src/ui/views/panels/VoiceControl.vue b/src/ui/views/panels/VoiceControl.vue index 172077425c..9b92eaa2e3 100644 --- a/src/ui/views/panels/VoiceControl.vue +++ b/src/ui/views/panels/VoiceControl.vue @@ -9,6 +9,7 @@ import VoiceVisualizer from './VoiceVisualizer.vue'; import ChatPanel from './ChatPanel.vue'; import PanelLayoutButtons from './PanelLayoutButtons.vue'; import UiButton from '../../kit/UiButton.vue'; +import UiCloseButton from '../../kit/UiCloseButton.vue'; import UiSelect from '../../kit/UiSelect.js'; // The voice control in the command dock, as its presenter @@ -107,7 +108,7 @@ const frameStyle = (panel) => ({{{ t('YOU') }}{{ view.mini.user }}
diff --git a/src/ui/views/panels/WildlifeSightingCard.vue b/src/ui/views/panels/WildlifeSightingCard.vue index 9caac8fdda..15f6086f97 100644 --- a/src/ui/views/panels/WildlifeSightingCard.vue +++ b/src/ui/views/panels/WildlifeSightingCard.vue @@ -3,6 +3,7 @@ import { computed, shallowRef, useTemplateRef, watch } from 'vue'; import { formatDate, t, translateKnown } from '../../../i18n/index.js'; import { photoCreator, formatAge } from '../../../layers/wildlifeSightings/photoText.js'; import { ACARTIA_SITE, inatLicenceLabel, inatPhotoUrl, isOpenPhoto } from '../../../layers/wildlifeSightings/records.js'; +import UiCloseButton from '../../kit/UiCloseButton.vue'; const props = defineProps({ sighting: { type: Object, required: true }, @@ -71,7 +72,7 @@ watch([() => props.sighting.stableId, () => photo.value?.src], () => { loaded.va{{ t('Loading photo...') }}
@@ -115,7 +116,7 @@ watch([() => props.sighting.stableId, () => photo.value?.src], () => { loaded.va .wildlife-sighting-card-content:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; } /* Script focus starts inside the card; tab focus still outlines its controls. */ .wildlife-sighting-card:focus-visible { outline: none !important; } -.wildlife-sighting-card-close { position: absolute; z-index: 1; inset-block-start: 4px; inset-inline-end: 4px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--btn-radius); background: transparent; color: inherit; font: 20px/1 var(--font-sans); cursor: pointer; } +.wildlife-sighting-card-close { position: absolute; z-index: 1; inset-block-start: 4px; inset-inline-end: 4px; width: 24px; height: 24px; border-radius: var(--btn-radius); color: inherit; font: 20px/1 var(--font-sans); } .wildlife-sighting-card-close:hover { background: var(--menu-bg); } .wildlife-sighting-card-close:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; } .wildlife-sighting-card-photo { position: relative; width: 100%; height: 180px; } diff --git a/style.css b/style.css index ff35bbe61f..987c188ee0 100644 --- a/style.css +++ b/style.css @@ -1,6 +1,7 @@ /* Preserve component and responsive rule order in one stylesheet entry. */ @import './src/ui/styles/foundation.css'; @import './src/ui/styles/action-button.css'; +@import './src/ui/styles/close-button.css'; @import './src/ui/styles/form-field.css'; @import './src/ui/styles/status-badge.css'; @import './src/ui/styles/chip.css';