Skip to content

Commit c2555da

Browse files
committed
refactor(material/radio): switch touch target to tokens
Reworks the radio touch target to use tokens.
1 parent 78446e5 commit c2555da

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ $_density-tokens: (
9696
(mat, paginator): (
9797
container-size: (56px, 52px, 48px, 40px),
9898
),
99-
(mat, radio): (),
99+
(mat, radio): (
100+
touch-target-display: (block, block, none, none),
101+
),
100102
(mat, ripple): (),
101103
(mat, select): (),
102104
(mat, sidenav): (),

src/material/core/tokens/m2/mat/_radio.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use '../../token-utils';
2+
@use '../../../theming/theming';
23
@use '../../../theming/inspection';
34
@use '../../../style/sass-utils';
45

@@ -29,7 +30,11 @@ $prefix: (mat, radio);
2930

3031
// Tokens that can be configured through Angular Material's density theming API.
3132
@function get-density-tokens($theme) {
32-
@return ();
33+
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
34+
35+
@return (
36+
touch-target-display: if($density-scale < -1, none, block),
37+
);
3338
}
3439

3540
// Combines the tokens generated by the above functions into a single map with placeholder values.

src/material/radio/_radio-theme.scss

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@use 'sass:map';
22
@use '@material/radio/radio-theme' as mdc-radio-theme;
33
@use '@material/form-field/form-field-theme' as mdc-form-field-theme;
4-
@use '../core/mdc-helpers/mdc-helpers';
54
@use '../core/style/sass-utils';
65
@use '../core/theming/theming';
76
@use '../core/theming/inspection';
@@ -60,6 +59,8 @@
6059
@else {
6160
@include sass-utils.current-selector-or-root() {
6261
@include mdc-radio-theme.theme(tokens-mdc-radio.get-typography-tokens($theme));
62+
@include token-utils.create-token-values(
63+
tokens-mat-radio.$prefix, tokens-mat-radio.get-typography-tokens($theme));
6364
}
6465

6566
.mat-mdc-radio-button {
@@ -77,12 +78,8 @@
7778

7879
@include sass-utils.current-selector-or-root() {
7980
@include mdc-radio-theme.theme(tokens-mdc-radio.get-density-tokens($theme));
80-
}
81-
82-
@include mdc-helpers.if-touch-targets-unsupported($density-scale) {
83-
.mat-mdc-radio-touch-target {
84-
display: none;
85-
}
81+
@include token-utils.create-token-values(
82+
tokens-mat-radio.$prefix, tokens-mat-radio.get-density-tokens($theme));
8683
}
8784
}
8885
}

src/material/radio/radio.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
$set-width: true,
109109
$query: mdc-helpers.$mdc-base-styles-query);
110110

111+
@include token-utils.use-tokens(tokens-mat-radio.$prefix,tokens-mat-radio.get-token-slots()) {
112+
@include token-utils.create-token-slot(display, touch-target-display);
113+
}
114+
111115
[dir='rtl'] & {
112116
left: 0;
113117
right: 50%;

0 commit comments

Comments
 (0)