Skip to content

fix: make treemap title and labels theme-aware for dark background readers#7403

Open
makandcheezy wants to merge 1 commit intomermaid-js:developfrom
makandcheezy:fix/treemap-title-dark-background
Open

fix: make treemap title and labels theme-aware for dark background readers#7403
makandcheezy wants to merge 1 commit intomermaid-js:developfrom
makandcheezy:fix/treemap-title-dark-background

Conversation

@makandcheezy
Copy link

📑 Summary

The treemap diagram title, labels, and values were hardcoded to 'black' in styles.ts, making them invisible on dark backgrounds regardless of the active theme. This fix resolves text colors from the active theme's titleColor and textColor variables instead of using hardcoded values. User-provided style overrides still take priority via the nullish coalescing operator.

Resolves #7218

📏 Design Decisions

Followed the same pattern used by the radar diagram (packages/mermaid/src/diagrams/radar/styles.ts), which imports getThemeVariables and getConfigAPI to resolve theme-aware colors at style generation time. Removed hardcoded 'black' defaults for titleColor, labelColor, and valueColor from the defaults object, and instead resolve them from themeVariables.titleColor and themeVariables.textColor. Explicit user overrides via the treemap config still take highest priority.

📋 Tasks

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation.
  • 🦋 changeset

@netlify
Copy link

netlify bot commented Feb 17, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit e73db0f
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69947ce9b23e560008e82aca
😎 Deploy Preview https://deploy-preview-7403--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2026

⚠️ No Changeset found

Latest commit: e73db0f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Feb 17, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 17, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7403

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7403

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7403

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7403

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7403

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7403

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7403

commit: e73db0f

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.58%. Comparing base (4d5ede8) to head (e73db0f).

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/treemap/styles.ts 0.00% 11 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7403      +/-   ##
==========================================
- Coverage     3.58%   3.58%   -0.01%     
==========================================
  Files          475     475              
  Lines        47589   47594       +5     
  Branches       741     741              
==========================================
  Hits          1706    1706              
- Misses       45883   45888       +5     
Flag Coverage Δ
unit 3.58% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/treemap/styles.ts 2.56% <0.00%> (-0.38%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Feb 17, 2026, 2:51 PM

@knsv
Copy link
Collaborator

knsv commented Feb 27, 2026

[sisyphus-bot] Thanks for this clean fix! This is the approach we'd like to go with — it follows the established radar diagram pattern and keeps the scope minimal.

Before we can merge, could you please add:

  1. A changeset (pnpm changeset — patch, message like fix: treemap title and labels use theme-aware colors for dark backgrounds)
  2. A Cypress snapshot test for the dark theme rendering (you can reference the test in PR treemap: fix unreadable title on dark backgrounds #7231 for inspiration)

Appreciate the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TreeMap title unreadable on dark backgrounds

2 participants