Skip to content

Commit 4b61f0e

Browse files
committed
refactor(material/theming): clean up theme file and use mdc typography everywhere
1 parent 610e3c4 commit 4b61f0e

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

src/dev-app/theme.scss

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,40 @@
1515

1616
// Plus imports for other components in your app.
1717

18-
// Include the common styles for Angular Material. We include this here so that you only
19-
// have to load a single css file for Angular Material in your app.
20-
// **Be sure that you only ever include this mixin once!**
21-
@include mat-core();
22-
@include angular-material-mdc-typography(mat-mdc-typography-config());
23-
@include mat-popover-edit-typography(mat-typography-config());
24-
25-
// Include base styles for strong focus indicators.
26-
.demo-strong-focus {
27-
@include mat-strong-focus-indicators();
28-
@include mat-mdc-strong-focus-indicators();
29-
}
30-
31-
// Define the default theme (same as the example above).
18+
// Define the default (light) theme.
3219
$candy-app-primary: mat-palette($mat-indigo);
3320
$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);
3421
$candy-app-theme: mat-light-theme((
35-
color: (
36-
primary: $candy-app-primary,
37-
accent: $candy-app-accent
38-
)
22+
// Define the default colors for our app.
23+
color: (
24+
primary: $candy-app-primary,
25+
accent: $candy-app-accent
26+
),
27+
// Define the default typography for our app.
28+
typography: mat-mdc-typography-config(),
29+
// Define the default density level for our app.
30+
density: 0,
3931
));
4032

33+
// Include the common styles for Angular Material. We include this here so that you only
34+
// have to load a single css file for Angular Material in your app.
35+
// **Be sure that you only ever include this mixin once!**
36+
@include mat-core($candy-app-theme);
37+
4138
// Include the default theme styles.
4239
@include angular-material-theme($candy-app-theme);
4340
@include angular-material-mdc-theme($candy-app-theme);
4441
@include mat-column-resize-theme($candy-app-theme);
4542
@include mat-popover-edit-theme($candy-app-theme);
46-
4743
// We add this in manually for now, because it isn't included in `angular-material-mdc-theme`.
4844
@include mat-mdc-slider-theme($candy-app-theme);
4945

50-
// Define an alternate dark theme.
51-
$dark-primary: mat-palette($mat-blue-grey);
52-
$dark-accent: mat-palette($mat-amber, A200, A100, A400);
53-
$dark-warn: mat-palette($mat-deep-orange);
54-
$dark-theme: mat-dark-theme((
55-
color: (
56-
primary: $dark-primary,
57-
accent: $dark-accent,
58-
warn: $dark-warn
59-
)
60-
));
61-
62-
// Include the default theme for focus indicators.
6346
.demo-strong-focus {
47+
// Include base styles for strong focus indicators.
48+
@include mat-strong-focus-indicators();
49+
@include mat-mdc-strong-focus-indicators();
50+
51+
// Include the default theme for focus indicators.
6452
@include mat-strong-focus-indicators-theme($candy-app-theme);
6553
@include mat-mdc-strong-focus-indicators-theme($candy-app-theme);
6654
}
@@ -70,17 +58,25 @@ $dark-theme: mat-dark-theme((
7058
// `.demo-unicorn-dark-theme` will be affected by this alternate dark theme instead of the
7159
// default theme.
7260
.demo-unicorn-dark-theme {
73-
@include angular-material-color($dark-theme);
74-
@include angular-material-mdc-color($dark-theme);
75-
@include mat-column-resize-color($dark-theme);
76-
@include mat-popover-edit-color($dark-theme);
77-
@include mat-mdc-slider-color($dark-theme);
78-
}
61+
// Create the color palettes used in our dark theme.
62+
$dark-primary: mat-palette($mat-blue-grey);
63+
$dark-accent: mat-palette($mat-amber, A200, A100, A400);
64+
$dark-warn: mat-palette($mat-deep-orange);
65+
$dark-colors: mat-dark-theme($dark-primary, $dark-accent, $dark-warn);
7966

80-
// Include the dark theme for focus indicators.
81-
.demo-unicorn-dark-theme.demo-strong-focus {
82-
@include mat-strong-focus-indicators-color($dark-theme);
83-
@include mat-mdc-strong-focus-indicators-color($dark-theme);
67+
// Include the dark theme color styles.
68+
@include angular-material-color($dark-colors);
69+
@include angular-material-mdc-color($dark-colors);
70+
@include mat-column-resize-color($dark-colors);
71+
@include mat-popover-edit-color($dark-colors);
72+
// We add this in manually for now, because it isn't included in `angular-material-mdc-theme`.
73+
@include mat-mdc-slider-color($dark-colors);
74+
75+
// Include the dark theme colors for focus indicators.
76+
.demo-strong-focus {
77+
@include mat-strong-focus-indicators-color($dark-colors);
78+
@include mat-mdc-strong-focus-indicators-color($dark-colors);
79+
}
8480
}
8581

8682
// Create classes for all density scales which are supported by all MDC-based components.

src/material/core/typography/_typography.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@
132132

133133
// Adds the base typography styles, based on a config.
134134
/* stylelint-disable-next-line material/theme-mixin-api */
135-
@mixin mat-base-typography($config, $selector: '.mat-typography') {
135+
@mixin mat-base-typography($config-or-theme, $selector: '.mat-typography') {
136+
$config: mat-private-typography-to-2014-config(mat-get-typography-config($config-or-theme));
137+
136138
.mat-h1, .mat-headline, #{$selector} h1 {
137139
@include mat-typography-level-to-styles($config, headline);
138140
margin: 0 0 16px;

0 commit comments

Comments
 (0)