Skip to content

Commit c78e96a

Browse files
committed
refactor(material/chips): follow angular touch-target density pattern
Updates previous changes to Angular Components' Chip component to add a touch-target element and modifies the previously implemented styles to follow the density logic applied to touch-target theme/styles for checkbox and button. Fixes b/537441584
1 parent f85696c commit c78e96a

4 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/dev-app/chips/chips-demo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
.mat-mdc-basic-chip {
21-
margin: 8px 10px;
21+
margin: 16px 10px;
2222
}
2323

2424
mat-chip-grid input {

src/material/chips/_m2-chip.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
@function get-tokens($theme) {
77
$system: m2-utils.get-system($theme);
88
$density-scale: theming.clamp-density(map.get($system, density-scale), -2);
9+
$touch-target-display: block;
10+
11+
@if $density-scale < 0 {
12+
$touch-target-display: none;
13+
}
914

1015
@return (
1116
base: (
@@ -43,7 +48,8 @@
4348
chip-container-height: map.get((
4449
0: 32px,
4550
-1: 28px,
46-
-2: 24px), $density-scale)
51+
-2: 24px), $density-scale),
52+
chip-touch-target-display: $touch-target-display,
4753
),
4854
);
4955
}

src/material/chips/_m3-chip.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@
7777

7878
@return (
7979
chip-container-height: list.nth((32px, 28px, 24px), $index),
80+
chip-touch-target-display: list.nth((block, none, none), $index),
8081
);
8182
}

src/material/chips/chip.scss

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,14 @@ $fallbacks: m3-chip.get-tokens();
2929
max-width: 100%;
3030
}
3131

32-
.mat-mdc-standard-chip,
33-
.mat-mdc-basic-chip,
34-
.mat-mdc-evolution-chip {
35-
// Ensures basic/unstyled chips also have a 32px min-height baseline.
36-
min-height: 32px;
37-
38-
// 8px top and bottom margin for 48px touch target separation.
39-
margin-top: $_touch-target-vertical-padding;
40-
margin-bottom: $_touch-target-vertical-padding;
41-
}
42-
4332
.mat-mdc-chip-touch-target {
4433
position: absolute;
4534
top: 50%;
4635
left: 0;
4736
right: 0;
4837
height: $_touch-target-size;
4938
transform: translateY(-50%);
39+
display: token-utils.slot(chip-touch-target-display, $fallbacks);
5040
pointer-events: auto;
5141
}
5242

0 commit comments

Comments
 (0)