feat(diagrams): bring the hand-drawn diagrams onto the same palette - #12647
Conversation
|
This pull request is part of a Mergify stack:
|
Merge Protections🔴 2 of 6 protections blocking · waiting on 👀 reviews
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
Show 4 satisfied protections🟢 🤖 Continuous Integration
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes shared diagram rendering and styling across many pages, so a final human review with visual verification is advisable.
Pull request overview
This PR unifies all diagram rendering (Graphviz fences, <GitGraph>, and <StackMapping>) under a single role-based palette and shared SVG post-processing, so diagrams stay consistent across themes and pages.
Changes:
- Introduces
finishDiagramSvg()as a shared Graphviz SVG post-processor and a single source of truth for diagram roles. - Refactors
<GitGraph>and the remark Graphviz pipeline to emit role classes (instead of hard-coded colors) and rely on.dgstyling. - Updates hand-drawn SVG diagrams (
<StackMapping>, GitGraph linear mode) and docs call sites to use roles (commitRole,role) instead of colors.
File summaries
| File | Description |
|---|---|
| src/util/diagramSvg.ts | Adds shared SVG post-processing and centralized DiagramRole vocabulary. |
| src/styles/theme.css | Removes the legacy --theme-diagram-edge token in favor of role accents. |
| src/styles/index.css | Extends .dg painting rules to cover hand-placed shapes and sets sizing for fixed-size diagrams. |
| src/content/docs/stacks/updating.mdx | Updates <GitGraph> usage from commitColor to commitRole. |
| src/content/docs/stacks/concepts.mdx | Updates <GitGraph> usage from commitColor to commitRole. |
| src/content/docs/stacks/compare/graphite.mdx | Migrates node objects from color to role. |
| src/content/docs/stacks/compare/gh-stack.mdx | Migrates node objects from color to role. |
| src/content/docs/stacks.mdx | Migrates PR/node coloring from color/commitColor to role-based props. |
| src/content/docs/merge-queue/stacks.mdx | Updates <GitGraph> usage from commitColor to commitRole. |
| src/content/docs/merge-queue/merge-strategies.mdx | Migrates node objects from color to role. |
| src/components/StacksLocalModel.astro | Updates <GitGraph> usage from commitColor to commitRole. |
| src/components/StackMapping.astro | Refactors hand-placed SVG to use .dg roles and content-sized columns (removes hex literals/styles). |
| src/components/GitGraph.astro | Refactors both linear and Graphviz modes to emit role classes and use shared SVG post-processing. |
| plugins/remark-graphviz.ts | Switches to shared SVG post-processing and keeps legacy color-to-role mapping via roleFor. |
Review details
Suppressed comments (1)
plugins/remark-graphviz.ts:140
- To keep the
finishDiagramSvg(..., { roleFor })contract type-safe,legacyRoleForshould returnDiagramRole | undefined(matching the roles actually used inLEGACY_ROLES). This prevents accidentally returning an unsupported role string that.dgcan't style.
function legacyRoleFor(kind: DiagramKind, { fill, stroke }: ShapePaint): string | undefined {
if (kind === 'edge') return stroke ? LEGACY_ROLES[stroke.toLowerCase()] : undefined;
const table = kind === 'cluster' ? LEGACY_CLUSTER_ROLES : LEGACY_ROLES;
const color = !fill || fill === 'none' ? (kind === 'cluster' ? stroke : undefined) : fill;
return color ? table[color.toLowerCase()] : undefined;
- Files reviewed: 14/14 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
204561e to
e2b246d
Compare
Revision history
|
|
Re-pushed to address the review: 204561e → e2b246d (compare).
|
|
@jd this pull request is now in conflict 😩 |
`<GitGraph>` was a second Graphviz pipeline running beside the `dot` fences, with its own `COLORS` map, its own `EDGE_COLOR`, and its own string-replace for dark mode. `<StackMapping>` was a third, with five more hex literals. Three surfaces, three private palettes, all drifting apart — which is how a page like merge-queue/stacks ends up rendering a themed diagram and a baked one side by side. All three now name roles. `src/util/diagramSvg.ts` holds the post-processing both Graphviz surfaces share — drop the canvas, strip the inline paint, mark a borderless shape as a caption — so there is one place to change and no second list of hex strings to fall out of date. The hand-placed SVG in GitGraph's linear mode and in StackMapping emits the same `node` / `edge` groups and the same role classes, so `.dg` paints all four kinds of diagram from one stylesheet. `--theme-diagram-edge` is deleted: it was the old surfaces' single diagram token and `--dg-a-chrome` now says the same thing. This also fixes the bug that made the case for it. GitGraph marks every node `style=filled`, which reaches a `shape=plaintext` node too, so the `main` branch label sat on an opaque pale box — barely noticeable in light mode and glaring in dark, on seven pages. It is a caption, so it now carries `plain` and the box is gone. Two things changed while I was in there: - `<StackMapping>` sizes its columns to their content. They were fixed at 160px and the generated branch names did not fit; the overflow was invisible while the label was white on a solid fill, and would have been plainly visible once the label became dark text on a tint. - Graph-mode commit graphs are typeset at the same sizes as the fences (13/10 rather than Graphviz's default 14 and a hand-set 9), so the two kinds of diagram on one page no longer disagree about how big a label is. A call site names a role rather than a color: `color: "green"` becomes `role: "queued"`, `commitColor="green"` becomes `commitRole="queued"`. The prop is typed as `DiagramRole`, so a color name no longer compiles. Change-Id: I6bdb5b9fbd6574a37172fa067e81b0103282725f
e2b246d to
b010849
Compare
|
Rebased onto
|
<GitGraph>was a second Graphviz pipeline running beside thedotfences,with its own
COLORSmap, its ownEDGE_COLOR, and its own string-replace fordark mode.
<StackMapping>was a third, with five more hex literals. Threesurfaces, three private palettes, all drifting apart — which is how a page like
merge-queue/stacks ends up rendering a themed diagram and a baked one side by
side.
All three now name roles.
src/util/diagramSvg.tsholds the post-processingboth Graphviz surfaces share — drop the canvas, strip the inline paint, mark a
borderless shape as a caption — so there is one place to change and no second
list of hex strings to fall out of date. The hand-placed SVG in GitGraph's
linear mode and in StackMapping emits the same
node/edgegroups and thesame role classes, so
.dgpaints all four kinds of diagram from onestylesheet.
--theme-diagram-edgeis deleted: it was the old surfaces' singlediagram token and
--dg-a-chromenow says the same thing.This also fixes the bug that made the case for it. GitGraph marks every node
style=filled, which reaches ashape=plaintextnode too, so themainbranch label sat on an opaque pale box — barely noticeable in light mode and
glaring in dark, on seven pages. It is a caption, so it now carries
plainandthe box is gone.
Two things changed while I was in there:
<StackMapping>sizes its columns to their content. They were fixed at160px and the generated branch names did not fit; the overflow was invisible
while the label was white on a solid fill, and would have been plainly
visible once the label became dark text on a tint.
rather than Graphviz's default 14 and a hand-set 9), so the two kinds of
diagram on one page no longer disagree about how big a label is.
A call site names a role rather than a color:
color: "green"becomesrole: "queued",commitColor="green"becomescommitRole="queued". Theprop is typed as
DiagramRole, so a color name no longer compiles.