Skip to content

Commit 7f298f7

Browse files
crisbetoandrewseguin
authored andcommitted
fix(datepicker): switch to typography api (#4950)
Switches the datepicker's typography styles to use the typography API and moves them into the theme file.
1 parent 22f0ea0 commit 7f298f7

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

src/lib/core/typography/_all-typography.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@import '../../card/card-theme';
66
@import '../../checkbox/checkbox-theme';
77
@import '../../chips/chips-theme';
8+
@import '../../datepicker/datepicker-theme';
89
@import '../../dialog/dialog-theme';
910
@import '../../grid-list/grid-list-theme';
1011
@import '../../icon/icon-theme';
@@ -34,6 +35,7 @@
3435
@include mat-card-typography($config);
3536
@include mat-checkbox-typography($config);
3637
@include mat-chips-typography($config);
38+
@include mat-datepicker-typography($config);
3739
@include mat-dialog-typography($config);
3840
@include mat-grid-list-typography($config);
3941
@include mat-icon-typography($config);

src/lib/datepicker/_datepicker-theme.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
@import '../core/theming/palette';
22
@import '../core/theming/theming';
3+
@import '../core/typography/typography-utils';
4+
5+
6+
$mat-calendar-body-font-size: 13px !default;
7+
$mat-calendar-weekday-table-font-size: 11px !default;
38

49

510
@mixin mat-datepicker-theme($theme) {
@@ -78,3 +83,28 @@
7883
border-color: fade-out(mat-color($foreground, hint-text), $mat-datepicker-today-fade-amount);
7984
}
8085
}
86+
87+
@mixin mat-datepicker-typography($config) {
88+
.mat-calendar {
89+
font-family: mat-font-family($config);
90+
}
91+
92+
.mat-calendar-body {
93+
font-size: $mat-calendar-body-font-size;
94+
}
95+
96+
.mat-calendar-body-label,
97+
.mat-calendar-period-button {
98+
font: {
99+
size: mat-font-size($config, button);
100+
weight: mat-font-weight($config, button);
101+
}
102+
}
103+
104+
.mat-calendar-table-header th {
105+
font: {
106+
size: $mat-calendar-weekday-table-font-size;
107+
weight: mat-font-weight($config, body-1);
108+
}
109+
}
110+
}

src/lib/datepicker/calendar-body.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
$mat-calendar-body-font-size: 13px !default;
2-
$mat-calendar-body-header-font-size: 14px !default;
31
$mat-calendar-body-label-padding-start: 5% !default;
42
$mat-calendar-body-label-translation: -6px !default;
53
$mat-calendar-body-cell-min-size: 32px !default;
@@ -13,7 +11,6 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
1311

1412

1513
.mat-calendar-body {
16-
font-size: $mat-calendar-body-font-size;
1714
min-width: $mat-calendar-body-min-size;
1815
}
1916

@@ -24,8 +21,6 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
2421
line-height: 0;
2522
transform: translateX($mat-calendar-body-label-translation);
2623
text-align: left;
27-
font-size: $mat-calendar-body-header-font-size;
28-
font-weight: bold;
2924
}
3025

3126
.mat-calendar-body-cell {

src/lib/datepicker/calendar.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ $mat-calendar-controls-vertical-padding: 5%;
66
$mat-calendar-controls-start-padding: calc(100% / 14 - 22px);
77
// Same as above, but on other side for arrows.
88
$mat-calendar-controls-end-padding: calc(100% / 14 - 22px);
9-
$mat-calendar-period-font-size: 14px;
109
$mat-calendar-arrow-size: 5px !default;
1110
$mat-calendar-arrow-disabled-opacity: 0.5 !default;
12-
$mat-calendar-weekday-table-font-size: 11px !default;
1311

1412
// Values chosen to approximate https://material.io/icons/#ic_navigate_before and
1513
// https://material.io/icons/#ic_navigate_next as closely as possible.
@@ -43,9 +41,6 @@ $mat-calendar-next-icon-transform: translateX(-2px) rotate(45deg);
4341
}
4442

4543
.mat-calendar-period-button {
46-
font: inherit;
47-
font-size: $mat-calendar-period-font-size;
48-
font-weight: bold;
4944
min-width: 0;
5045
}
5146

@@ -108,8 +103,6 @@ $mat-calendar-next-icon-transform: translateX(-2px) rotate(45deg);
108103

109104
.mat-calendar-table-header th {
110105
text-align: center;
111-
font-size: $mat-calendar-weekday-table-font-size;
112-
font-weight: normal;
113106
padding: 0 0 $mat-calendar-padding 0;
114107
}
115108

0 commit comments

Comments
 (0)