Skip to content

Commit 3a2b7af

Browse files
DOT Graph lines now easier to see in dark mode
1 parent 902567a commit 3a2b7af

4 files changed

Lines changed: 96 additions & 1 deletion

File tree

‎AGENTS.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ coverage there when introducing new markup patterns.
154154
identical dark blocks) in `app/globals.css`; mvp.css light overrides must
155155
stay on `html:root` (mvp loads after the bundle). Report-template
156156
widgets that hardcode light colors are re-driven from `main#app …`
157-
rules there (the mustache stays byte-identical).
157+
rules there (the mustache stays byte-identical); the vizdom graph
158+
SVGs' embedded black strokes/fills are likewise re-themed to
159+
`--graph-line` (`#9fb0c0` dark = `CHART_LEGEND_TEXT.dark`) via
160+
`path[stroke]`/`polygon` selectors on `.fullscreen-svg` — red cycle
161+
edges stay red.
158162

159163
## Report Tables (Enhanced)
160164

‎app/globals.css‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
--card-bg: #ffffff;
2929
--border-color: #dde4ea;
3030
--input-border: #c6d2dc;
31+
/* vizdom WASM graph edges bake black stroke/fill attributes into the SVG;
32+
palette-driven so the dark theme can swap them to a readable tint. */
33+
--graph-line: #000000;
3134
--error-color: #c0392b;
3235
--success-color: #1e8449;
3336
--error-bg: #fdf6f5;
@@ -91,6 +94,7 @@ html:root {
9194
--card-bg: #1a2330;
9295
--border-color: #2c3a4d;
9396
--input-border: #5b7396;
97+
--graph-line: #9fb0c0;
9498
--error-color: #f0928c;
9599
--success-color: #5bbd8b;
96100
--error-bg: #2b1d1f;
@@ -132,6 +136,7 @@ html:root {
132136
--card-bg: #1a2330;
133137
--border-color: #2c3a4d;
134138
--input-border: #5b7396;
139+
--graph-line: #9fb0c0;
135140
--error-color: #f0928c;
136141
--success-color: #5bbd8b;
137142
--error-bg: #2b1d1f;
@@ -921,3 +926,18 @@ main#app table.rf-data-table:not([data-rf-table]) {
921926
table headers. */
922927
overflow-x: auto;
923928
}
929+
930+
/* vizdom WASM graphs (Class/Package/cycle maps): the layout bakes black
931+
stroke/fill presentation attributes onto the edge curves and arrowhead
932+
polygons, which vanish on the dark page. Only non-red elements re-drive
933+
from the palette --graph-line — red stays red (cycle edges) and the
934+
fill-only paths (text glyphs) are left alone: node labels stay black on
935+
their white ellipses. */
936+
main#app .fullscreen-svg path[stroke]:not([stroke="red"]) {
937+
stroke: var(--graph-line);
938+
}
939+
940+
main#app .fullscreen-svg polygon:not([fill="red"]) {
941+
stroke: var(--graph-line);
942+
fill: var(--graph-line);
943+
}

‎tests/e2e/dark-mode.spec.js‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,49 @@ test('dark mode keeps rendering dark on report pages after navigation', async ({
128128
expect(await page.evaluate(() => localStorage.getItem('rf-theme'))).toBe('dark');
129129
});
130130

131+
test('non-red graph edges re-tint to the dark palette, cycle edges stay red', async ({ page }) => {
132+
test.skip(test.info().project.name !== 'chromium', 'wasm-heavy check runs once');
133+
// Mock GitHub raw content so the report page never hits the network.
134+
await page.route('**/raw.githubusercontent.com/**', route => {
135+
if (route.request().url().endsWith('refactor-first.json')) {
136+
route.fulfill({ status: 200, contentType: 'application/json', body: SAMPLE_REPORT });
137+
} else {
138+
route.continue();
139+
}
140+
});
141+
await page.goto('/refactorfirst/refactorfirst/master/');
142+
// vizdom parses/lays out the graph asynchronously via WASM.
143+
await page.waitForSelector('#classGraph svg path[stroke="black"]', { timeout: 120000 });
144+
await page.waitForSelector('#classGraph svg polygon[fill="black"]');
145+
await page.waitForSelector('#classGraph svg path[stroke="red"]');
146+
147+
const strokeOf = selector => page.evaluate(
148+
sel => getComputedStyle(document.querySelector(sel)).stroke, selector);
149+
const fillOf = selector => page.evaluate(
150+
sel => getComputedStyle(document.querySelector(sel)).fill, selector);
151+
const REGULAR_EDGE = '#classGraph svg path[stroke="black"]';
152+
const REGULAR_ARROW = '#classGraph svg polygon[fill="black"]';
153+
const CYCLE_EDGE = '#classGraph svg path[stroke="red"]';
154+
const CYCLE_ARROW = '#classGraph svg polygon[fill="red"]';
155+
156+
// Light theme: edges keep the baked-in black.
157+
expect(await strokeOf(REGULAR_EDGE)).toBe('rgb(0, 0, 0)');
158+
159+
await page.locator('#rf-theme-dark').check();
160+
// Dark theme: non-red edges/arrowheads use #9fb0c0 (dark --muted-color,
161+
// the Chart.js legend text color)…
162+
expect(await strokeOf(REGULAR_EDGE)).toBe('rgb(159, 176, 192)');
163+
expect(await strokeOf(REGULAR_ARROW)).toBe('rgb(159, 176, 192)');
164+
expect(await fillOf(REGULAR_ARROW)).toBe('rgb(159, 176, 192)');
165+
// …while red (cycle) edges and arrowheads stay red.
166+
expect(await strokeOf(CYCLE_EDGE)).toBe('rgb(255, 0, 0)');
167+
expect(await fillOf(CYCLE_ARROW)).toBe('rgb(255, 0, 0)');
168+
169+
// Switching back to light restores black without a reload (pure CSS).
170+
await page.locator('#rf-theme-light').check();
171+
expect(await strokeOf(REGULAR_EDGE)).toBe('rgb(0, 0, 0)');
172+
});
173+
131174
test('breadcrumbs and the toggle share one vertically centered row on report pages', async ({ page }) => {
132175
test.skip(test.info().project.name !== 'chromium', 'geometry check runs once');
133176
// Mock GitHub raw content so the report page never hits the network.

‎tests/unit/theme-css.test.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ describe('dark mode cascade structure', () => {
205205
});
206206
});
207207

208+
// vizdom WASM graphs (classGraph/packageGraph/cycle SVGs): the layout bakes
209+
// black stroke/fill presentation attributes onto the edge curves and
210+
// arrowhead polygons, which disappear on the dark page background. Only
211+
// non-red elements re-drive from the palette — red marks cycle edges.
212+
describe('vizdom graph edges in dark mode', () => {
213+
it('declares a per-palette graph line color (dark mirrors the chart legend text)', () => {
214+
// The dark value must mirror CHART_LEGEND_TEXT.dark in
215+
// lib/report-view.js (#9fb0c0 == --muted-color).
216+
expect(lightPalette.get('--graph-line')).toBeTruthy();
217+
expect(darkPalette.get('--graph-line')).toBe('#9fb0c0');
218+
// Perceivable against the dark page (SC 1.4.11, non-text >= 3:1).
219+
expect(contrastOf(darkPalette, '--graph-line', '--bg-color')).toBeGreaterThanOrEqual(3);
220+
});
221+
222+
it('re-drives non-red edge curves and arrowheads from the palette', () => {
223+
// Edge curves are the stroke-bearing paths (fill-only paths are text
224+
// glyphs, which must not match: node labels stay black on their white
225+
// ellipses); red cycle edges stay red.
226+
const edges = rules.get('main#app .fullscreen-svg path[stroke]:not([stroke="red"])');
227+
expect(edges).toBeTruthy();
228+
expect(edges).toMatch(/stroke:\s*var\(--graph-line\)/);
229+
const arrows = rules.get('main#app .fullscreen-svg polygon:not([fill="red"])');
230+
expect(arrows).toBeTruthy();
231+
expect(arrows).toMatch(/stroke:\s*var\(--graph-line\)/);
232+
expect(arrows).toMatch(/fill:\s*var\(--graph-line\)/);
233+
});
234+
});
235+
208236
describe('popup close button', () => {
209237
it('is a red square re-driven from palette variables', () => {
210238
// The template ships a bare × button; the red-square chrome must come

0 commit comments

Comments
 (0)