Skip to content

Commit bad94fd

Browse files
authored
fix(material/datepicker): calendar font tokens not being picked up (#29610) (#29615)
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 5f0c890 commit bad94fd

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ $_tokens: (tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots(
9191
outline: none;
9292
font-family: inherit;
9393
margin: 0;
94+
95+
// Needs to be repeated here in order to override the user agent styles.
96+
@include token-utils.use-tokens($_tokens...) {
97+
@include token-utils.create-token-slot(font-family, calendar-text-font);
98+
@include token-utils.create-token-slot(font-size, calendar-text-size);
99+
}
94100
}
95101

96102
// We use ::before to apply a background to the body cell, because we need to apply a border

0 commit comments

Comments
 (0)