Skip to content

Commit

Permalink
fix(material/datepicker): calendar font tokens not being picked up
Browse files Browse the repository at this point in the history
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 angular#29608.
  • Loading branch information
crisbeto committed Aug 20, 2024
1 parent 01711b1 commit f4595b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/material/core/tokens/m2/mat/_datepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ $private-default-overlap-color: #a8dab5;
// that were set in the previous theming API to reduce the amount of subtle screenshot
// differences. We should look into introducing the other tokens in a follow-up.
calendar-text-font: inspection.get-theme-typography($theme, body-1, font-family),
calendar-text-size: 13px, // TODO(crisbeto): this doesn't appear to affect anything
calendar-text-size: 13px,

calendar-body-label-text-size: inspection.get-theme-typography($theme, button, font-size),
calendar-body-label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
Expand Down
4 changes: 2 additions & 2 deletions src/material/core/tokens/m3/mat/_datepicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ $prefix: (mat, datepicker);
token-definition.hardcode(elevation.get-box-shadow(0), $exclude-hardcoded),
calendar-container-shape: map.get($systems, md-sys-shape, corner-large),
calendar-container-touch-shape: map.get($systems, md-sys-shape, corner-extra-large),
calendar-text-font: map.get($systems, md-sys-typescale, body-large-font),
calendar-text-size: map.get($systems, md-sys-typescale, body-large-size),
calendar-text-font: map.get($systems, md-sys-typescale, body-medium-font),
calendar-text-size: map.get($systems, md-sys-typescale, body-medium-size),
calendar-body-label-text-size: map.get($systems, md-sys-typescale, title-small-size),
calendar-body-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight),
calendar-period-button-text-size: map.get($systems, md-sys-typescale, title-small-size),
Expand Down
7 changes: 7 additions & 0 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ $_tokens: (tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots(
outline: none;
font-family: inherit;
margin: 0;

// Needs to be repeated here in order to override the user agent styles.
@include token-utils.use-tokens($_tokens...) {
@include token-utils.create-token-slot(font-family, calendar-text-font);
@include token-utils.create-token-slot(font-size, calendar-text-size);
}

@include button-common.reset();
}

Expand Down

0 comments on commit f4595b6

Please sign in to comment.