Skip to content

Commit 635edaf

Browse files
authored
fix(tokens): color classes generation from tokens (#30725)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> This pull request makes a minor update to the `generateColorUtilityClasses` function to improve how CSS custom property values are interpolated in the generated class definitions. * In `core/scripts/tokens/utils.mjs`, the function now wraps the SCSS variable reference for the custom property value in `#{...}` to ensure proper interpolation when generating the CSS class. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 9a1d3ca commit 635edaf

File tree

2 files changed

+450
-450
lines changed

2 files changed

+450
-450
lines changed

core/scripts/tokens/utils.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export function generateColorUtilityClasses(prop, className) {
151151
const isBg = className.includes('bg');
152152
const cssProp = isBg ? 'background-color' : 'color';
153153
return `.${classAndScssPrefix}-${className} {
154-
--${cssProp}: $${classAndScssPrefix}-${prop.name};
154+
--${cssProp}: #{$${classAndScssPrefix}-${prop.name}};
155155
${cssProp}: $${classAndScssPrefix}-${prop.name};
156156
}`;
157157
}
@@ -275,7 +275,7 @@ export function generateSpaceUtilityClasses(prop, className) {
275275
// Generates a valid box-shadow value from a shadow Design Token structure
276276
export function generateRadiusUtilityClasses(propName) {
277277
return `.${classAndScssPrefix}-${propName} {
278-
--border-radius: $${classAndScssPrefix}-${propName};
278+
--border-radius: #{$${classAndScssPrefix}-${propName}};
279279
border-radius: $${classAndScssPrefix}-${propName};
280280
}`;
281281
}
@@ -296,7 +296,7 @@ export function generateBorderUtilityClasses(prop, propName) {
296296
attribute = 'border-color';
297297
}
298298
return `.${classAndScssPrefix}-${propName} {
299-
--${attribute}: $${classAndScssPrefix}-${propName};
299+
--${attribute}: #{$${classAndScssPrefix}-${propName}};
300300
${attribute}: $${classAndScssPrefix}-${propName};
301301
}`;
302302
}
@@ -309,7 +309,7 @@ export function generateFontUtilityClasses(prop, propName) {
309309
// Generates a valid box-shadow value from a shadow Design Token structure
310310
export function generateShadowUtilityClasses(propName) {
311311
return `.${classAndScssPrefix}-${propName} {
312-
--box-shadow: $${classAndScssPrefix}-${propName};
312+
--box-shadow: #{$${classAndScssPrefix}-${propName}};
313313
box-shadow: $${classAndScssPrefix}-${propName};
314314
}`;
315315
}

0 commit comments

Comments
 (0)