Skip to content

Commit

Permalink
fix(dialog)!: remove with-icon prefix from with-icon-icon-color and w…
Browse files Browse the repository at this point in the history
…ith-icon-icon-size

PiperOrigin-RevId: 546360441
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Jul 7, 2023
1 parent 2922914 commit 1893e08
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 30 deletions.
4 changes: 2 additions & 2 deletions dialog/lib/_dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@
// Slot styling
[name='headline-prefix']::slotted(*),
[name='headline-suffix']::slotted(*) {
color: var(--_with-icon-icon-color);
font-size: var(--_with-icon-icon-size);
color: var(--_icon-color);
font-size: var(--_icon-size);
}

[name='header']::slotted(*) {
Expand Down
27 changes: 5 additions & 22 deletions dialog/lib/_tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,12 @@ $_fullscreen-tokens: (
fullscreen-container-block-padding: 8px,
);

@function _map-without-keys-with-prefix($map, $prefix) {
$filtered: ();
@each $prop, $value in $map {
@if not string-ext.has-prefix($prop, $prefix) {
$filtered: map.set($filtered, $prop, $value);
}
}
@return $filtered;
}

@function remove-unsupported-tokens($tokens) {
$remove-prefix: 'action-';
$tokens: _map-without-keys-with-prefix($tokens, $remove-prefix);

@return $tokens;
}

/**
* Extended token set for dialog. Note, currently ignoring tokens for
* `action-*-label-text` and `action-*-state-layer` since actions are
* spec'd as standard text buttons.
* Extended token set for dialog.
*/
@function md-comp-dialog-values() {
$tokens: remove-unsupported-tokens(tokens.md-comp-dialog-values());
@return map.merge(map.merge($tokens, $_tokens), $_fullscreen-tokens);
@return map.merge(
map.merge(tokens.md-comp-dialog-values(), $_tokens),
$_fullscreen-tokens
);
}
54 changes: 48 additions & 6 deletions tokens/_md-comp-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@
@use './md-sys-state';
@use './md-sys-typescale';
@use './v0_172/md-comp-dialog';
@use './values';
// go/keep-sorted end

$supported-tokens: (
// go/keep-sorted start
'container-color',
'container-elevation',
'container-shape',
'headline-color',
'headline-type',
'icon-color',
'icon-size',
'supporting-text-color',
'supporting-text-type',
// go/keep-sorted end
);

$_default: (
'md-sys-color': md-sys-color.values-light(),
'md-sys-elevation': md-sys-elevation.values(),
Expand All @@ -23,7 +38,26 @@ $_default: (
'md-sys-typescale': md-sys-typescale.values(),
);

$_unsupported-tokens: (
// Note: currently ignoring tokens for `action-*-label-text` and
// `action-*-state-layer` since actions are spec'd as standard text buttons.
$unsupported-tokens: (
// go/keep-sorted start
'action-focus-label-text-color',
'action-focus-state-layer-color',
'action-focus-state-layer-opacity',
'action-hover-label-text-color',
'action-hover-state-layer-color',
'action-hover-state-layer-opacity',
'action-label-text-color',
'action-label-text-font',
'action-label-text-line-height',
'action-label-text-size',
'action-label-text-tracking',
'action-label-text-type',
'action-label-text-weight',
'action-pressed-label-text-color',
'action-pressed-state-layer-color',
'action-pressed-state-layer-opacity',
'headline-font',
'headline-line-height',
'headline-size',
Expand All @@ -33,18 +67,26 @@ $_unsupported-tokens: (
'supporting-text-line-height',
'supporting-text-size',
'supporting-text-tracking',
'supporting-text-weight'
'supporting-text-weight',
// go/keep-sorted end
);

@function values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: md-comp-dialog.values($deps, $exclude-hardcoded-values);
$tokens: map.remove($tokens, $_unsupported-tokens...);
$tokens: values.validate(
md-comp-dialog.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $unsupported-tokens,
$renamed-tokens: (
// Remove "with-*" prefixes (b/273534858)
'with-icon-icon-color': 'icon-color',
'with-icon-icon-size': 'icon-size'
)
);

// TODO(b/271876162): remove when tokens compiler emits typescale tokens
$tokens: map.merge(
$tokens,
(
'action-label-text-type':
map.get($deps, 'md-sys-typescale', 'label-large'),
'headline-type': map.get($deps, 'md-sys-typescale', 'headline-small'),
)
);
Expand Down

0 comments on commit 1893e08

Please sign in to comment.