WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@jkuelz
Copy link
Member

@jkuelz jkuelz commented Nov 4, 2025

Description of changes:
Adds a property to the internal theme builder that uses CSS variables instead of resolved values for better runtime theme swapping. This is part 2 of a series for theming improvements.

In an attempt to not generate duplicated CSS, the current theming setup only overrides tokens that have a different resolved value. That works ok for now, where you can only theme a handful of tokens. But with the introduction of reference tokens, essentially every token can be themed (300+), and would have a different resolved value. Rather than regenerating all 300+ tokens for the wholistic theming that reference tokens provide, this flag makes it so that only the reference tokens (~30) need to be sent, and the rest can be cascade via native CSS variable inheritance.

Next up:

  • Seed token API
  • Color palette generation utilities

Previous improvements:

  • Extend ThemeBuilder with reference token processing

[ac9YAbqsd7e6]

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jkuelz jkuelz changed the title Jkuelz preserve css vars @jkuelz feat: Add property for preserving css variables in token resolution Nov 4, 2025
@jkuelz jkuelz changed the title @jkuelz feat: Add property for preserving css variables in token resolution feat: Add property for preserving css variables in token resolution Nov 4, 2025
@jkuelz jkuelz force-pushed the jkuelz-preserve-css-vars branch from 8768a62 to d1b1682 Compare November 4, 2025 22:06
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 99.07834% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.49%. Comparing base (d6bd388) to head (ec53fc6).

Files with missing lines Patch % Lines
src/shared/theme/utils.ts 94.28% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
+ Coverage   97.43%   98.49%   +1.05%     
==========================================
  Files          45       46       +1     
  Lines        2186     2326     +140     
  Branches      417      451      +34     
==========================================
+ Hits         2130     2291     +161     
+ Misses         56       35      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@jkuelz jkuelz force-pushed the jkuelz-preserve-css-vars branch from d1b1682 to 7890c73 Compare November 5, 2025 00:54
@jkuelz jkuelz marked this pull request as ready for review November 5, 2025 01:28
@jkuelz jkuelz requested a review from a team as a code owner November 5, 2025 01:28
@jkuelz jkuelz requested review from a team, Harsh-Anand-Singh and avinashbot and removed request for a team and Harsh-Anand-Singh November 5, 2025 01:28
return defaults;
}

export function generateReferenceTokenName(colorName: string, step: string): string {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps generateReferenceColorTokenName? Or have an argument specifically for "type"? Your tech doc seems to allow for other kinds of reference tokens like border radiuses or spacing, but this PR assumes only color in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right on both parts. It will eventually support more than color, but this PR only focuses on adding color. I made them more generic though since we'd have to do that eventually anyway.

@jkuelz jkuelz requested a review from avinashbot November 7, 2025 16:13
jkuelz added a commit that referenced this pull request Dec 3, 2025
feat: Add property for preserving css variables in token resolution

chore: Enable useCssVars for testing

chore: Add useCssVars support to runtime theming

refactor: Make reference helpers more generic than just colors for future
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants