diff --git a/changes/fix-page-links-s2-tabs.md b/changes/fix-page-links-s2-tabs.md deleted file mode 100644 index 048ce884..00000000 --- a/changes/fix-page-links-s2-tabs.md +++ /dev/null @@ -1,3 +0,0 @@ -Fixed - -- A hub's page links on a narrow screen are drawn as S2's Tabs: plain labels 24px apart, hover changing only the text colour, and the current page marked by a rounded 2px line as wide as its label. The labels can no longer be selected by dragging or clicking. diff --git a/e2e/mobile-layout.spec.ts b/e2e/mobile-layout.spec.ts index 37761561..ca0236f1 100644 --- a/e2e/mobile-layout.spec.ts +++ b/e2e/mobile-layout.spec.ts @@ -47,19 +47,12 @@ for (const width of [1280, 1024, 390, 320]) { } if (width <= 390) { - const undersized = await page.locator('.rp-top .rp-btn.icon, .rp-hubbar > a, .rp-hubnav .rp-page-link, .rp-content .rp-tab').evaluateAll(elements => + const undersized = await page.locator('.rp-top .rp-btn.icon, .rp-hubbar > a, .rp-hubnav .rp-btn, .rp-content .rp-tab').evaluateAll(elements => elements .filter(element => element.getClientRects().length) .map(element => { const box = element.getBoundingClientRect(); - // A page link's invisible ::before extends its hit area on a touch screen. - const area = getComputedStyle(element, '::before'); - const out = (side: 'top' | 'right' | 'bottom' | 'left') => (area.content === 'none' ? 0 : Math.max(0, -parseFloat(area[side]) || 0)); - return { - label: element.getAttribute('aria-label') ?? element.textContent, - width: box.width + out('left') + out('right'), - height: box.height + out('top') + out('bottom') - }; + return {label: element.getAttribute('aria-label') ?? element.textContent, width: box.width, height: box.height}; }) .filter(box => box.width < 36 || box.height < 36) ); diff --git a/e2e/mobile.spec.ts b/e2e/mobile.spec.ts index de655ba4..22b2079d 100644 --- a/e2e/mobile.spec.ts +++ b/e2e/mobile.spec.ts @@ -434,7 +434,7 @@ test.describe('360px', () => { for (const hub of hubs) { for (const route of hub.pages) { await page.goto(`/#/${route}`); - await expect(page.locator('.rp-hubnav .rp-page-link')).toHaveCount(hub.pages.length); + await expect(page.locator('.rp-hubnav .rp-btn')).toHaveCount(hub.pages.length); const strip = () => page.locator('.rp-hubnav').evaluate(nav => { const box = nav.getBoundingClientRect(); diff --git a/e2e/toolbar-height.spec.ts b/e2e/toolbar-height.spec.ts index 43c5f960..4eeca094 100644 --- a/e2e/toolbar-height.spec.ts +++ b/e2e/toolbar-height.spec.ts @@ -81,7 +81,7 @@ test.describe('page rows on a phone', () => { await page.evaluate(() => document.fonts.ready); await settleFrames(page); for (const scope of ['.rp-content .rp-page-links', '.rp-content [data-page-tabrow] .rp-tablist']) - expect(await lineCount(page, scope, '.rp-btn, .rp-page-link, [role=tab]'), `${route} ${scope}`).toBeLessThanOrEqual(1); + expect(await lineCount(page, scope, '.rp-btn, [role=tab]'), `${route} ${scope}`).toBeLessThanOrEqual(1); } await page.goto('/#/connections'); await page.locator('.rp-content [role=tab]:visible').nth(1).click(); @@ -136,7 +136,7 @@ async function toolbarGeometry(page: Page) { const sizes = getComputedStyle(document.documentElement); const mHeight = parseFloat(sizes.getPropertyValue('--rp-control')); const lHeight = parseFloat(sizes.getPropertyValue('--rp-control-lg')); - const controls = '.rp-btn, .rp-page-link, .rp-input, .rp-selectbtn, .rp-select, .rp-seg, .rp-switch, .rp-tab, .rp-tabbar'; + const controls = '.rp-btn, .rp-input, .rp-selectbtn, .rp-select, .rp-seg, .rp-switch, .rp-tab, .rp-tabbar'; return [...root.querySelectorAll(`${rows}, ${localRows}`)] .filter(row => row.checkVisibility({visibilityProperty: true})) .flatMap(row => { diff --git a/src/ui/PageLinks.tsx b/src/ui/PageLinks.tsx index b72965c8..941470f5 100644 --- a/src/ui/PageLinks.tsx +++ b/src/ui/PageLinks.tsx @@ -1,14 +1,13 @@ import {Link} from './Link'; -// A hub's sibling pages, drawn as S2's Tabs at compact density: plain labels over a divider with the current page -// underlined, so the row reads as navigation between pages rather than as the page's own tabs, which are a segmented -// control. +// A hub's sibling pages, drawn as S2's Tabs: quiet labels over a divider with the current page underlined, so the row +// reads as navigation between pages rather than as the page's own tabs, which are a segmented control. export function PageLinks({label, items}: {label: string; items: {id: string; href: string; label: string; current?: boolean}[]}) { return ( diff --git a/src/ui/styles/motion.css b/src/ui/styles/motion.css index 16159946..4e903a37 100644 --- a/src/ui/styles/motion.css +++ b/src/ui/styles/motion.css @@ -13,7 +13,6 @@ .rp-input .clear, .rp-input .reveal, .rp-link, -.rp-page-link, .rp-tag-link, .rp-tag-more, .rp-disclosure-trigger, diff --git a/src/ui/styles/shell-search.css b/src/ui/styles/shell-search.css index 4258b7d6..f9b027de 100644 --- a/src/ui/styles/shell-search.css +++ b/src/ui/styles/shell-search.css @@ -491,11 +491,6 @@ padding: 0 var(--rp-space-2) env(safe-area-inset-bottom); background: var(--rp-base); } -/* The page links reach half a gap past their labels; the strip holds that reach, the row and its divider do not. */ -.rp-hubnav { - margin-inline: calc(var(--rp-space-6) / -2); - padding-inline: calc(var(--rp-space-6) / 2); -} @media (min-width: 1024px) { .rp-hubnav, .rp-hubbar { diff --git a/src/ui/styles/tabs-panels.css b/src/ui/styles/tabs-panels.css index 2f1a3bc0..3d5928be 100644 --- a/src/ui/styles/tabs-panels.css +++ b/src/ui/styles/tabs-panels.css @@ -151,66 +151,15 @@ } } -/* S2's Tabs at compact density: the label is the tab, M tall and 24px from the next; hover and press only darken the - text. The current tab's 2px indicator spans its label and sits on the row's divider. The link reaches half of each - gap, and on a touch screen a 44px height as an icon button does, so the label alone draws the focus ring. */ .rp-page-links { display: flex; flex-wrap: wrap; - column-gap: var(--rp-space-6); + gap: var(--rp-space-1); border-block-end: 1px solid var(--rp-line); } -.rp-page-link { - position: relative; - display: flex; - block-size: var(--rp-control); - padding-inline: calc(var(--rp-space-6) / 2); - margin-inline: calc(var(--rp-space-6) / -2); - color: var(--rp-subtle); - text-decoration: none; - white-space: nowrap; - user-select: none; - -webkit-tap-highlight-color: transparent; -} -.rp-page-link > span { - position: relative; - display: flex; - align-items: center; - border-radius: var(--rp-r-sm); -} -.rp-page-link:is([data-hovered], [data-pressed], [aria-current='page']) { - color: var(--rp-text); -} -.rp-page-link:is(:focus-visible, [data-focus-visible]) { - outline: none; -} -.rp-page-link:is(:focus-visible, [data-focus-visible]) > span { - outline: var(--rp-focus-width) solid var(--rp-focus-color); - outline-offset: var(--rp-focus-offset); -} -.rp-page-link[aria-current='page'] > span::after { - content: ''; - position: absolute; - inset: auto 0 0; - block-size: 2px; - border-radius: var(--rp-r-pill); - background: var(--rp-text); -} -@media (pointer: coarse) { - .rp-page-link::before { - content: ''; - position: absolute; - inset: min(0px, 50% - 22px) 0; - } -} -@media (forced-colors: active) { - .rp-page-link[aria-current='page'] { - color: Highlight; - } - .rp-page-link[aria-current='page'] > span::after { - forced-color-adjust: none; - background: Highlight; - } +.rp-page-links [aria-current='page'] { + border-radius: 0; + box-shadow: inset 0 -2px var(--rp-text); } .rp-disclosure[data-variant='nav'] { margin: 0;