Skip to content

Commit 7cf8c6c

Browse files
authored
fix(material/datepicker): calendar font tokens not being picked up (#29610)
We were setting the `calendar-text-font` and `calendar-text-size` tokens at the top level of the calendar which meant that it wasn't being picked up in the cells, because they have `button` elements which have user agent styles. These changes resolve the issue by explicitly setting the tokens. Also fixes that the font size was too big in M3. Fixes #29608.
1 parent 01711b1 commit 7cf8c6c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ $private-default-overlap-color: #a8dab5;
106106
// that were set in the previous theming API to reduce the amount of subtle screenshot
107107
// differences. We should look into introducing the other tokens in a follow-up.
108108
calendar-text-font: inspection.get-theme-typography($theme, body-1, font-family),
109-
calendar-text-size: 13px, // TODO(crisbeto): this doesn't appear to affect anything
109+
calendar-text-size: 13px,
110110

111111
calendar-body-label-text-size: inspection.get-theme-typography($theme, button, font-size),
112112
calendar-body-label-text-weight: inspection.get-theme-typography($theme, button, font-weight),

src/material/core/tokens/m3/mat/_datepicker.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ $prefix: (mat, datepicker);
7373
token-definition.hardcode(elevation.get-box-shadow(0), $exclude-hardcoded),
7474
calendar-container-shape: map.get($systems, md-sys-shape, corner-large),
7575
calendar-container-touch-shape: map.get($systems, md-sys-shape, corner-extra-large),
76-
calendar-text-font: map.get($systems, md-sys-typescale, body-large-font),
77-
calendar-text-size: map.get($systems, md-sys-typescale, body-large-size),
76+
calendar-text-font: map.get($systems, md-sys-typescale, body-medium-font),
77+
calendar-text-size: map.get($systems, md-sys-typescale, body-medium-size),
7878
calendar-body-label-text-size: map.get($systems, md-sys-typescale, title-small-size),
7979
calendar-body-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight),
8080
calendar-period-button-text-size: map.get($systems, md-sys-typescale, title-small-size),

src/material/datepicker/calendar-body.scss

+7
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ $_tokens: (tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots(
9090
outline: none;
9191
font-family: inherit;
9292
margin: 0;
93+
94+
// Needs to be repeated here in order to override the user agent styles.
95+
@include token-utils.use-tokens($_tokens...) {
96+
@include token-utils.create-token-slot(font-family, calendar-text-font);
97+
@include token-utils.create-token-slot(font-size, calendar-text-size);
98+
}
99+
93100
@include button-common.reset();
94101
}
95102

0 commit comments

Comments
 (0)