Skip to content

refactor(styles): diff view uses the shared code colour tokens#8069

Draft
talissoncosta wants to merge 13 commits into
mainfrom
refactor/diff-code-tokens
Draft

refactor(styles): diff view uses the shared code colour tokens#8069
talissoncosta wants to merge 13 commits into
mainfrom
refactor/diff-code-tokens

Conversation

@talissoncosta

Copy link
Copy Markdown
Contributor
  • 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

Follow-up to #8023, from Kyle's review comment: the diff view (change requests, flag history) now uses the same code colour palette as the rest of the app's snippets, and follows light/dark mode for free.

  • Prism token colours in the diff map to the --color-code-* tokens, matching how highlight.js colours the same concepts (keys, strings, literals)
  • Row and word tints use the semantic surface tokens; new --color-surface-danger-strong / --color-surface-success-strong for word-level emphasis inside a tinted row
  • The manual .dark override in _react-diff.scss is gone, tokens flip themselves
  • Adds DiffString Storybook stories (changed JSON, changed string, same value)

Stacked on #8023 (needs its --color-code-* tokens); will retarget main once that merges.

How did you test this code?

Storybook: npm run storybook, Components/DiffString stories, toggled light/dark. In the app: a change request or feature history diff with a JSON value, both themes.

  • Changed JSON: keys/strings/literals match the code snippet colours; added/removed rows tinted, changed words stand out within them
  • Dark mode: same, with readable tints
  • Same-value view (unchanged flag value) still renders on the subtle surface

Screenshots

After (light) After (dark)
Changed JSON
Same value

talissoncosta and others added 11 commits July 17, 2026 11:15
New --color-code-* semantic family for highlight.js syntax, mapped to the
nearest palette primitives (light in :root, lighter in .dark). Added to
tokens.json (source of truth) and regenerated; registered in the Semantic
Colour Tokens story so it shows the group.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Point the shared .hljs palette (and the Pylon --hljs-* var-feed) at the
--color-code-* tokens so code blocks follow light/dark. Add .hljs--embedded
for containers that own their surface (onboarding's CodeCard opts in via
Highlight's embedded prop and drops its bespoke palette) and a theme-adaptive
scrollbar. Nest the palette under .hljs to out-specify Pylon's injected rules.
Drop the dead $code-color/$code-bg vars and the legacy .yaml override. Header
chrome untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…awHtml

Add an `embedded` boolean prop that applies the .hljs--embedded modifier,
instead of callers concatenating the class into the language string. Import
Button (via the components/ alias) instead of the global, since the Highlight
story renders it and Storybook doesn't stub the global. Extract the nested
raw-html ternary into a getRawHtml method. No behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover the code wrapper across languages plus the embedded variant. Stub the
isMobile global so components that read it render in Storybook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review (Kyle): red tag names read as errors. Tags now render like an IDE:
grey angle brackets (base text via the catch-all), blue tag name.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Covers markup tags inside JavaScript, mirroring the React code-help
snippet, so the tag colour renders in Chromatic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The shared React init snippet was two files mashed into one - two 'export
default function' (App and HomePage, invalid JS), duplicate imports, an unused
useFlagsmith import, and an App that never rendered HomePage. Make it one
coherent example: a named HomePage using useFlags, rendered inside the default
App wrapped in FlagsmithProvider. Shared via codeHelp.INIT, so this fixes the
snippet app-wide, including the onboarding wire step.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Ports the onboarding code-card fix (was on #7989) to the shared embedded
variant: overflow-x auto instead of a permanently reserved gutter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Snippet sources were pre-escaped (&lt; &gt;) because CodeHelp rendered
them as raw HTML via preventEscape, so Copy Code shipped the entities
to the clipboard. Store plain < > and let Highlight's default escaping
handle rendering, like the onboarding code card already does.
preventEscape now has no users, so the prop is gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Keep this PR theming-only. preventEscape removal + code-help source
de-escaping move to #8062. Highlight keeps embedded + the de-nested
getRawHtml (retaining preventEscape); escaping behaviour is unchanged here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
One step above surface-success/danger, for emphasis inside an already
tinted surface (e.g. changed words inside a diff row).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@talissoncosta
talissoncosta requested a review from a team as a code owner July 22, 2026 12:21
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jul 22, 2026 12:36pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jul 22, 2026 12:36pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jul 22, 2026 12:36pm

Request Review

@talissoncosta
talissoncosta requested review from kyle-ssg and removed request for a team July 22, 2026 12:21
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3e582680-c46f-49ec-adcb-d79d91cfa0a7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8069 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8069 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8069 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8069 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8069 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8069 Finished ✅ Results

@talissoncosta
talissoncosta marked this pull request as draft July 22, 2026 12:27
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.3 seconds
commit  5b2b240
info  🔄 Run: #18627 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.8 seconds
commit  5b2b240
info  🔄 Run: #18627 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 2 suites
duration  11.5 seconds
commit  5b2b240
info  🔄 Run: #18627 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  37.4 seconds
commit  5b2b240
info  🔄 Run: #18627 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

talissoncosta and others added 2 commits July 22, 2026 09:35
Review (Kyle on #8023): the diff should use the same palette as the code
theme. Prism tokens now map to the --color-code-* tokens the way
highlight.js maps the same concepts, and the row/word tints use the
surface tokens, so the diff follows light/dark with no .dark override.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Base automatically changed from refactor/hljs-theme-adaptive to main July 22, 2026 18:40
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 refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant