Skip to content

Commit e1025b5

Browse files
committed
refactor(material/chips): simplify structural styles
Simplifies the structural styles for the chips to make them simpler and easier to maintain.
1 parent 2636512 commit e1025b5

File tree

6 files changed

+551
-236
lines changed

6 files changed

+551
-236
lines changed

src/material/chips/_chips-theme.scss

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@use 'sass:color';
2-
@use '@material/chips/chip-theme' as mdc-chip-theme;
32
@use '../core/tokens/m2/mdc/chip' as tokens-mdc-chip;
43
@use '../core/tokens/m2/mat/chip' as tokens-mat-chip;
54
@use '../core/tokens/token-utils';
@@ -17,9 +16,10 @@
1716
}
1817
@else {
1918
.mat-mdc-standard-chip {
20-
@include mdc-chip-theme.theme(tokens-mdc-chip.get-unthemable-tokens());
2119
@include token-utils.create-token-values(
22-
tokens-mat-chip.$prefix, tokens-mat-chip.get-unthemable-tokens());
20+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-unthemable-tokens());
21+
@include token-utils.create-token-values(
22+
tokens-mat-chip.$prefix, tokens-mat-chip.get-unthemable-tokens());
2323
}
2424
}
2525
}
@@ -35,32 +35,32 @@
3535
}
3636
@else {
3737
.mat-mdc-standard-chip {
38-
$default-color-tokens: tokens-mdc-chip.get-color-tokens($theme);
39-
@include mdc-chip-theme.theme($default-color-tokens);
4038
@include token-utils.create-token-values(
41-
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme));
39+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-color-tokens($theme));
40+
@include token-utils.create-token-values(
41+
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme));
4242

4343
&.mat-mdc-chip-selected,
4444
&.mat-mdc-chip-highlighted {
4545
&.mat-primary {
46-
$primary-color-tokens: tokens-mdc-chip.get-color-tokens($theme, primary);
47-
@include mdc-chip-theme.theme($primary-color-tokens);
4846
@include token-utils.create-token-values(
49-
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, primary));
47+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-color-tokens($theme, primary));
48+
@include token-utils.create-token-values(
49+
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, primary));
5050
}
5151

5252
&.mat-accent {
53-
$accent-color-tokens: tokens-mdc-chip.get-color-tokens($theme, accent);
54-
@include mdc-chip-theme.theme($accent-color-tokens);
5553
@include token-utils.create-token-values(
56-
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, accent));
54+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-color-tokens($theme, accent));
55+
@include token-utils.create-token-values(
56+
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, accent));
5757
}
5858

5959
&.mat-warn {
60-
$warn-color-tokens: tokens-mdc-chip.get-color-tokens($theme, warn);
61-
@include mdc-chip-theme.theme($warn-color-tokens);
6260
@include token-utils.create-token-values(
63-
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, warn));
61+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-color-tokens($theme, warn));
62+
@include token-utils.create-token-values(
63+
tokens-mat-chip.$prefix, tokens-mat-chip.get-color-tokens($theme, warn));
6464
}
6565
}
6666
}
@@ -74,12 +74,11 @@
7474
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography));
7575
}
7676
@else {
77-
$typography-tokens: tokens-mdc-chip.get-typography-tokens($theme);
78-
7977
.mat-mdc-standard-chip {
80-
@include mdc-chip-theme.theme($typography-tokens);
8178
@include token-utils.create-token-values(
82-
tokens-mat-chip.$prefix, tokens-mat-chip.get-typography-tokens($theme));
79+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-typography-tokens($theme));
80+
@include token-utils.create-token-values(
81+
tokens-mat-chip.$prefix, tokens-mat-chip.get-typography-tokens($theme));
8382
}
8483
}
8584
}
@@ -91,12 +90,11 @@
9190
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
9291
}
9392
@else {
94-
$density-tokens: tokens-mdc-chip.get-density-tokens($theme);
95-
9693
.mat-mdc-chip.mat-mdc-standard-chip {
97-
@include mdc-chip-theme.theme($density-tokens);
9894
@include token-utils.create-token-values(
99-
tokens-mat-chip.$prefix, tokens-mat-chip.get-density-tokens($theme));
95+
tokens-mdc-chip.$prefix, tokens-mdc-chip.get-density-tokens($theme));
96+
@include token-utils.create-token-values(
97+
tokens-mat-chip.$prefix, tokens-mat-chip.get-density-tokens($theme));
10098
}
10199
}
102100
}
@@ -141,6 +139,6 @@
141139
'Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector');
142140
$mdc-chip-tokens: token-utils.get-tokens-for($tokens, tokens-mdc-chip.$prefix, $options...);
143141
$mat-chip-tokens: token-utils.get-tokens-for($tokens, tokens-mat-chip.$prefix, $options...);
144-
@include mdc-chip-theme.theme($mdc-chip-tokens);
142+
@include token-utils.create-token-values(tokens-mdc-chip.$prefix, $mdc-chip-tokens);
145143
@include token-utils.create-token-values(tokens-mat-chip.$prefix, $mat-chip-tokens);
146144
}

src/material/chips/chip-set.scss

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
1-
@use '@material/chips/chip-set' as mdc-chip-set;
2-
@use '../core/mdc-helpers/mdc-helpers';
3-
4-
@include mdc-chip-set.core-styles($query: mdc-helpers.$mdc-base-styles-query);
5-
61
// Ensures that the internal chip container spans the entire outer container width, if the
72
// outer container width is customized. This is used by some wrapper components in g3.
83
.mat-mdc-chip-set {
4+
display: flex;
5+
6+
&:focus {
7+
outline: none;
8+
}
9+
910
.mdc-evolution-chip-set__chips {
1011
min-width: 100%;
12+
margin-left: -8px;
13+
margin-right: 0;
14+
}
15+
16+
.mdc-evolution-chip {
17+
margin: 4px 0 4px 8px;
1118
}
19+
20+
[dir='rtl'] & {
21+
.mdc-evolution-chip-set__chips {
22+
margin-left: 0;
23+
margin-right: -8px;
24+
}
25+
26+
.mdc-evolution-chip {
27+
margin-left: 0;
28+
margin-right: 8px;
29+
}
30+
}
31+
}
32+
33+
.mdc-evolution-chip-set__chips {
34+
display: flex;
35+
flex-flow: wrap;
36+
min-width: 0;
1237
}
1338

1439
// Angular Material supports vertically-stacked chips, which MDC does not.

0 commit comments

Comments
 (0)