2525// Internal styling for Chip MDC component.
2626
2727@use ' sass:map' ;
28- @use ' sass:meta' ;
2928@use ' sass:math' ;
3029@use ' sass:color' ;
3130@use ' @material/dom/dom' ;
@@ -218,7 +217,6 @@ $_custom-property-prefix: 'chip';
218217
219218@mixin theme-styles ($theme , $resolvers : resolvers .$material ) {
220219 @include theme .validate-theme-styles ($_light-theme , $theme );
221- $theme : _resolve-theme ($theme , $resolvers : $resolvers );
222220 $theme : keys .create-theme-properties (
223221 $theme ,
224222 $prefix : $_custom-property-prefix
@@ -232,49 +230,57 @@ $_custom-property-prefix: 'chip';
232230 map .get ($theme , container-surface-tint-layer-color )
233231 );
234232 @include _container-elevation (
235- $ map: (
236- default : map .get ($theme , container-elevation ),
237- )
233+ map . get ( $resolvers , elevation ),
234+ $shadow-color : map .get ($theme , container-shadow-color ),
235+ $map : ( default : map . get ( $theme , container-elevation ) )
238236 );
239237 @include _container-elevation (
240- $ map: (
241- enabled : map .get ($theme , flat-container-elevation ),
242- )
238+ map . get ( $resolvers , elevation ),
239+ $shadow-color : map .get ($theme , flat-container-shadow-color ),
240+ $map : (enabled: map . get ( $theme , flat-container-elevation ) )
243241 );
244242 @include _container-elevation (
243+ map .get ($resolvers , elevation ),
244+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
245245 $map : (
246246 enabled: map .get ($theme , elevated-container-elevation ),
247247 disabled : map .get ($theme , elevated-disabled-container-elevation ),
248248 hover: map .get ($theme , elevated-hover-container-elevation ),
249249 focus: map .get ($theme , elevated-focus-container-elevation ),
250- pressed: map .get ($theme , elevated-pressed-container-elevation ),
250+ pressed: map .get ($theme , elevated-pressed-container-elevation )
251251 )
252252 );
253253 @include _selected-container-elevation (
254+ map .get ($resolvers , elevation ),
255+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
254256 $map : (
255257 enabled: map .get ($theme , elevated-selected-container-elevation ),
256258 disabled : map .get ($theme , elevated-selected-disabled-container-elevation ),
257259 hover: map .get ($theme , elevated-selected-hover-container-elevation ),
258260 focus: map .get ($theme , elevated-selected-focus-container-elevation ),
259- pressed: map .get ($theme , elevated-selected-pressed-container-elevation ),
261+ pressed: map .get ($theme , elevated-selected-pressed-container-elevation )
260262 )
261263 );
262264 @include _selected-container-elevation (
265+ map .get ($resolvers , elevation ),
266+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
263267 $map : (
264268 enabled: map .get ($theme , flat-selected-container-elevation ),
265269 disabled : map .get ($theme , flat-selected-disabled-container-elevation ),
266270 hover: map .get ($theme , flat-selected-hover-container-elevation ),
267271 focus: map .get ($theme , flat-selected-focus-container-elevation ),
268- pressed: map .get ($theme , flat-selected-pressed-container-elevation ),
272+ pressed: map .get ($theme , flat-selected-pressed-container-elevation )
269273 )
270274 );
271275 @include _unselected-container-elevation (
276+ map .get ($resolvers , elevation ),
277+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
272278 $map : (
273279 enabled: map .get ($theme , flat-unselected-container-elevation ),
274280 disabled : map .get ($theme , flat-unselected-disabled-container-elevation ),
275281 hover: map .get ($theme , flat-unselected-hover-container-elevation ),
276282 focus: map .get ($theme , flat-unselected-focus-container-elevation ),
277- pressed: map .get ($theme , flat-unselected-pressed-container-elevation ),
283+ pressed: map .get ($theme , flat-unselected-pressed-container-elevation )
278284 )
279285 );
280286 @include outline-color (
@@ -462,52 +468,38 @@ $_custom-property-prefix: 'chip';
462468
463469@function _resolve-theme ($theme , $resolvers ) {
464470 $elevation-resolver : map .get ($resolvers , elevation );
465- @if $elevation-resolver == null {
471+ $shadow-color : map .get ($theme , elevated-container-shadow-color );
472+ @if $elevation-resolver == null or $shadow-color == null {
466473 @return $theme ;
467474 }
468475
469- $elevation-pairs : (
470- container- shadow- color: (
471- container- elevation,
472- ),
473- flat- container- shadow- color: (
474- flat- container- elevation,
475- ),
476- elevated- container- shadow- color: (
477- elevated- container- elevation,
478- elevated- disabled- container- elevation,
479- elevated- focus- container- elevation,
480- elevated- hover- container- elevation,
481- elevated- pressed- container- elevation,
482- elevated- selected- container- elevation,
483- elevated- selected- disabled- container- elevation,
484- elevated- selected- focus- container- elevation,
485- elevated- selected- hover- container- elevation,
486- elevated- selected- pressed- container- elevation,
487- flat- selected- focus- container- elevation,
488- flat- selected- hover- container- elevation,
489- flat- selected- pressed- container- elevation,
490- flat- unselected- focus- container- elevation,
491- flat- unselected- hover- container- elevation,
492- flat- unselected- pressed- container- elevation,
493- ),
476+ $elevation-keys : (
477+ container- elevation,
478+ elevated- container- elevation,
479+ elevated- disabled- container- elevation,
480+ elevated- focus- container- elevation,
481+ elevated- hover- container- elevation,
482+ elevated- pressed- container- elevation,
483+ elevated- selected- container- elevation,
484+ flat- container- elevation,
485+ flat- selected- focus- container- elevation,
486+ flat- selected- hover- container- elevation,
487+ flat- selected- pressed- container- elevation,
488+ flat- unselected- focus- container- elevation,
489+ flat- unselected- hover- container- elevation,
490+ flat- unselected- pressed- container- elevation
494491 );
495492
496- @each $shadow-color-key , $elevation-keys in $elevation-pairs {
497- $shadow-color : map .get ($theme , $shadow-color-key );
498- @if $shadow-color != null {
499- @each $key in $elevation-keys {
500- $elevation : map .get ($theme , $key );
501- @if $elevation != null {
502- $resolved-value : meta .call (
503- $elevation-resolver ,
504- $elevation : $elevation ,
505- $shadow-color : $shadow-color
506- );
507- // Update the key with the resolved value.
508- $theme : map .set ($theme , $key , $resolved-value );
509- }
510- }
493+ @each $key in $elevation-keys {
494+ $elevation : map .get ($theme , $key );
495+ @if $elevation != null {
496+ $resolved-value : meta .call (
497+ $resolvers ,
498+ $elevation : $elevation ,
499+ $shadow-color : $shadow-color
500+ );
501+ // Update the key with the resolved value.
502+ $theme : map .set ($theme , $key , $resolved-value );
511503 }
512504 }
513505 @return $theme ;
@@ -1483,67 +1475,67 @@ $_custom-property-prefix: 'chip';
14831475 }
14841476}
14851477
1486- @mixin _container-elevation-theme ($theme ) {
1487- @if map .get ($theme , shadow ) {
1488- @include elevation-theme .shadow (map .get ($theme , shadow ));
1489- }
1490- @if map .get ($theme , overlay-opacity ) {
1491- @include elevation-theme .overlay-opacity (map .get ($theme , overlay-opacity ));
1492- }
1493- }
1494-
1495- // TODO(b/259913622): Use elevation's theme-style() mixin.
1496- @mixin _container-elevation ($map ) {
1497- $default-state : state .get-default-state ($map );
1498- @if $default-state {
1499- @include _container-elevation-theme ($default-state );
1500- }
1501-
1478+ @mixin _container-elevation ($resolver , $shadow-color , $map ) {
15021479 @include _is-enabled () {
1503- $enabled-state : state .get-enabled-state ($map );
1504- @if $enabled-state {
1505- @include _container-elevation-theme ($enabled-state );
1480+ @if (state .get-enabled-state ($map )) {
1481+ @include elevation-theme .with-resolver (
1482+ $resolver ,
1483+ $elevation : state .get-enabled-state ($map ),
1484+ $shadow-color : $shadow-color
1485+ );
15061486 }
15071487 }
15081488
15091489 @include ripple-theme .hover () {
1510- $hover-state : state .get-hover-state ($map );
1511- @if $hover-state {
1512- @include _container-elevation-theme ($hover-state );
1490+ @if state .get-hover-state ($map ) {
1491+ @include elevation-theme .with-resolver (
1492+ $resolver ,
1493+ $elevation : state .get-hover-state ($map ),
1494+ $shadow-color : $shadow-color
1495+ );
15131496 }
15141497 }
15151498
15161499 @include ripple-theme .focus () {
1517- $focus-state : state .get-focus-state ($map );
1518- @if $focus-state {
1519- @include _container-elevation-theme ($focus-state );
1500+ @if (state .get-focus-state ($map )) {
1501+ @include elevation-theme .with-resolver (
1502+ $resolver ,
1503+ $elevation : state .get-focus-state ($map ),
1504+ $shadow-color : $shadow-color
1505+ );
15201506 }
15211507 }
15221508
15231509 @include ripple-theme .pressed () {
1524- $pressed-state : state .get-pressed-state ($map );
1525- @if $pressed-state {
1526- @include _container-elevation-theme ($pressed-state );
1510+ @if (state .get-pressed-state ($map )) {
1511+ @include elevation-theme .with-resolver (
1512+ $resolver ,
1513+ $elevation : state .get-pressed-state ($map ),
1514+ $shadow-color : $shadow-color
1515+ );
15271516 }
15281517 }
15291518
15301519 @include _is-disabled () {
1531- $disabled-state : state .get-disabled-state ($map );
1532- @if $disabled-state {
1533- @include _container-elevation-theme ($disabled-state );
1520+ @if (state .get-disabled-state ($map )) {
1521+ @include elevation-theme .with-resolver (
1522+ $resolver ,
1523+ $elevation : state .get-disabled-state ($map ),
1524+ $shadow-color : $shadow-color
1525+ );
15341526 }
15351527 }
15361528}
15371529
1538- @mixin _selected-container-elevation ($map ) {
1530+ @mixin _selected-container-elevation ($resolver , $shadow-color , $ map ) {
15391531 @include _is-selected () {
1540- @include _container-elevation ($map );
1532+ @include _container-elevation ($resolver , $shadow-color , $ map );
15411533 }
15421534}
15431535
1544- @mixin _unselected-container-elevation ($map ) {
1536+ @mixin _unselected-container-elevation ($resolver , $shadow-color , $ map ) {
15451537 @include _is-unselected () {
1546- @include _container-elevation ($map );
1538+ @include _container-elevation ($resolver , $shadow-color , $ map );
15471539 }
15481540}
15491541
0 commit comments