Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/web-accent-means-selection.md
Original file line number Diff line number Diff line change
@@ -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.
34 changes: 18 additions & 16 deletions packages/hunk/src/web/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -226,7 +230,7 @@ body {
}

.toggle-button[aria-pressed="true"]::before {
color: var(--hunk-accent);
color: var(--hunk-text);
content: "●" / "";
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -671,7 +673,7 @@ body {
}

.note-author {
color: var(--hunk-accent);
color: var(--hunk-text);
font-weight: 600;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1641,7 +1643,7 @@ body {
}

.notes-author {
color: var(--hunk-accent);
color: var(--hunk-text);
font-weight: 600;
}

Expand Down Expand Up @@ -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;
}

Expand Down
32 changes: 32 additions & 0 deletions test/web/review-shell.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading