Skip to content

Mermaid: reproduce mermaid.js themes, flatten translucent host colors, fit tall diagrams by width (alpha.21) - #3

Merged
239573049 merged 1 commit into
mainfrom
mermaid-theme
Oct 18, 2026
Merged

239573049 merged 1 commit into
mainfrom
mermaid-theme

Conversation

@239573049

Copy link
Copy Markdown
Collaborator

Summary

Diagrams were unreadable in hosts whose theme tokens are translucent (AtomUI dark: text = 85% white, code background = 4% white). DiagramBlockView passed those colors on and MermaidDiagramRenderer dropped the alpha, giving Bg = Fg = #F0F0F0 (white on white; black on black in light themes). Tall flowcharts were also squeezed by a 900px height cap, leaving ~3px text.

  • Translucent colors — DiagramBlockView composites foreground / surface / accent onto the real backdrop (nearest opaque ancestor background) before calling the renderer. It renders only once attached, uses an opaque fullscreen background, and keys the diagram cache by the colors, font and renderer instance actually used.
  • Themes — new MermaidTheme (MermaidJs default, MermaidJsNeutral, Native). The MermaidJs palettes are the real mermaid 12.2 dark / default / neutral styles, applied through Mermaider's Surface / Border / Line options plus an SVG repaint of subgraphs, edge labels and derived node shapes. A neutral DataPalette is used for structural diagrams only; charts keep categorical colors.
  • Tall diagrams — no more 900px cap: fit by width, 6000px safety cap.
  • Codemap, docs and repo memory updated.

Test plan

  • New MermaidThemeTests (palettes, node text contrast for every theme, translucent host colors, subgraph / edge label / shape repaint, chart colors kept, diagram kind detection, snapshots) and DiagramBlockViewTests (flattening onto the real backdrop, cache key reacts to color changes, height fit)
  • dotnet test StreamMark.slnx on macOS: 159 + 334 passed
  • NativeAOT Gallery publish on osx-arm64: 0 IL warnings, --smoke passes (including ui.diagram)
  • CI on Windows / Linux / AOT smoke

🤖 Generated with Claude Code

…, fit tall diagrams by width

Diagrams were unreadable in hosts whose theme tokens are translucent (AtomUI dark:
text = 85% white, code background = 4% white). DiagramBlockView passed those colors
on and MermaidDiagramRenderer dropped the alpha, giving Bg = Fg = #F0F0F0 (white on
white; black on black in light themes). Tall flowcharts were also squeezed to a 900px
height cap, leaving ~3px text.

- DiagramBlockView composites foreground / surface / accent onto the real backdrop
  (nearest opaque ancestor background) before calling the renderer, renders only once
  attached, uses an opaque fullscreen background, and keys the diagram cache by the
  colors, font and renderer instance actually used.
- StreamMark.Mermaid: new MermaidTheme (MermaidJs default, MermaidJsNeutral, Native).
  The MermaidJs palettes are the real mermaid 12.2 dark / default / neutral styles,
  applied through Mermaider's Surface / Border / Line options plus an SVG repaint of
  subgraphs, edge labels and derived node shapes (stadium, cylinder, decision). A
  neutral DataPalette is used for structural diagrams only; charts keep categorical
  colors.
- Diagram height is no longer capped at 900px: fit by width, 6000px safety cap.
- Tests (theme palettes, node text contrast, translucent host colors, cache key,
  height fit), codemap, docs and repo memory updated.

Packed as 0.1.0-alpha.21 for TKCode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@239573049
239573049 merged commit 8d344a6 into main Oct 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant