Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/schematics): switch custom theme schematic to @use #22436

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/material/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ describe('ng-add schematic', () => {
const buffer = tree.read(expectedStylesPath);
const themeContent = buffer!.toString();

expect(themeContent).toContain(`@import '~@angular/material/theming';`);
expect(themeContent).toContain(`$app-primary: mat-palette(`);
expect(themeContent).toContain(`@use '~@angular/material' as mat;`);
expect(themeContent).toContain(`$app-primary: mat.define-palette(`);
});

it('should create a custom theme file if no SCSS file could be found', async () => {
Expand Down
14 changes: 7 additions & 7 deletions src/material/schematics/ng-add/theming/create-custom-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ export function createCustomTheme(name: string = 'app') {
return `
// Custom Theming for Angular Material
// For more information: https://material.angular.io/guide/theming
@import '~@angular/material/theming';
@use '~@angular/material' as mat;
// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();
@include mat.core();

// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$${name}-primary: mat-palette($mat-indigo);
$${name}-accent: mat-palette($mat-pink, A200, A100, A400);
$${name}-primary: mat.define-palette(mat.$indigo-palette);
$${name}-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);

// The warn palette is optional (defaults to red).
$${name}-warn: mat-palette($mat-red);
$${name}-warn: mat.define-palette(mat.$red-palette);

// Create the theme object. A theme consists of configurations for individual
// theming systems such as "color" or "typography".
$${name}-theme: mat-light-theme((
$${name}-theme: mat.define-light-theme((
color: (
primary: $${name}-primary,
accent: $${name}-accent,
Expand All @@ -41,7 +41,7 @@ $${name}-theme: mat-light-theme((
// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($${name}-theme);
@include mat.all-component-themes($${name}-theme);

`;
}