Skip to content

Commit

Permalink
fix(tokens): bugs with component values() functions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 528870337
  • Loading branch information
asyncLiz authored and copybara-github committed May 2, 2023
1 parent c32cf1f commit beb5f81
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 116 deletions.
6 changes: 4 additions & 2 deletions list/lib/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
$tokens: theme.validate-theme(tokens.md-comp-list-values(), $tokens);

@each $token, $value in $tokens {
--md-list-#{$token}: #{$value};
@if $value {
--md-list-#{$token}: #{$value};
}
}
}

Expand All @@ -30,7 +32,7 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-list-#{$token}, #{$value});
}

color: unset;
Expand Down
6 changes: 4 additions & 2 deletions list/lib/listitem/_list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
$tokens: theme.validate-theme(tokens.md-comp-list-item-values(), $tokens);

@each $token, $value in $tokens {
--md-list-item-#{$token}: #{$value};
@if $value {
--md-list-item-#{$token}: #{$value};
}
}
}

Expand All @@ -29,7 +31,7 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-list-item-#{$token}, #{$value});
}
}

Expand Down
6 changes: 4 additions & 2 deletions menu/lib/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
$tokens: theme.validate-theme(tokens.md-comp-menu-values(), $tokens);

@each $token, $value in $tokens {
--md-menu-#{$token}: #{$value};
@if $value {
--md-menu-#{$token}: #{$value};
}
}
}

Expand All @@ -30,7 +32,7 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-menu-#{$token}, #{$value});
}

@include md-list.theme(
Expand Down
6 changes: 4 additions & 2 deletions menu/lib/menuitem/_menu-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
$tokens: theme.validate-theme(tokens.md-comp-menu-item-values(), $tokens);

@each $token, $value in $tokens {
--md-menu-item-#{$token}: #{$value};
@if $value {
--md-menu-item-#{$token}: #{$value};
}
}
}

Expand All @@ -28,7 +30,7 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-menu-item-#{$token}, #{$value});
}

@include list-item.theme(
Expand Down
27 changes: 0 additions & 27 deletions tokens/_md-comp-list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,5 @@ $supported-tokens: (
$new-tokens: get-new-tokens($deps, $exclude-hardcoded-values)
);

@each $token, $value in $tokens {
$tokens: map.set($tokens, $token, var(--md-list-item-#{$token}, #{$value}));
}

@return $tokens;
}

// TODO(b/276957188): Remove this when we resolve issues with values fn.
@function theme-values($deps: $_default, $exclude-hardcoded-values: false) {
$original-tokens: md-comp-list.values($deps, $exclude-hardcoded-values);
$original-tokens: map.merge($original-tokens, get-override-tokens($deps));

$tokens: values.validate(
md-comp-list.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$new-tokens: get-new-tokens($deps, $exclude-hardcoded-values)
);

@each $token, $value in $tokens {
@if $value {
$tokens: map.set($tokens, $token, #{$value});
} @else {
$tokens: map.remove($tokens, $token);
}
}

@return $tokens;
}
32 changes: 3 additions & 29 deletions tokens/_md-comp-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,41 +116,15 @@ $unsupported-tokens: (
// go/keep-sorted end
);

$renamed-tokens: (
'list-item-container-color': 'container-color',
);

@function values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: values.validate(
md-comp-list.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$renamed-tokens: $renamed-tokens
$renamed-tokens: (
'list-item-container-color': 'container-color',
)
);

@each $token, $value in $tokens {
$tokens: map.set($tokens, $token, var(--md-list-#{$token}, #{$value}));
}

@return $tokens;
}

// TODO(b/276957188): Remove this when we resolve issues with values fn.
@function theme-values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: values.validate(
md-comp-list.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$renamed-tokens: $renamed-tokens
);

@each $token, $value in $tokens {
@if $value {
$tokens: map.set($tokens, $token, #{$value});
} @else {
$tokens: map.remove($tokens, $token);
}
}

@return $tokens;
}
32 changes: 3 additions & 29 deletions tokens/_md-comp-menu-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,15 @@ $supported-tokens: (
// go/keep-sorted end
);

$renamed-tokens: (
'container-color': 'list-item-container-color',
);

@function values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: values.validate(
md-comp-menu.values($deps),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$renamed-tokens: $renamed-tokens
$renamed-tokens: (
'container-color': 'list-item-container-color',
)
);

@each $token, $value in $tokens {
$tokens: map.set($tokens, $token, var(--md-menu-item-#{$token}, #{$value}));
}

@return $tokens;
}

// TODO(b/276957188): Remove this when we resolve issues with values fn.
@function theme-values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: values.validate(
md-comp-menu.values($deps),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$renamed-tokens: $renamed-tokens
);

@each $token, $value in $tokens {
@if $value {
$tokens: map.set($tokens, $token, #{$value});
} @else {
$tokens: map.remove($tokens, $token);
}
}

@return $tokens;
}
23 changes: 0 additions & 23 deletions tokens/_md-comp-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,5 @@ $supported-tokens: (
$unsupported-tokens: $unsupported-tokens
);

@each $token, $value in $tokens {
$tokens: map.set($tokens, $token, var(--md-menu-#{$token}, #{$value}));
}

@return $tokens;
}

// TODO(b/276957188): Remove this when we resolve issues with values fn.
@function theme-values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: values.validate(
md-comp-menu.values($deps),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens
);

@each $token, $value in $tokens {
@if $value {
$tokens: map.set($tokens, $token, #{$value});
} @else {
$tokens: map.remove($tokens, $token);
}
}

@return $tokens;
}

0 comments on commit beb5f81

Please sign in to comment.