From 1711b4b4566a62ccad8a55ccdd2b03413255ed8b Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Thu, 19 Nov 2026 00:14:58 -0800 Subject: [PATCH 1/2] Vue kit: UiCloseButton for every close button in the views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UiCloseButton is a UiButton with a fixed glyph (× or the Material close symbol through UiIcon), a required accessible label and no tip unless the site passes a title. Attributes and classes pass through, so each site keeps its id, feature class, data and aria attributes, and its look. Its kit class, ui-close-button (close-button.css, loaded before the feature stylesheets), is Core's common look: a bare glyph with no padding, border or background of its own, and a pointer. The guide's close button shares the rule, and the copies of those declarations leave the feature rules. `bare` leaves the look off for Street Level's and the space mission's close buttons, whose skins keep the browser's padding. UiIcon takes size null to leave the glyph's size to the stylesheet. The sixteen hand-written close, dismiss and clear buttons in the SFCs are now UiCloseButtons; closeButtons.test.mjs pins that none remain. Co-authored-by: Manjunath Paparaju --- docs/VUE-MIGRATION.md | 8 ++ scripts/format-scope.json | 4 + scripts/package-boundaries.json | 5 + src/ui/kit/UiCloseButton.test.mjs | 98 +++++++++++++++++++ src/ui/kit/UiCloseButton.vue | 40 ++++++++ src/ui/kit/UiIcon.vue | 7 +- src/ui/kit/closeButtons.test.mjs | 76 ++++++++++++++ src/ui/kit/kitStyles.test.mjs | 20 ++++ src/ui/rail/RailCardBlocks.vue | 10 +- src/ui/recentImagery/RecentImageryReadout.vue | 14 +-- src/ui/styles/bhote-koshi.css | 3 +- src/ui/styles/close-button.css | 13 +++ src/ui/styles/context-dock.css | 5 +- src/ui/styles/entity-card.css | 13 +-- src/ui/styles/guide.css | 5 +- src/ui/styles/provider-settings.css | 3 +- src/ui/styles/voice-card.css | 3 +- src/ui/views/ContextView.vue | 5 +- src/ui/views/ProviderSettingsView.vue | 5 +- src/ui/views/panels/BhoteKoshiPanel.vue | 3 +- src/ui/views/panels/CctvPreview.vue | 5 +- src/ui/views/panels/ChatPanel.vue | 3 +- src/ui/views/panels/DataLibraryDialog.vue | 7 +- src/ui/views/panels/DrawMarkList.vue | 3 +- src/ui/views/panels/EntityCard.vue | 5 +- src/ui/views/panels/MissionDetail.vue | 3 +- src/ui/views/panels/StreetLevelPanel.vue | 3 +- src/ui/views/panels/ViewContext.vue | 5 +- src/ui/views/panels/VoiceCard.vue | 3 +- src/ui/views/panels/VoiceControl.vue | 3 +- src/ui/views/panels/WildlifeSightingCard.vue | 5 +- style.css | 1 + 32 files changed, 317 insertions(+), 69 deletions(-) create mode 100644 src/ui/kit/UiCloseButton.test.mjs create mode 100644 src/ui/kit/UiCloseButton.vue create mode 100644 src/ui/kit/closeButtons.test.mjs create mode 100644 src/ui/styles/close-button.css diff --git a/docs/VUE-MIGRATION.md b/docs/VUE-MIGRATION.md index 3a8be5b0cb..c6969f4277 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 keeps the browser's padding | `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 +keep the browser's padding. 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..56f9bbaa37 --- /dev/null +++ b/src/ui/kit/UiCloseButton.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/ui/kit/UiIcon.vue b/src/ui/kit/UiIcon.vue index 4f34f29e4b..01bfedd230 100644 --- a/src/ui/kit/UiIcon.vue +++ b/src/ui/kit/UiIcon.vue @@ -1,5 +1,8 @@ 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(

{{ shownTitle }}

{{ subtitle }} - +
diff --git a/src/ui/views/panels/MissionDetail.vue b/src/ui/views/panels/MissionDetail.vue index d88bc2e5ae..cd310841ce 100644 --- a/src/ui/views/panels/MissionDetail.vue +++ b/src/ui/views/panels/MissionDetail.vue @@ -5,6 +5,7 @@ import { t } from '../../../i18n/index.js'; import UiSlider from '../../kit/UiSlider.js'; import { useSpaceMissionsStore } from '../../stores/spaceMissions.js'; import UiButton from '../../kit/UiButton.vue'; +import UiCloseButton from '../../kit/UiCloseButton.vue'; // The selected space mission. The launches layer presents it // and hides the panel while none is selected; the roster beside it hides @@ -27,7 +28,7 @@ watch(