Skip to content

Add theming support to new visual designer#18987

Merged
shenglol merged 2 commits intomainfrom
shenglol/visualizer-migration-2
Feb 10, 2026
Merged

Add theming support to new visual designer#18987
shenglol merged 2 commits intomainfrom
shenglol/visualizer-migration-2

Conversation

@shenglol
Copy link
Contributor

@shenglol shenglol commented Feb 10, 2026

Summary

Add VS Code theme support to the new visual designer so it renders correctly in light, dark, high-contrast dark, and high-contrast light themes.

Changes

New files

  • styled.d.tsDefaultTheme type augmentation for styled-components, declaring the shape of the theme object (canvas, node, text, edge, controlBar, etc.)
  • theming/themes.ts — Four curated color palettes (lightTheme, darkTheme, highContrastTheme, highContrastLightTheme) plus getThemeFromBody() which reads document.body.dataset.vscodeThemeKind
  • theming/useTheme.ts — React hook that observes data-vscode-theme-kind on <body> via MutationObserver and returns the matching DefaultTheme

Updated files

  • App.tsx — Wraps component tree in styled-components <ThemeProvider>; renders <GlobalStyle /> inside the provider
  • GlobalStyle.ts — Uses theme props for background-color and color
  • CanvasBackground.tsx — Uses currentColor trick with useTheme() for dot grid color; transparent dots in HC themes
  • ResourceDeclaration.tsx / ModuleDeclaration.tsx — Styled-component theme interpolations for node border, background, text colors
  • EdgeMarkerDefs.tsx / StraightEdge.tsxuseTheme() for edge stroke color as JSX props
  • GraphControlBar.tsx — Theme interpolations for toolbar background, border, icon, hover/active/focus states
  • Canvas.tsx — Builds grab cursor data URI from theme props (grabCursor.fill / grabCursor.opacity)
  • index.tsx — Cleaned up (theming is handled entirely in App.tsx)

Documentation

  • visualizer-migration/step-2-theming.md — Updated to reflect the actual implementation
  • visualizer-migration/README.md — Step 2 marked as complete

Design decisions

  • Custom palettes over --vscode-* variables — Editor theme colors are designed for text editors, not graph visualization. Curated palettes ensure nodes, edges, and canvas look intentional.
  • data-vscode-theme-kind over className — The body class list can contain multiple overlapping theme classes (e.g. vscode-high-contrast-light vscode-high-contrast vscode-reduce-motion), making regex matching unreliable. The data attribute always has a single, unambiguous value.
  • Four theme variants — The old visualizer only supported three. Adding high-contrast light ensures complete accessibility coverage.

Testing

Verified with npm run dev using the <vscode-dev-toolbar> to toggle between all four themes. Build passes (npx turbo build).

Microsoft Reviewers: Open in CodeFlow

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

Test this change out locally with the following install scripts (Action run 21884519724)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 21884519724
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 21884519724"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 21884519724
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 21884519724"

@shenglol shenglol merged commit b043602 into main Feb 10, 2026
41 of 42 checks passed
@shenglol shenglol deleted the shenglol/visualizer-migration-2 branch February 10, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants