-
-
Notifications
You must be signed in to change notification settings - Fork 210
Fix font size token export and rem value conversion for different typography baselines across themes #3638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix font size token export and rem value conversion for different typography baselines across themes #3638
Changes from 11 commits
9607079
d1a119b
90d4a18
368d79d
eed2c63
a67673d
6667ea4
459d58d
4e9f568
b6f4311
eb7efa5
efd15e9
378e72a
bea191e
3627670
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@tokens-studio/figma-plugin": patch | ||
| --- | ||
|
|
||
| Enhanced UI display for rem values to show pixel equivalents based on current theme baseline font size. Token tooltips and inspector now display rem values as "1rem (16px)" format. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@tokens-studio/figma-plugin": patch | ||
| --- | ||
|
|
||
| Fix font size token export for different typography baselines across themes | ||
|
|
||
| When exporting tokens with expandTypography enabled, composite tokens (like typography tokens) now correctly use resolved values from the provided resolvedTokens array instead of the original unresolved token values. This ensures that font size tokens and other properties within typography tokens reflect the correct baseline values for each theme when tokens are resolved per theme. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@tokens-studio/figma-plugin": patch | ||
| --- | ||
|
|
||
| Fixed multi-theme variable export to use correct base font size per theme for rem conversion. Previously, when exporting multiple themes simultaneously, all themes would use the base font size from the currently active theme due to shared TokenResolver state. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,26 +2,32 @@ import { TokenSetStatus } from '@/constants/TokenSetStatus'; | |
| import { tokenTypesToCreateVariable } from '@/constants/VariableTypes'; | ||
| import { ThemeObject, UsedTokenSetsMap } from '@/types'; | ||
| import { AnyTokenList } from '@/types/tokens'; | ||
| import { defaultTokenResolver } from '@/utils/TokenResolver'; | ||
| import { mergeTokenGroups } from '@/utils/tokenHelpers'; | ||
| import { TokenResolver } from '@/utils/TokenResolver'; | ||
| import { mergeTokenGroups, ResolveTokenValuesResult } from '@/utils/tokenHelpers'; | ||
|
|
||
| export function generateTokensToCreate({ | ||
| theme, | ||
| tokens, | ||
| filterByTokenSet, | ||
| overallConfig = {}, | ||
| themeTokenResolver, | ||
| }: { | ||
| theme: ThemeObject; | ||
| tokens: Record<string, AnyTokenList>; | ||
| filterByTokenSet?: string; | ||
| overallConfig?: UsedTokenSetsMap; | ||
| }) { | ||
| themeTokenResolver?: TokenResolver; | ||
| }): { tokensToCreate: ResolveTokenValuesResult[]; resolvedTokens: ResolveTokenValuesResult[] } { | ||
| // Big O(resolveTokenValues * mergeTokenGroups) | ||
| const enabledTokenSets = Object.entries(theme.selectedTokenSets) | ||
| .filter(([name, status]) => status === TokenSetStatus.ENABLED && (!filterByTokenSet || name === filterByTokenSet)) | ||
| .map(([tokenSet]) => tokenSet); | ||
| const resolved = defaultTokenResolver.setTokens(mergeTokenGroups(tokens, theme.selectedTokenSets, overallConfig)); | ||
| return resolved.filter( | ||
| // Create a separate TokenResolver instance for this theme to avoid interference | ||
| // when multiple themes are processed concurrently (if not provided) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have a different PR where we remove the concurrent creation as its leading to memory issues - lets not adjust it in this PR then? #3561 just need to fix the tests there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unless its absolutely required for your PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot respond to this comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My changes to If PR #3561 removes concurrent processing, my changes won't conflict - they'll simply ensure each theme has its own resolver instance (even if processed sequentially). The fix is still valuable for correctness, though less critical without concurrency. The changes are minimal and won't interfere with removing |
||
| const resolver = themeTokenResolver || new TokenResolver([]); | ||
| const resolved = resolver.setTokens(mergeTokenGroups(tokens, theme.selectedTokenSets, overallConfig)); | ||
| const tokensToCreate = resolved.filter( | ||
| (token) => ((!token.internal__Parent || enabledTokenSets.includes(token.internal__Parent)) && tokenTypesToCreateVariable.includes(token.type)), // filter out SOURCE tokens | ||
| ); | ||
| return { tokensToCreate, resolvedTokens: resolved }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.