25
25
// Internal styling for Chip MDC component.
26
26
27
27
@use ' sass:map' ;
28
- @use ' sass:meta' ;
29
28
@use ' sass:math' ;
30
29
@use ' sass:color' ;
31
30
@use ' @material/dom/dom' ;
@@ -218,7 +217,6 @@ $_custom-property-prefix: 'chip';
218
217
219
218
@mixin theme-styles ($theme , $resolvers : resolvers .$material ) {
220
219
@include theme .validate-theme-styles ($_light-theme , $theme );
221
- $theme : _resolve-theme ($theme , $resolvers : $resolvers );
222
220
$theme : keys .create-theme-properties (
223
221
$theme ,
224
222
$prefix : $_custom-property-prefix
@@ -232,49 +230,57 @@ $_custom-property-prefix: 'chip';
232
230
map .get ($theme , container-surface-tint-layer-color )
233
231
);
234
232
@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 ) )
238
236
);
239
237
@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 ) )
243
241
);
244
242
@include _container-elevation (
243
+ map .get ($resolvers , elevation ),
244
+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
245
245
$map : (
246
246
enabled: map .get ($theme , elevated-container-elevation ),
247
247
disabled : map .get ($theme , elevated-disabled-container-elevation ),
248
248
hover: map .get ($theme , elevated-hover-container-elevation ),
249
249
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 )
251
251
)
252
252
);
253
253
@include _selected-container-elevation (
254
+ map .get ($resolvers , elevation ),
255
+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
254
256
$map : (
255
257
enabled: map .get ($theme , elevated-selected-container-elevation ),
256
258
disabled : map .get ($theme , elevated-selected-disabled-container-elevation ),
257
259
hover: map .get ($theme , elevated-selected-hover-container-elevation ),
258
260
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 )
260
262
)
261
263
);
262
264
@include _selected-container-elevation (
265
+ map .get ($resolvers , elevation ),
266
+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
263
267
$map : (
264
268
enabled: map .get ($theme , flat-selected-container-elevation ),
265
269
disabled : map .get ($theme , flat-selected-disabled-container-elevation ),
266
270
hover: map .get ($theme , flat-selected-hover-container-elevation ),
267
271
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 )
269
273
)
270
274
);
271
275
@include _unselected-container-elevation (
276
+ map .get ($resolvers , elevation ),
277
+ $shadow-color : map .get ($theme , elevated-container-shadow-color ),
272
278
$map : (
273
279
enabled: map .get ($theme , flat-unselected-container-elevation ),
274
280
disabled : map .get ($theme , flat-unselected-disabled-container-elevation ),
275
281
hover: map .get ($theme , flat-unselected-hover-container-elevation ),
276
282
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 )
278
284
)
279
285
);
280
286
@include outline-color (
@@ -462,52 +468,38 @@ $_custom-property-prefix: 'chip';
462
468
463
469
@function _resolve-theme ($theme , $resolvers ) {
464
470
$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 {
466
473
@return $theme ;
467
474
}
468
475
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
494
491
);
495
492
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 );
511
503
}
512
504
}
513
505
@return $theme ;
@@ -1483,67 +1475,67 @@ $_custom-property-prefix: 'chip';
1483
1475
}
1484
1476
}
1485
1477
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 ) {
1502
1479
@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
+ );
1506
1486
}
1507
1487
}
1508
1488
1509
1489
@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
+ );
1513
1496
}
1514
1497
}
1515
1498
1516
1499
@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
+ );
1520
1506
}
1521
1507
}
1522
1508
1523
1509
@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
+ );
1527
1516
}
1528
1517
}
1529
1518
1530
1519
@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
+ );
1534
1526
}
1535
1527
}
1536
1528
}
1537
1529
1538
- @mixin _selected-container-elevation ($map ) {
1530
+ @mixin _selected-container-elevation ($resolver , $shadow-color , $ map ) {
1539
1531
@include _is-selected () {
1540
- @include _container-elevation ($map );
1532
+ @include _container-elevation ($resolver , $shadow-color , $ map );
1541
1533
}
1542
1534
}
1543
1535
1544
- @mixin _unselected-container-elevation ($map ) {
1536
+ @mixin _unselected-container-elevation ($resolver , $shadow-color , $ map ) {
1545
1537
@include _is-unselected () {
1546
- @include _container-elevation ($map );
1538
+ @include _container-elevation ($resolver , $shadow-color , $ map );
1547
1539
}
1548
1540
}
1549
1541
0 commit comments