diff --git a/.changeset/web-accent-means-selection.md b/.changeset/web-accent-means-selection.md new file mode 100644 index 000000000..b615e84b1 --- /dev/null +++ b/.changeset/web-accent-means-selection.md @@ -0,0 +1,5 @@ +--- +"hunkdiff": patch +--- + +The browser review page now reserves its accent color for your position and focus, so pressed toggles, checked segments, resting note cards, and the minimap viewport use a neutral "on" style instead. diff --git a/packages/hunk/src/web/styles.css b/packages/hunk/src/web/styles.css index d2da1b3ea..dc52b882d 100644 --- a/packages/hunk/src/web/styles.css +++ b/packages/hunk/src/web/styles.css @@ -211,10 +211,14 @@ body { text-align: center; } -/* A pressed toggle reads like a checked segment: tinted, with the accent border. */ +/* A pressed toggle is a neutral "on" state, not a selection: the accent stays reserved for + position and focus. The filled panel, the full-strength label, and the dot glyph (on text + toggles) tell on from off without relying on color alone. */ .tool-button[aria-pressed="true"] { - background: var(--hunk-accent-muted); - border-color: var(--hunk-accent); + background: var(--hunk-panel-alt); + border-color: var(--hunk-border); + color: var(--hunk-text); + box-shadow: inset 0 -2px 0 var(--hunk-muted); } .toggle-button[aria-pressed]::before { @@ -226,7 +230,7 @@ body { } .toggle-button[aria-pressed="true"]::before { - color: var(--hunk-accent); + color: var(--hunk-text); content: "●" / ""; } @@ -328,8 +332,10 @@ body { } .segmented button[aria-checked="true"] { - background: var(--hunk-accent-muted); - border-color: var(--hunk-accent); + background: var(--hunk-panel-alt); + border-color: var(--hunk-border); + color: var(--hunk-text); + box-shadow: inset 0 -2px 0 var(--hunk-muted); position: relative; } @@ -648,15 +654,11 @@ body { max-width: 920px; padding: 6px 10px 8px; background: var(--hunk-panel); - border: 1px solid var(--hunk-note-border, var(--hunk-accent)); + border: 1px solid var(--hunk-border); border-left-width: 3px; border-radius: 6px; } -.note-card[data-source="user"] { - border-color: var(--hunk-accent); -} - .note-card[data-stale] { border-style: dashed; opacity: 0.8; @@ -671,7 +673,7 @@ body { } .note-author { - color: var(--hunk-accent); + color: var(--hunk-text); font-weight: 600; } @@ -1219,7 +1221,7 @@ body { .side-panel-tabs [role="tab"][aria-selected="true"] { color: var(--hunk-text); - border-bottom-color: var(--hunk-accent); + border-bottom-color: var(--hunk-text); } .side-panel-close { @@ -1641,7 +1643,7 @@ body { } .notes-author { - color: var(--hunk-accent); + color: var(--hunk-text); font-weight: 600; } @@ -1707,8 +1709,8 @@ body { left: 0; right: 0; box-sizing: border-box; - background: color-mix(in srgb, var(--hunk-accent) 14%, transparent); - border: 1px solid color-mix(in srgb, var(--hunk-accent) 70%, transparent); + background: color-mix(in srgb, var(--hunk-muted) 14%, transparent); + border: 1px solid color-mix(in srgb, var(--hunk-muted) 60%, transparent); pointer-events: none; } diff --git a/test/web/review-shell.e2e.ts b/test/web/review-shell.e2e.ts index 0ad446c0f..12ca1aee2 100644 --- a/test/web/review-shell.e2e.ts +++ b/test/web/review-shell.e2e.ts @@ -88,6 +88,38 @@ async function selectedHunk(page: Page) { .getAttribute("data-hunk-index")}`; } +// Intent: the accent marks position and focus; an "on" toggle or a checked segment is neutral. +test("pressed toggles and checked segments stay off the accent color", async ({ page }) => { + await openTestReview(page, "--rich"); + + const colors = await page.evaluate(() => { + const resolve = (value: string) => { + const probe = document.createElement("i"); + probe.style.backgroundColor = value; + document.body.append(probe); + const resolved = getComputedStyle(probe).backgroundColor; + probe.remove(); + return resolved; + }; + const paint = (element: Element | null) => { + const style = getComputedStyle(element!); + return { background: style.backgroundColor, border: style.borderTopColor }; + }; + + return { + accent: resolve("var(--hunk-accent)"), + accentMuted: resolve("var(--hunk-accent-muted)"), + toggle: paint(document.querySelector('[data-testid="toggle-line-numbers"]')), + segment: paint(document.querySelector('.segmented button[aria-checked="true"]')), + }; + }); + + for (const painted of [colors.toggle, colors.segment]) { + expect([painted.background, painted.border]).not.toContain(colors.accent); + expect([painted.background, painted.border]).not.toContain(colors.accentMuted); + } +}); + // Intent: Space is a checkbox's only native key; the page must not turn it into a page-down. test("Space on a focused Viewed checkbox toggles it instead of paging", async ({ page }) => { await openTestReview(page, "--rich");