Skip to content

Commit 4f05c42

Browse files
fix(component-tokens): only emit static values in emit-component-tokens (#7801)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 1de98d0 commit 4f05c42

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/components/src/globals/scss/_component-tokens.scss

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ $enable-css-custom-properties: feature-flag-enabled(
2020
/// @example get-token-value($component-tokens, 'tag-background-red');
2121
/// @returns {String} Token value
2222
/// @group component-tokens
23-
@function get-token-value($tokens, $name) {
23+
@function get-token-value($tokens, $name, $force-static-values: false) {
24+
$emit-as-css-custom-property: $force-static-values == false and
25+
feature-flag-enabled('enable-css-custom-properties');
26+
2427
@if map-has-key($tokens, $name) {
2528
$config: map-get($tokens, $name);
2629
$fallback: map-get($config, 'fallback');
@@ -33,15 +36,15 @@ $enable-css-custom-properties: feature-flag-enabled(
3336
$value: map-get($option, 'value');
3437

3538
@return if(
36-
feature-flag-enabled('enable-css-custom-properties'),
39+
$emit-as-css-custom-property,
3740
var(--#{$custom-property-prefix}-#{$name}, #{$value}),
3841
$value
3942
);
4043
}
4144
}
4245

4346
@return if(
44-
feature-flag-enabled('enable-css-custom-properties'),
47+
$emit-as-css-custom-property,
4548
var(--#{$custom-property-prefix}-#{$name}, #{$fallback}),
4649
$fallback
4750
);
@@ -73,6 +76,6 @@ $enable-css-custom-properties: feature-flag-enabled(
7376
/// @example @include emit-component-tokens($component-tokens);
7477
@mixin emit-component-tokens($tokens) {
7578
@each $key, $options in $tokens {
76-
@include custom-property($key, get-token-value($tokens, $key));
79+
@include custom-property($key, get-token-value($tokens, $key, true));
7780
}
7881
}

0 commit comments

Comments
 (0)