diff --git a/list/lib/_list.scss b/list/lib/_list.scss index b2d16b8708..679e3e8388 100644 --- a/list/lib/_list.scss +++ b/list/lib/_list.scss @@ -18,18 +18,15 @@ // go/keep-sorted end @mixin theme($tokens) { - $reference: tokens.md-comp-list-values(); - $reference: resolve-tokens($reference); - $tokens: resolve-tokens($tokens); - $tokens: theme.validate-theme($reference, $tokens); - $tokens: theme.create-theme-vars($tokens, list); + $tokens: theme.validate-theme(tokens.md-comp-list-values(), $tokens); - @include theme.emit-theme-vars($tokens); + @each $token, $value in $tokens { + --md-list-#{$token}: #{$value}; + } } @mixin styles() { - $tokens: resolve-tokens(tokens.md-comp-list-values()); - $tokens: theme.create-theme-vars($tokens, list); + $tokens: tokens.md-comp-list-values(); :host { @each $token, $value in $tokens { @@ -42,6 +39,7 @@ .md3-list { background-color: var(--_container-color); + border-radius: inherit; display: block; list-style-type: none; margin: 0; @@ -53,44 +51,3 @@ position: relative; } } - -/// Resolves the tokens that are specific to list. -/// -/// The tokenset for list include list plus all of list item. We do not want to -/// duplicate tokens and custom properties across md-list and md-list-item. -/// So here we resolve list-items tokens, and resolve the difference between -/// the full set of tokens and the ones specific to list-item. -@function resolve-tokens($tokens) { - // Accept container-color token in the theme() mixin. - $container-color: map.get($tokens, container-color); - - @if not $container-color { - // If not defined, rename the list-item-container-color token. This is - // useful for our styles() mixin where we simply feed this function the comp - // tokens from the compiler and no `container-color` token. - $container-color: map.get($tokens, list-item-container-color); - $tokens: map.set($tokens, container-color, $container-color); - } - - $list-tokens: remove-unused-tokens($tokens); - - @return $list-tokens; -} - -// removes unused tokens -@function remove-unused-tokens($tokens) { - $unused-tokens: (); - @each $token in map-keys($tokens) { - $index: string.index($token, 'list-item'); - - @if $index { - $unused-tokens: list.append($unused-tokens, $token); - } - } - - @each $token in $unused-tokens { - $tokens: map.remove($tokens, $token); - } - - @return $tokens; -} diff --git a/list/lib/listitem/_list-item.scss b/list/lib/listitem/_list-item.scss index b2593626dd..384542cbf1 100644 --- a/list/lib/listitem/_list-item.scss +++ b/list/lib/listitem/_list-item.scss @@ -17,18 +17,15 @@ // go/keep-sorted end @mixin theme($tokens) { - $tokens: theme.validate-theme( - resolve-tokens(tokens.md-comp-list-values()), - resolve-tokens($tokens) - ); - $tokens: theme.create-theme-vars($tokens, 'list'); + $tokens: theme.validate-theme(tokens.md-comp-list-item-values(), $tokens); - @include theme.emit-theme-vars($tokens); + @each $token, $value in $tokens { + --md-list-item-#{$token}: #{$value}; + } } @mixin styles() { - $tokens: resolve-tokens(tokens.md-comp-list-values()); - $tokens: theme.create-theme-vars($tokens, 'list'); + $tokens: tokens.md-comp-list-item-values(); :host { @each $token, $value in $tokens { @@ -417,64 +414,3 @@ height: var(--_list-item-large-leading-video-height); } } - -/// Resolves the tokens that are specific to list-item. -/// -/// The tokenset for list include list plus all of list item. We do not want to -/// duplicate tokens and custom properties across md-list and md-list-item. -/// So here we resolve list-items tokens by selecting only tokens that have -/// 'list-item' in its name. -@function resolve-tokens($tokens) { - // Values pulled from b/198759625 spreadsheet - $list-item-tokens: ( - 'list-item-leading-space': 16px, - 'list-item-trailing-space': 16px, - 'list-item-leading-element-leading-space': 16px, - 'list-item-leading-video-leading-space': 0px, - // Commented out until the comments in the spreadsheet linked above are - // resolved regarding vertical alignment. - // 'list-item-leading-item-top-space': 8px, - // 'list-item-leading-video-top-space': 0px, - // 'list-item-leading-item-bottom-space': 8px, - // 'list-item-leading-video-bottom-space': 0px, - 'list-item-trailing-element-headline-trailing-element-space': 16px, - ); - - @each $token, $value in $tokens { - $index: string.index($token, 'list-item'); - - @if $index { - $list-item-tokens: map.set($list-item-tokens, $token, $value); - } - } - - $list-item-tokens: _remove-unused-tokens($list-item-tokens); - - @return $list-item-tokens; -} - -// removes unused tokens -@function _remove-unused-tokens($tokens) { - $unused-tokens: ( - 'list-item-container-elevation', - 'list-item-disabled-state-layer-color', - 'list-item-disabled-state-layer-opacity', - 'list-item-dragged-container-elevation', - 'list-item-dragged-label-text-color', - 'list-item-dragged-leading-icon-icon-color', - 'list-item-dragged-state-layer-color', - 'list-item-dragged-state-layer-opacity', - 'list-item-dragged-trailing-icon-icon-color', - 'list-item-overline-color', - 'list-item-overline-type', - 'list-item-selected-trailing-icon', - 'list-item-selected-trailing-icon-color', - 'list-item-unselected-trailing-icon-color' - ); - - @each $token in $unused-tokens { - $tokens: map.remove($tokens, $token); - } - - @return $tokens; -} diff --git a/menu/lib/_menu.scss b/menu/lib/_menu.scss index ed0083e597..e3d4ed628d 100644 --- a/menu/lib/_menu.scss +++ b/menu/lib/_menu.scss @@ -17,20 +17,16 @@ @use '../../tokens'; // go/keep-sorted end -$_custom-property-prefix: 'menu'; +@mixin theme($tokens) { + $tokens: theme.validate-theme(tokens.md-comp-menu-values(), $tokens); -@mixin theme($theme) { - $theme: theme.validate-theme(tokens.md-comp-menu-values(), $theme); - $theme: _resolve-tokens($theme); - $theme: theme.create-theme-vars($theme, $_custom-property-prefix); - - @include theme.emit-theme-vars($theme); + @each $token, $value in $tokens { + --md-menu-#{$token}: #{$value}; + } } @mixin styles() { $tokens: tokens.md-comp-menu-values(); - $tokens: _resolve-tokens($tokens); - $tokens: theme.create-theme-vars($tokens, $_custom-property-prefix); :host { @each $token, $value in $tokens { @@ -39,7 +35,7 @@ $_custom-property-prefix: 'menu'; @include md-list.theme( ( - 'list-item-container-color': var(--_container-color), + 'container-color': var(--_container-color), ) ); @@ -103,21 +99,3 @@ $_custom-property-prefix: 'menu'; } } } - -@function _resolve-tokens($tokens) { - // removes unused tokens - $unused-tokens: (); - @each $token in map-keys($tokens) { - $index: string.index($token, 'list-item'); - - @if $index { - $unused-tokens: list.append($unused-tokens, $token); - } - } - - @each $token in $unused-tokens { - $tokens: map.remove($tokens, $token); - } - - @return $tokens; -} diff --git a/menu/lib/menu.ts b/menu/lib/menu.ts index 68bcfdabfb..e5e8cf325b 100644 --- a/menu/lib/menu.ts +++ b/menu/lib/menu.ts @@ -256,8 +256,8 @@ export abstract class Menu extends LitElement { class="menu ${classMap(this.getSurfaceClasses())}" style=${styleMap(this.menuPositionController.surfaceStyles)} @focusout=${this.handleFocusout}> - ${this.renderList()} ${this.renderElevation()} + ${this.renderList()} ${this.renderFocusRing()} `; diff --git a/menu/lib/menuitem/_menu-item.scss b/menu/lib/menuitem/_menu-item.scss index 03a37ecb6c..5f185d05bd 100644 --- a/menu/lib/menuitem/_menu-item.scss +++ b/menu/lib/menuitem/_menu-item.scss @@ -9,30 +9,33 @@ @use 'sass:string'; // go/keep-sorted end // go/keep-sorted start +@use '../../../list/list-item'; @use '../../../ripple/ripple'; @use '../../../sass/theme'; @use '../../../tokens'; // go/keep-sorted end -$_custom-property-prefix: 'menu'; +@mixin theme($tokens) { + $tokens: theme.validate-theme(tokens.md-comp-menu-item-values(), $tokens); -@mixin theme($theme) { - $theme: theme.validate-theme(tokens.md-comp-menu-values(), $theme); - $theme: _resolve-tokens($theme); - $theme: theme.create-theme-vars($theme, $_custom-property-prefix); - - @include theme.emit-theme-vars($theme); + @each $token, $value in $tokens { + --md-menu-item-#{$token}: #{$value}; + } } @mixin styles() { - $tokens: tokens.md-comp-menu-values(); - $tokens: _resolve-tokens($tokens); - $tokens: theme.create-theme-vars($tokens, $_custom-property-prefix); + $tokens: tokens.md-comp-menu-item-values(); :host { @each $token, $value in $tokens { --_#{$token}: #{$value}; } + + @include list-item.theme( + ( + 'list-item-container-color': var(--_list-item-container-color), + ) + ); } .list-item { @@ -53,25 +56,3 @@ $_custom-property-prefix: 'menu'; ); } } - -@function _resolve-tokens($tokens) { - @return _remove-unused-tokens($tokens); -} - -// removes unused tokens -@function _remove-unused-tokens($tokens) { - $unused-tokens: (); - @each $token in map-keys($tokens) { - $index: string.index($token, 'list-item'); - - @if not $index { - $unused-tokens: list.append($unused-tokens, $token); - } - } - - @each $token in $unused-tokens { - $tokens: map.remove($tokens, $token); - } - - @return $tokens; -} diff --git a/tokens/_index.scss b/tokens/_index.scss index 6fd1d5305a..9f044e5153 100644 --- a/tokens/_index.scss +++ b/tokens/_index.scss @@ -58,7 +58,9 @@ @forward './md-comp-linear-progress-indicator' as md-comp-linear-progress-indicator-*; @forward './md-comp-list' as md-comp-list-*; +@forward './md-comp-list-item' as md-comp-list-item-*; @forward './md-comp-menu' as md-comp-menu-*; +@forward './md-comp-menu-item' as md-comp-menu-item-*; @forward './md-comp-navigation-bar' as md-comp-navigation-bar-*; @forward './md-comp-navigation-drawer' as md-comp-navigation-drawer-*; @forward './md-comp-navigation-rail' as md-comp-navigation-rail-*; diff --git a/tokens/_md-comp-list-item.scss b/tokens/_md-comp-list-item.scss new file mode 100644 index 0000000000..ce98d31294 --- /dev/null +++ b/tokens/_md-comp-list-item.scss @@ -0,0 +1,201 @@ +// +// Copyright 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 +// + +// go/keep-sorted start +@use 'sass:map'; +// go/keep-sorted end +// go/keep-sorted start +@use './md-sys-color'; +@use './md-sys-elevation'; +@use './md-sys-shape'; +@use './md-sys-state'; +@use './md-sys-typescale'; +@use './v0_172/md-comp-list'; +@use './values'; +// go/keep-sorted end + +$_default: ( + 'md-sys-color': md-sys-color.values-light(), + 'md-sys-elevation': md-sys-elevation.values(), + 'md-sys-shape': md-sys-shape.values(), + 'md-sys-state': md-sys-state.values(), + 'md-sys-typescale': md-sys-typescale.values(), +); + +$unsupported-tokens: ( + // go/keep-sorted start + 'list-item-container-elevation', + 'list-item-disabled-state-layer-color', + 'list-item-disabled-state-layer-opacity', + 'list-item-dragged-container-elevation', + 'list-item-dragged-label-text-color', + 'list-item-dragged-leading-icon-icon-color', + 'list-item-dragged-state-layer-color', + 'list-item-dragged-state-layer-opacity', + 'list-item-dragged-trailing-icon-icon-color', + 'list-item-label-text-font', + 'list-item-label-text-size', + 'list-item-label-text-tracking', + 'list-item-label-text-weight', + 'list-item-leading-avatar-label-font', + 'list-item-leading-avatar-label-line-height', + 'list-item-leading-avatar-label-size', + 'list-item-leading-avatar-label-tracking', + 'list-item-leading-avatar-label-weight', + 'list-item-overline-color', + 'list-item-overline-font', + 'list-item-overline-line-height', + 'list-item-overline-size', + 'list-item-overline-tracking', + 'list-item-overline-type', + 'list-item-overline-weight', + 'list-item-selected-trailing-icon-color', + 'list-item-supporting-text-font', + 'list-item-supporting-text-line-height', + 'list-item-supporting-text-size', + 'list-item-supporting-text-tracking', + 'list-item-supporting-text-weight', + 'list-item-trailing-supporting-text-font', + 'list-item-trailing-supporting-text-size', + 'list-item-trailing-supporting-text-tracking', + 'list-item-trailing-supporting-text-weight', + 'list-item-unselected-trailing-icon-color', + // go/keep-sorted end +); + +$supported-tokens: ( + // go/keep-sorted start + 'list-item-container-color', + 'list-item-container-shape', + 'list-item-disabled-label-text-color', + 'list-item-disabled-label-text-opacity', + 'list-item-disabled-leading-icon-color', + 'list-item-disabled-leading-icon-opacity', + 'list-item-disabled-trailing-icon-color', + 'list-item-disabled-trailing-icon-opacity', + 'list-item-focus-label-text-color', + 'list-item-focus-leading-icon-icon-color', + 'list-item-focus-state-layer-color', + 'list-item-focus-state-layer-opacity', + 'list-item-focus-trailing-icon-icon-color', + 'list-item-hover-label-text-color', + 'list-item-hover-leading-icon-icon-color', + 'list-item-hover-state-layer-color', + 'list-item-hover-state-layer-opacity', + 'list-item-hover-trailing-icon-icon-color', + 'list-item-label-text-color', + 'list-item-label-text-line-height', + 'list-item-label-text-type', + 'list-item-large-leading-video-height', + 'list-item-leading-avatar-color', + 'list-item-leading-avatar-label-color', + 'list-item-leading-avatar-label-type', + 'list-item-leading-avatar-shape', + 'list-item-leading-avatar-size', + 'list-item-leading-icon-color', + 'list-item-leading-icon-size', + 'list-item-leading-image-height', + 'list-item-leading-image-shape', + 'list-item-leading-image-width', + 'list-item-leading-video-shape', + 'list-item-leading-video-width', + 'list-item-one-line-container-height', + 'list-item-pressed-label-text-color', + 'list-item-pressed-leading-icon-icon-color', + 'list-item-pressed-state-layer-color', + 'list-item-pressed-state-layer-opacity', + 'list-item-pressed-trailing-icon-icon-color', + 'list-item-small-leading-video-height', + 'list-item-supporting-text-color', + 'list-item-supporting-text-type', + 'list-item-three-line-container-height', + 'list-item-trailing-icon-color', + 'list-item-trailing-icon-size', + 'list-item-trailing-supporting-text-color', + 'list-item-trailing-supporting-text-line-height', + 'list-item-trailing-supporting-text-type', + 'list-item-two-line-container-height', + // go/keep-sorted end +); + +@function get-new-tokens($deps, $exclude-hardcoded-values) { + // Values pulled from b/198759625 spreadsheet + @return ( + // go/keep-sorted start + 'list-item-leading-element-leading-space': + if($exclude-hardcoded-values, null, 16px), + 'list-item-leading-space': if($exclude-hardcoded-values, null, 16px), + 'list-item-leading-video-leading-space': + if($exclude-hardcoded-values, null, 0px), + // Commented out until the comments in the spreadsheet linked above are + // resolved regarding vertical alignment. + // 'list-item-leading-item-top-space': if($exclude-hardcoded-values, null, 8px), + // 'list-item-leading-video-top-space': if($exclude-hardcoded-values, null, 0px), + // 'list-item-leading-item-bottom-space': if($exclude-hardcoded-values, null, 8px), + // 'list-item-leading-video-bottom-space': if($exclude-hardcoded-values, null, 0px), + 'list-item-trailing-element-headline-trailing-element-space': 16px, + 'list-item-trailing-space': if($exclude-hardcoded-values, null, 16px), + // go/keep-sorted end + ); +} + +@function get-override-tokens($deps) { + // TODO(b/271876162): remove when tokens compiler emits typescale tokens + @return ( + // go/keep-sorted start + 'list-item-label-text-type': + map.get($deps, 'md-sys-typescale', 'body-large'), + 'list-item-leading-avatar-label-type': + map.get($deps, 'md-sys-typescale', 'title-medium'), + // unsupported token + // 'list-item-overline-type': map.get($deps, 'md-sys-typescale', 'label-small'), + 'list-item-supporting-text-type': + map.get($deps, 'md-sys-typescale', 'body-medium'), + 'list-item-trailing-supporting-text-type': + map.get($deps, 'md-sys-typescale', 'label-small'), + // go/keep-sorted end + ); +} + +@function 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( + $original-tokens, + $supported-tokens: $supported-tokens, + $unsupported-tokens: $unsupported-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; +} diff --git a/tokens/_md-comp-list.scss b/tokens/_md-comp-list.scss index 5f1f0019fd..0ab74c8a93 100644 --- a/tokens/_md-comp-list.scss +++ b/tokens/_md-comp-list.scss @@ -13,6 +13,7 @@ @use './md-sys-state'; @use './md-sys-typescale'; @use './v0_172/md-comp-list'; +@use './values'; // go/keep-sorted end $_default: ( @@ -23,53 +24,133 @@ $_default: ( 'md-sys-typescale': md-sys-typescale.values(), ); -$_unsupported-tokens: ( - // Do not remove label-text-line-height since it is needed +$supported-tokens: (); + +$unsupported-tokens: ( + // go/keep-sorted start + 'list-item-container-elevation', + 'list-item-container-shape', + 'list-item-disabled-label-text-color', + 'list-item-disabled-label-text-opacity', + 'list-item-disabled-leading-icon-color', + 'list-item-disabled-leading-icon-opacity', + 'list-item-disabled-state-layer-color', + 'list-item-disabled-state-layer-opacity', + 'list-item-disabled-trailing-icon-color', + 'list-item-disabled-trailing-icon-opacity', + 'list-item-dragged-container-elevation', + 'list-item-dragged-label-text-color', + 'list-item-dragged-leading-icon-icon-color', + 'list-item-dragged-state-layer-color', + 'list-item-dragged-state-layer-opacity', + 'list-item-dragged-trailing-icon-icon-color', + 'list-item-focus-label-text-color', + 'list-item-focus-leading-icon-icon-color', + 'list-item-focus-state-layer-color', + 'list-item-focus-state-layer-opacity', + 'list-item-focus-trailing-icon-icon-color', + 'list-item-hover-label-text-color', + 'list-item-hover-leading-icon-icon-color', + 'list-item-hover-state-layer-color', + 'list-item-hover-state-layer-opacity', + 'list-item-hover-trailing-icon-icon-color', + 'list-item-label-text-color', 'list-item-label-text-font', + 'list-item-label-text-line-height', 'list-item-label-text-size', 'list-item-label-text-tracking', + 'list-item-label-text-type', 'list-item-label-text-weight', + 'list-item-large-leading-video-height', + 'list-item-leading-avatar-color', + 'list-item-leading-avatar-label-color', 'list-item-leading-avatar-label-font', 'list-item-leading-avatar-label-line-height', 'list-item-leading-avatar-label-size', 'list-item-leading-avatar-label-tracking', + 'list-item-leading-avatar-label-type', 'list-item-leading-avatar-label-weight', - 'list-item-supporting-text-font', - 'list-item-supporting-text-line-height', - 'list-item-supporting-text-size', - 'list-item-supporting-text-tracking', - 'list-item-supporting-text-weight', + 'list-item-leading-avatar-shape', + 'list-item-leading-avatar-size', + 'list-item-leading-icon-color', + 'list-item-leading-icon-size', + 'list-item-leading-image-height', + 'list-item-leading-image-shape', + 'list-item-leading-image-width', + 'list-item-leading-video-shape', + 'list-item-leading-video-width', + 'list-item-one-line-container-height', + 'list-item-overline-color', 'list-item-overline-font', 'list-item-overline-line-height', 'list-item-overline-size', 'list-item-overline-tracking', + 'list-item-overline-type', 'list-item-overline-weight', - // Do not remove trailing-supporting-text-line-height since it is needed + 'list-item-pressed-label-text-color', + 'list-item-pressed-leading-icon-icon-color', + 'list-item-pressed-state-layer-color', + 'list-item-pressed-state-layer-opacity', + 'list-item-pressed-trailing-icon-icon-color', + 'list-item-selected-trailing-icon-color', + 'list-item-small-leading-video-height', + 'list-item-supporting-text-color', + 'list-item-supporting-text-font', + 'list-item-supporting-text-line-height', + 'list-item-supporting-text-size', + 'list-item-supporting-text-tracking', + 'list-item-supporting-text-type', + 'list-item-supporting-text-weight', + 'list-item-three-line-container-height', + 'list-item-trailing-icon-color', + 'list-item-trailing-icon-size', + 'list-item-trailing-supporting-text-color', 'list-item-trailing-supporting-text-font', + 'list-item-trailing-supporting-text-line-height', 'list-item-trailing-supporting-text-size', 'list-item-trailing-supporting-text-tracking', - 'list-item-trailing-supporting-text-weight' + 'list-item-trailing-supporting-text-type', + 'list-item-trailing-supporting-text-weight', + 'list-item-two-line-container-height', + 'list-item-unselected-trailing-icon-color', + // go/keep-sorted end +); + +$renamed-tokens: ( + 'list-item-container-color': 'container-color', ); @function values($deps: $_default, $exclude-hardcoded-values: false) { - $tokens: md-comp-list.values($deps, $exclude-hardcoded-values); - $tokens: map.remove($tokens, $_unsupported-tokens...); + $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 { + $tokens: map.set($tokens, $token, var(--md-list-#{$token}, #{$value})); + } - // TODO(b/271876162): remove when tokens compiler emits typescale tokens - $tokens: map.merge( - $tokens, - ( - 'list-item-label-text-type': - map.get($deps, 'md-sys-typescale', 'body-large'), - 'list-item-leading-avatar-label-type': - map.get($deps, 'md-sys-typescale', 'title-medium'), - 'list-item-overline-type': - map.get($deps, 'md-sys-typescale', 'label-small'), - 'list-item-supporting-text-type': - map.get($deps, 'md-sys-typescale', 'body-medium'), - 'list-item-trailing-supporting-text-type': - map.get($deps, 'md-sys-typescale', 'label-small'), - ) + @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; } diff --git a/tokens/_md-comp-menu-item.scss b/tokens/_md-comp-menu-item.scss new file mode 100644 index 0000000000..a3f392d3e5 --- /dev/null +++ b/tokens/_md-comp-menu-item.scss @@ -0,0 +1,76 @@ +// +// Copyright 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 +// + +// go/keep-sorted start +@use 'sass:list'; +@use 'sass:map'; +@use 'sass:string'; +// go/keep-sorted end +// go/keep-sorted start +@use './md-sys-color'; +@use './md-sys-elevation'; +@use './md-sys-shape'; +@use './v0_172/md-comp-menu'; +@use './values'; +// go/keep-sorted end + +$_default: ( + 'md-sys-color': md-sys-color.values-light(), + 'md-sys-elevation': md-sys-elevation.values(), + 'md-sys-shape': md-sys-shape.values(), +); + +$unsupported-tokens: ( + // go/keep-sorted start + 'container-elevation', + 'container-shadow-color', + 'container-shape', + // go/keep-sorted end +); + +$supported-tokens: ( + // go/keep-sorted start + 'list-item-selected-container-color', + // 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 + ); + + @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; +} diff --git a/tokens/_md-comp-menu.scss b/tokens/_md-comp-menu.scss index 12f3c28dbc..6811b66504 100644 --- a/tokens/_md-comp-menu.scss +++ b/tokens/_md-comp-menu.scss @@ -3,11 +3,17 @@ // SPDX-License-Identifier: Apache-2.0 // +// go/keep-sorted start +@use 'sass:list'; +@use 'sass:map'; +@use 'sass:string'; +// go/keep-sorted end // go/keep-sorted start @use './md-sys-color'; @use './md-sys-elevation'; @use './md-sys-shape'; @use './v0_172/md-comp-menu'; +@use './values'; // go/keep-sorted end $_default: ( @@ -16,6 +22,50 @@ $_default: ( 'md-sys-shape': md-sys-shape.values(), ); -@function values($deps: $_default) { - @return md-comp-menu.values($deps); +$unsupported-tokens: ( + // go/keep-sorted start + 'list-item-selected-container-color', + // go/keep-sorted end +); + +$supported-tokens: ( + // go/keep-sorted start + 'container-color', + 'container-elevation', + 'container-shadow-color', + 'container-shape', + // go/keep-sorted end +); + +@function 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 { + $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; }