Skip to content
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

fix(component-tokens): only emit static values in emit-component-tokens #7801

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/components/src/globals/scss/_component-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ $enable-css-custom-properties: feature-flag-enabled(
/// @example get-token-value($component-tokens, 'tag-background-red');
/// @returns {String} Token value
/// @group component-tokens
@function get-token-value($tokens, $name) {
@function get-token-value($tokens, $name, $force-static-values: false) {
$emit-as-css-custom-property: $force-static-values == false and
feature-flag-enabled('enable-css-custom-properties');

@if map-has-key($tokens, $name) {
$config: map-get($tokens, $name);
$fallback: map-get($config, 'fallback');
Expand All @@ -33,15 +36,15 @@ $enable-css-custom-properties: feature-flag-enabled(
$value: map-get($option, 'value');

@return if(
feature-flag-enabled('enable-css-custom-properties'),
$emit-as-css-custom-property,
var(--#{$custom-property-prefix}-#{$name}, #{$value}),
$value
);
}
}

@return if(
feature-flag-enabled('enable-css-custom-properties'),
$emit-as-css-custom-property,
var(--#{$custom-property-prefix}-#{$name}, #{$fallback}),
$fallback
);
Expand Down Expand Up @@ -73,6 +76,6 @@ $enable-css-custom-properties: feature-flag-enabled(
/// @example @include emit-component-tokens($component-tokens);
@mixin emit-component-tokens($tokens) {
@each $key, $options in $tokens {
@include custom-property($key, get-token-value($tokens, $key));
@include custom-property($key, get-token-value($tokens, $key, true));
}
}