Skip to content

Commit d0d59b7

Browse files
committedNov 11, 2024·
fix(material/core): change ng-add to use mat.theme (#29990)
* fix(material/core): change ng-add to use mat.theme * fix(material/core): tests --------- Co-authored-by: Andrew Seguin <andrewseguin@google.com> (cherry picked from commit 0a5b036)
1 parent 09da06b commit d0d59b7

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed
 

‎src/material/schematics/ng-add/index.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('ng-add schematic', () => {
124124
const themeContent = buffer!.toString();
125125

126126
expect(themeContent).toContain(`@use '@angular/material' as mat;`);
127-
expect(themeContent).toContain(`$material-theme: mat.define-theme((`);
127+
expect(themeContent).toContain(`@include mat.theme((`);
128128
});
129129

130130
it('should create a custom theme file if no SCSS file could be found', async () => {

‎src/material/schematics/ng-add/theming/create-custom-theme.ts

+11-27
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,16 @@ export function createCustomTheme(name: string = 'app') {
1212
// Custom Theming for Angular Material
1313
// For more information: https://material.angular.io/guide/theming
1414
@use '@angular/material' as mat;
15-
// Plus imports for other components in your app.
1615
17-
// Define the theme object.
18-
$${name}-theme: mat.define-theme((
19-
color: (
20-
theme-type: light,
21-
primary: mat.$azure-palette,
22-
tertiary: mat.$blue-palette,
23-
),
24-
density: (
25-
scale: 0,
26-
)
27-
));
28-
29-
// Include theme styles for core and each component used in your app.
30-
// Alternatively, you can import and @include the theme mixins for each component
31-
// that you are using.
32-
:root {
33-
@include mat.all-component-themes($${name}-theme);
34-
}
35-
36-
// Comment out the line below if you want to use the pre-defined typography utility classes.
37-
// For more information: https://material.angular.io/guide/typography#using-typography-styles-in-your-application.
38-
// @include mat.typography-hierarchy($${name}-theme);
39-
40-
// Comment out the line below if you want to use the deprecated \`color\` inputs.
41-
// @include mat.color-variants-backwards-compatibility($${name}-theme);
42-
`;
16+
html {
17+
@include mat.theme((
18+
color: (
19+
theme-type: light,
20+
primary: mat.$azure-palette,
21+
tertiary: mat.$blue-palette,
22+
),
23+
typography: Roboto,
24+
density: 0,
25+
));
26+
}`;
4327
}

0 commit comments

Comments
 (0)
Please sign in to comment.