Skip to content

Commit c88c598

Browse files
committed
fix(material/list): tokenize space around leading icon
List component: tokenize space on left and right of leading icon. Correct spacing around leading icon on M3. Currently, leading icon has 16px margin in front of icon and 32px behind. Give leading icon symmetrical margin for M3. Does not intend to make visual change to M2.
1 parent f3e487d commit c88c598

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

src/material-experimental/theming/_m3-density.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ $_density-tokens: (
9595
(mat, icon-button): (
9696
touch-target-display: (block, block, none, none),
9797
),
98+
(mat, list): (
99+
list-item-leading-icon-start-space: (16px, 12px, 8px, 4px),
100+
list-item-leading-icon-end-space: (16px, 12px, 8px, 4px),
101+
),
98102
(mat, text-button): (
99103
touch-target-display: (block, block, none, none),
100104
),

src/material/core/tokens/m2/_index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
@use './mat/grid-list' as tokens-mat-grid-list;
2222
@use './mat/icon' as tokens-mat-icon;
2323
@use './mat/icon-button' as tokens-mat-icon-button;
24+
@use './mat/list' as tokens-mat-list;
2425
@use './mat/menu' as tokens-mat-menu;
2526
@use './mat/option' as tokens-mat-option;
2627
@use './mat/optgroup' as tokens-mat-optgroup;
@@ -139,6 +140,7 @@
139140
_get-tokens-for-module($theme, tokens-mat-paginator),
140141
_get-tokens-for-module($theme, tokens-mat-checkbox),
141142
_get-tokens-for-module($theme, tokens-mat-full-pseudo-checkbox),
143+
_get-tokens-for-module($theme, tokens-mat-list),
142144
_get-tokens-for-module($theme, tokens-mat-minimal-pseudo-checkbox),
143145
_get-tokens-for-module($theme, tokens-mat-protected-button),
144146
_get-tokens-for-module($theme, tokens-mat-radio),
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@use '../../token-utils';
2+
@use '../../../style/sass-utils';
3+
4+
// The prefix used to generate the fully qualified name for tokens in this file.
5+
$prefix: (mat, list);
6+
7+
// Tokens that can't be configured through Angular Material's current theming API,
8+
// but may be in a future version of the theming API.
9+
@function get-unthemable-tokens() {
10+
@return ();
11+
}
12+
13+
// Tokens that can be configured through Angular Material's color theming API.
14+
@function get-color-tokens($theme) {
15+
@return ();
16+
}
17+
18+
// Tokens that can be configured through Angular Material's typography theming API.
19+
@function get-typography-tokens($theme) {
20+
@return ();
21+
}
22+
23+
// Tokens that can be configured through Angular Material's density theming API.
24+
@function get-density-tokens($theme) {
25+
@return (
26+
list-item-leading-icon-start-space: 16px,
27+
list-item-leading-icon-end-space: 32px,
28+
);
29+
}
30+
31+
// Combines the tokens generated by the above functions into a single map with placeholder values.
32+
// This is used to create token slots.
33+
@function get-token-slots() {
34+
@return sass-utils.deep-merge-all(
35+
get-unthemable-tokens(),
36+
get-color-tokens(token-utils.$placeholder-color-config),
37+
get-typography-tokens(token-utils.$placeholder-typography-config),
38+
get-density-tokens(token-utils.$placeholder-density-config)
39+
);
40+
}

src/material/list/_list-theme.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
@use '../core/style/sass-utils';
88
@use '../core/theming/theming';
99
@use '../core/theming/inspection';
10+
@use '../core/tokens/m2/mat/list' as tokens-mat-list;
1011
@use '../core/tokens/m2/mdc/checkbox' as tokens-mdc-checkbox;
1112
@use '../core/tokens/m2/mdc/radio' as tokens-mdc-radio;
1213
@use '../core/tokens/m2/mdc/list' as tokens-mdc-list;
14+
@use '../core/tokens/token-utils';
1315
@use '../core/typography/typography';
1416

1517
@mixin base($theme) {
@@ -96,6 +98,8 @@
9698
// Add values for MDC list tokens.
9799
@include sass-utils.current-selector-or-root() {
98100
@include mdc-list-theme.theme($mdc-list-density-tokens);
101+
@include token-utils.create-token-values(
102+
tokens-mat-list.$prefix, tokens-mat-list.get-density-tokens($theme));
99103
}
100104

101105
.mdc-list-item__start,
@@ -180,5 +184,8 @@
180184
@mixin _theme-from-tokens($tokens) {
181185
@if ($tokens != ()) {
182186
@include mdc-list-theme.theme(map.get($tokens, tokens-mdc-list.$prefix));
187+
188+
$mat-list-tokens: token-utils.get-tokens-for($tokens, tokens-mat-list.$prefix);
189+
@include token-utils.create-token-values(tokens-mat-list.$prefix, $mat-list-tokens);
183190
}
184191
}

src/material/list/list.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@use '@material/list/list-theme' as mdc-list-theme;
44
@use '@material/theme/custom-properties' as mdc-custom-properties;
55
@use '../core/style/layout-common';
6+
@use '../core/tokens/m2/mat/list' as m2-mat-list;
67
@use '../core/tokens/m2/mdc/list' as m2-mdc-list;
78
@use '../core/tokens/token-utils';
89
@use './list-item-hcm-indicator';
@@ -195,3 +196,15 @@ mat-action-list button {
195196
border: 0;
196197
}
197198
}
199+
200+
@include token-utils.use-tokens(m2-mat-list.$prefix,
201+
m2-mat-list.get-token-slots()) {
202+
.mdc-list-item--with-leading-icon .mdc-list-item__start {
203+
@include token-utils.create-token-slot(margin-left, list-item-leading-icon-start-space);
204+
@include token-utils.create-token-slot(margin-right, list-item-leading-icon-end-space);
205+
[dir='rtl'] & {
206+
@include token-utils.create-token-slot(margin-right, list-item-leading-icon-start-space);
207+
@include token-utils.create-token-slot(margin-left, list-item-leading-icon-end-space);
208+
}
209+
}
210+
}

0 commit comments

Comments
 (0)