Skip to content

Fix chart axis colours for dark mode#7087

Draft
talissoncosta wants to merge 7 commits intochore/design-system-tokensfrom
fix/chart-dark-mode-colours-6889
Draft

Fix chart axis colours for dark mode#7087
talissoncosta wants to merge 7 commits intochore/design-system-tokensfrom
fix/chart-dark-mode-colours-6889

Conversation

@talissoncosta
Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #6889

Replace hardcoded hex colours in all Recharts chart components with semantic design tokens that adapt to light and dark mode.

What was done

  • useChartTheme hook — resolves CSS custom property tokens (--color-text-*, --color-border-*) into values Recharts can use in SVG fill/stroke props. Exposes palette array for data series colouring.
  • ChartTooltip component — shared tooltip with colour swatch + readable text, replacing 2 duplicated inline RechartsTooltip components and 3 Recharts default tooltips.
  • Tooltip SCSS.recharts-tooltip, .recharts-default-tooltip, and .recharts-tooltip-swatch classes using CSS custom properties instead of .dark class overrides.
  • 5 chart files updated:
    • OrganisationUsage.container.tsx — tokens for grid, axis, ticks; shared tooltip
    • SingleSDKLabelsChart.tsx — same; removed duplicate tooltip
    • UsageTrendsChart.tsx — tokens for ticks and line strokes (info/success/warning)
    • ExperimentResultsTab.tsx — tokens for all chart elements; variant colours from palette
    • FeatureAnalytics.tsx — tokens for ticks, axis, tooltip

Before / After

Element Before (hardcoded) After (token)
Grid lines #EFF1F4 --color-border-default
Tick text #656D7B / #1A2634 --color-text-secondary
Axis lines #EFF1F4 / #656D7B --color-border-default
Line strokes #0AADDF, #27AB95, #FF9F43 --color-text-info/success/warning
Tooltip bg hardcoded white --color-surface-default
Tooltip text hardcoded / colour-matched swatch + --color-text-secondary

How did you test this code?

  1. ENV=local npm run dev
  2. Navigate to Organisation Usage, Feature Analytics (Usage tab), and Experiments pages
  3. Toggle dark mode via settings
  4. Verified chart grid lines, axis labels, tick text, tooltips, and line/bar colours adapt correctly in both themes
  5. Verified tooltip swatch pattern is consistent across all charts

🤖 Generated with Claude Code

talissoncosta and others added 7 commits March 31, 2026 18:11
Add _token-utilities.scss with utility classes consuming the design
tokens for colours, borders, icons, radius, shadows, font weights, and
transitions. These fill the gap Bootstrap doesn't cover — semantic
surface colours, icon colours, border radius tokens, etc.

Remove spacing tokens entirely — Bootstrap handles spacing via its
existing utility classes. This avoids two competing sources of truth
for the same concern.

- Create web/styles/_token-utilities.scss (no !important, no spacing)
- Remove space key from tokens.json
- Update generate-tokens.mjs to skip spacing generation
- Delete SpacingTokens.stories.tsx
- Regenerate _tokens.scss, tokens.ts, and MCP reference story
- Update TokenMaintenance.mdx and docs.scss

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add utility class generation to the codegen pipeline. When tokens.json
changes, the pre-commit hook now generates _token-utilities.scss
alongside _tokens.scss, tokens.ts, and the MCP reference story.

Adding a new token to tokens.json automatically creates its utility
class — no manual SCSS to write.

- Add generateUtilities() to generate-tokens.mjs
- Update lint-staged to auto-stage _token-utilities.scss
- Update TokenMaintenance.mdx to document the 4-file pipeline

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded hex colours in Recharts components with resolved
semantic design tokens via useChartTheme hook. Fixes chart axis labels,
grid lines, tick fills, and tooltip text being invisible or low contrast
in dark mode. Also updates recharts tooltip SCSS to use CSS custom
properties instead of .dark class overrides.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove experiment-specific winnerColour, rename variantColours to
palette. Consumers pick from semantic colours directly (e.g.
lineSuccess for winner).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the duplicated tooltip pattern (colour swatch + readable text)
into a reusable ChartTooltip component. Add CSS classes for tooltip
swatch and Recharts default tooltip dark mode styling using semantic
tokens.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tooltip styling is now handled entirely via CSS classes targeting
.recharts-tooltip and .recharts-default-tooltip, so the JS-resolved
tooltip colour is no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace duplicated inline RechartsTooltip components in
OrganisationUsage and SingleSDKLabelsChart, and replace Recharts
default tooltips in FeatureAnalytics, UsageTrendsChart, and
ExperimentResultsTab with the shared ChartTooltip. This gives all
charts a consistent swatch + readable text tooltip pattern that
works in both light and dark mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Mar 31, 2026 10:25pm
flagsmith-frontend-staging Ready Ready Preview, Comment Mar 31, 2026 10:25pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Mar 31, 2026 10:25pm

Request Review

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

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant