Skip to content

feat(charts): add high contrast - #8379

Merged
mcoker merged 4 commits into
patternfly:mainfrom
mcoker:hc-charts
May 8, 2026
Merged

mcoker merged 4 commits into
patternfly:mainfrom
mcoker:hc-charts

Conversation

@mcoker

@mcoker mcoker commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

fixes #7949

Relies on token updates from patternfly/design-tokens#148

Used to do the react work in patternfly/patternfly-react#12419

Summary by CodeRabbit

  • New Features

    • Added high-contrast chart themes (dark and high-contrast variants) for improved accessibility.
  • Updates

    • Enhanced chart contrast across axes, grids, ticks, data strokes, legends, and skeletons for clearer visuals.
    • Split chart stroke settings into separate color and width controls for finer styling and accessibility tuning.

@coderabbitai

coderabbitai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: fbe636d6-52d5-47d3-b2e0-a4217484b237

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe0c45 and ab7989f.

📒 Files selected for processing (1)
  • src/patternfly/patternfly-charts.scss
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/patternfly/patternfly-charts.scss

Walkthrough

Adds high-contrast chart token files and Red Hat high-contrast tokens, refactors chart label stroke into separate color and width CSS custom properties, updates chart SCSS to include and use high-contrast tokens, and regenerates timestamps in many token files.

Changes

High-Contrast Chart Token Support

Layer / File(s) Summary
Token Definitions
src/patternfly/base/tokens/tokens-charts-highcontrast.scss, src/patternfly/base/tokens/tokens-charts-highcontrast-dark.scss, src/patternfly/base/tokens/tokens-redhat-highcontrast.scss, src/patternfly/base/tokens/tokens-charts-dark.scss
New high-contrast chart and Red Hat high-contrast token mixins added; chart label stroke token refactored from --pf-t--chart--global--label--stroke into --pf-t--chart--global--label--stroke--color and --pf-t--chart--global--label--stroke--width.
Chart Theme Integration
src/patternfly/patternfly-charts.scss
Added @use imports and theme-scoped includes for high-contrast tokens; updated per-chart CSS custom properties (area, axis, bar, box-plot, bullet, donut, legend, pie, skeleton) to reference high-contrast border and label-stroke color/width tokens.
Token File Regeneration
src/patternfly/base/tokens/tokens-*.scss
Regenerated header timestamps across many existing token files without functional changes.

Sequence Diagram(s)

sequenceDiagram
  participant DevPipeline
  participant TokenFiles
  participant ThemeIncludes
  participant ChartStyles
  DevPipeline->>TokenFiles: generate/add high-contrast token mixins
  TokenFiles->>ThemeIncludes: expose token mixins via `@use`
  ThemeIncludes->>ChartStyles: include tokens under theme selectors
  ChartStyles->>ChartStyles: update per-chart CSS custom properties to use HC tokens
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #7724: The changes add/adjust high-contrast chart token files and update chart SCSS to use those high-contrast border/label stroke variables, addressing the high-contrast charts work referenced by the issue.

Suggested labels

released on @prerelease``

Suggested reviewers

  • srambach
  • lboehling
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(charts): add high contrast' follows conventional commit guidelines with appropriate type prefix and scope.
Linked Issues check ✅ Passed Changes implement high contrast support for charts by adding new token files and updating stroke properties, directly addressing issue #7949 requirements.
Out of Scope Changes check ✅ Passed All changes focus on chart high contrast support: new token files, stroke property updates, and high contrast theme selectors are directly related to PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@patternfly-build

patternfly-build commented May 8, 2026 •

Copy link
Copy Markdown
Collaborator

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/patternfly/patternfly-charts.scss (1)

108-110: ⚡ Quick win

Wire label stroke width to the new token

You’ve split label stroke into color/width tokens, but width is still hardcoded (0) here, so theme-level width overrides can’t take effect.

Proposed fix
-  --#{$chart}-global--label--stroke: var(--pf-t--chart--global--label--stroke--color);
+  --#{$chart}-global--label--stroke: var(--pf-t--chart--global--label--stroke--color);
   --#{$chart}-global--label--text-anchor: var(--pf-t--chart--global--label--text-anchor);
-  --#{$chart}-global--label--stroke--Width: 0;
+  --#{$chart}-global--label--stroke--Width: var(--pf-t--chart--global--label--stroke--width);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/patternfly/patternfly-charts.scss` around lines 108 - 110, The label
stroke width is hardcoded to 0 and uses a capitalized property name
(--#{$chart}-global--label--stroke--Width), so theme overrides can't apply;
change the property to use a lowercase suffix and wire it to the new token, i.e.
replace the hardcoded line with --#{$chart}-global--label--stroke--width:
var(--pf-t--chart--global--label--stroke--width); so the theme-level width token
is respected (update the property name and its value to the token).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/patternfly/base/tokens/tokens-redhat-highcontrast.scss`:
- Line 732: The token mapping for
--pf-t--global--text--color--status--on-danger--clicked incorrectly references
the icon inverse token (--pf-t--global--icon--color--inverse); update that
mapping to use the text inverse token (--pf-t--global--text--color--inverse) so
it matches neighboring text mappings and the source token semantics, then
regenerate.
- Around line 64-66: The lint failures come from capitalized generic font family
keywords in the generated tokens (--pf-t--global--font--family--100,
--pf-t--global--font--family--200, --pf-t--global--font--family--300); fix by
normalizing generic family names to lowercase in the token generator/source so
it emits "helvetica, arial, sans-serif, courier, monospace" (or update the
generator's fallback mapping) and regenerate tokens, or alternatively update CI
linting to ignore this generated file (exclude it from the stylelint
keyword-case rule) so the produced values for those token variables no longer
trigger keyword-case errors.
- Line 598: There are duplicate declarations for the custom property
--pf-t--global--color--status--read--on-secondary (one at the earlier occurrence
and another later that overrides it); update the token generator/source mapping
that emits tokens-redhat-highcontrast.scss so it emits a single canonical value
for --pf-t--global--color--status--read--on-secondary (and ensure
--pf-t--global--color--status--read--on-primary remains correct), by removing
the duplicate mapping or consolidating conflicting token inputs in the generator
so only one declaration for that custom property is produced.

---

Nitpick comments:
In `@src/patternfly/patternfly-charts.scss`:
- Around line 108-110: The label stroke width is hardcoded to 0 and uses a
capitalized property name (--#{$chart}-global--label--stroke--Width), so theme
overrides can't apply; change the property to use a lowercase suffix and wire it
to the new token, i.e. replace the hardcoded line with
--#{$chart}-global--label--stroke--width:
var(--pf-t--chart--global--label--stroke--width); so the theme-level width token
is respected (update the property name and its value to the token).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9ef2e3ae-90a5-43c1-bc80-be7c1ddb1939

📥 Commits

Reviewing files that changed from the base of the PR and between b06d57f and 98d1ec0.

📒 Files selected for processing (17)
  • src/patternfly/base/tokens/tokens-charts-dark.scss
  • src/patternfly/base/tokens/tokens-charts-highcontrast-dark.scss
  • src/patternfly/base/tokens/tokens-charts-highcontrast.scss
  • src/patternfly/base/tokens/tokens-charts.scss
  • src/patternfly/base/tokens/tokens-dark.scss
  • src/patternfly/base/tokens/tokens-default.scss
  • src/patternfly/base/tokens/tokens-felt-dark.scss
  • src/patternfly/base/tokens/tokens-felt-glass-dark.scss
  • src/patternfly/base/tokens/tokens-felt-glass.scss
  • src/patternfly/base/tokens/tokens-felt-highcontrast-dark.scss
  • src/patternfly/base/tokens/tokens-felt-highcontrast.scss
  • src/patternfly/base/tokens/tokens-felt.scss
  • src/patternfly/base/tokens/tokens-glass-dark.scss
  • src/patternfly/base/tokens/tokens-glass.scss
  • src/patternfly/base/tokens/tokens-palette.scss
  • src/patternfly/base/tokens/tokens-redhat-highcontrast.scss
  • src/patternfly/patternfly-charts.scss

Comment on lines +64 to +66
--pf-t--global--font--family--100: "Red Hat Text", "RedHatText", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans JP", "Noto Sans KR", "Noto Sans Malayalam", "Noto Sans SC", "Noto Sans TC", "Noto Sans Thai", Helvetica, Arial, sans-serif;
--pf-t--global--font--family--200: "Red Hat Display", "RedHatDisplay", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans JP", "Noto Sans KR", "Noto Sans Malayalam", "Noto Sans SC", "Noto Sans TC", "Noto Sans Thai", Helvetica, Arial, sans-serif;
--pf-t--global--font--family--300: "Red Hat Mono", "RedHatMono", "Courier New", Courier, monospace;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Resolve stylelint keyword-case failures in generated font-family fallbacks

Static analysis flags Line 64-Line 66 for value keyword casing (Helvetica/Arial/Courier). If this generated file is linted, it can block CI.

Since this file is generated, either normalize casing in the token generator/source or exclude generated token artifacts from this lint rule.

🧰 Tools
🪛 Stylelint (17.10.0)

[error] 64-64: Expected "Helvetica" to be "helvetica" (value-keyword-case)

(value-keyword-case)


[error] 64-64: Expected "Arial" to be "arial" (value-keyword-case)

(value-keyword-case)


[error] 65-65: Expected "Helvetica" to be "helvetica" (value-keyword-case)

(value-keyword-case)


[error] 65-65: Expected "Arial" to be "arial" (value-keyword-case)

(value-keyword-case)


[error] 66-66: Expected "Courier" to be "courier" (value-keyword-case)

(value-keyword-case)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/patternfly/base/tokens/tokens-redhat-highcontrast.scss` around lines 64 -
66, The lint failures come from capitalized generic font family keywords in the
generated tokens (--pf-t--global--font--family--100,
--pf-t--global--font--family--200, --pf-t--global--font--family--300); fix by
normalizing generic family names to lowercase in the token generator/source so
it emits "helvetica, arial, sans-serif, courier, monospace" (or update the
generator's fallback mapping) and regenerate tokens, or alternatively update CI
linting to ignore this generated file (exclude it from the stylelint
keyword-case rule) so the produced values for those token variables no longer
trigger keyword-case errors.

--pf-t--global--color--brand--accent--clicked: var(--pf-t--global--color--brand--clicked);
--pf-t--global--color--brand--accent--default: var(--pf-t--global--color--brand--default);
--pf-t--global--color--brand--accent--hover: var(--pf-t--global--color--brand--hover);
--pf-t--global--color--status--read--on-primary: var(--pf-t--global--background--color--secondary--default);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove duplicate declaration for --pf-t--global--color--status--read--on-secondary

Line 598 and Line 754 define the same custom property with different values; Line 754 silently overrides Line 598. This creates ambiguous intent and can cause theme drift.

Because this file is generated, please fix the source token mapping/generator so only one canonical value is emitted.

Also applies to: 754-754

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/patternfly/base/tokens/tokens-redhat-highcontrast.scss` at line 598,
There are duplicate declarations for the custom property
--pf-t--global--color--status--read--on-secondary (one at the earlier occurrence
and another later that overrides it); update the token generator/source mapping
that emits tokens-redhat-highcontrast.scss so it emits a single canonical value
for --pf-t--global--color--status--read--on-secondary (and ensure
--pf-t--global--color--status--read--on-primary remains correct), by removing
the duplicate mapping or consolidating conflicting token inputs in the generator
so only one declaration for that custom property is produced.

--pf-t--global--text--color--status--on-custom--clicked: var(--pf-t--global--text--color--inverse);
--pf-t--global--text--color--status--on-custom--default: var(--pf-t--global--text--color--inverse);
--pf-t--global--text--color--status--on-custom--hover: var(--pf-t--global--text--color--inverse);
--pf-t--global--text--color--status--on-danger--clicked: var(--pf-t--global--icon--color--inverse);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the text inverse token for the text color mapping

Line 732 maps --pf-t--global--text--color--status--on-danger--clicked to --pf-t--global--icon--color--inverse, while neighboring text mappings use --pf-t--global--text--color--inverse. This is a semantic mismatch and may break contrast behavior if icon/text inverse tokens diverge.

Please align this to the text token in the source token definition before regenerating.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/patternfly/base/tokens/tokens-redhat-highcontrast.scss` at line 732, The
token mapping for --pf-t--global--text--color--status--on-danger--clicked
incorrectly references the icon inverse token
(--pf-t--global--icon--color--inverse); update that mapping to use the text
inverse token (--pf-t--global--text--color--inverse) so it matches neighboring
text mappings and the source token semantics, then regenerate.

@mcoker

mcoker commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Thumbs up from @lboehling on this initial pass by testing in react and sifting through visual regressions of charts in light/dark/hc-light/hc-dark. These are needed to create a react PR so going ahead and merging.

@mcoker
mcoker merged commit 5882641 into patternfly:main May 8, 2026
5 checks passed
@mcoker
mcoker deleted the hc-charts branch May 8, 2026 20:05
@patternfly-build

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.5.0-prerelease.86 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

High contrast support for charts

2 participants