Skip to content

Commit 9c3af28

Browse files
authored
feat(material/schematics): Switch custom theme schematic to use theme mixin instead of define-theme and add high contrast override mixins (#29642)
1 parent a58e6f6 commit 9c3af28

File tree

16 files changed

+704
-589
lines changed

16 files changed

+704
-589
lines changed

.ng-dev/google-sync-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"src/material/**/*.ts",
77
"src/material/**/*.html",
88
"src/material/**/*.scss",
9-
"src/material/schematics/ng-generate/m3-theme/**/*",
9+
"src/material/schematics/ng-generate/theme-color/**/*",
1010
"src/material-experimental/**/*.ts",
1111
"src/material-experimental/**/*.html",
1212
"src/material-experimental/**/*.scss",
@@ -25,7 +25,7 @@
2525
"src/**/*spec.ts",
2626
"src/cdk/schematics/**/*",
2727
"src/material/schematics/**/*",
28-
"src/material/schematics/ng-generate/m3-theme/**/*.bazel",
28+
"src/material/schematics/ng-generate/theme-color/**/*.bazel",
2929
"src/google-maps/schematics/**/*",
3030
"src/cdk/testing/testbed/zone-types.d.ts",
3131
"src/material/_theming.scss",

guides/schematics.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ ng generate @angular/cdk:drag-drop <component-name>
118118

119119
### Material 3 Theme schematic
120120

121-
The `m3-theme` schematic will generate a file with Material 3 themes created
122-
from custom colors.
121+
The `theme-color` schematic will generate a file with Material 3 palettes from the specified colors
122+
that can be used in a theme file. It also generates high contrast color override mixins if
123+
specified.
123124

124125
```
125-
ng generate @angular/material:m3-theme
126+
ng generate @angular/material:theme-color
126127
```
127128

128-
Learn more about this schematic in its [documentation](https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/m3-theme/README.md).
129+
Learn more about this schematic in its [documentation](https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/theme-color/README.md).

guides/theming.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,36 @@ and `tertiary` options:
128128
- `$rose-palette`
129129

130130
##### Custom theme
131-
Alternatively, a theme can be generated with a custom color with the following schematic:
131+
Alternatively, custom palettes can be generated with a custom color with the following schematic:
132132

133133
```shell
134-
ng generate @angular/material:m3-theme
134+
ng generate @angular/material:theme-color
135135
```
136136

137-
This schematic integrates with [Material Color Utilities](https://github.com/material-foundation/material-color-utilities) to build a theme based on a generated set of palettes based on a single color. Optionally you can provide additional custom colors for the secondary, tertiary, and neutral palettes.
137+
This schematic integrates with [Material Color Utilities](https://github.com/material-foundation/material-color-utilities) to build palettes based on a single color. Optionally you can provide
138+
additional custom colors for the secondary, tertiary, and neutral palettes.
138139

139-
The output of the schematic is a new Sass file that exports a theme or themes (if generating both a light and dark theme) that can be provided to component theme mixins.
140+
The output of the schematic is a new Sass file that exports the palettes that can be provided to
141+
a theme definition.
140142

141143
```scss
142144
@use '@angular/material' as mat;
143-
@use './path/to/m3-theme';
144-
145-
@include mat.core();
145+
@use './path/to/my-theme'; // location of generated file
146146

147147
html {
148-
// Apply the light theme by default
149-
@include mat.core-theme(m3-theme.$light-theme);
150-
@include mat.button-theme(m3-theme.$light-theme);
148+
@include mat.theme(
149+
color: (
150+
primary: my-theme.$primary-palette,
151+
tertiary: my-theme.$tertiary-palette,
152+
),
153+
typography: Roboto,
154+
density: 0,
155+
)
151156
}
152157
```
153158

154-
Learn more about this schematic in its [documentation](https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/m3-theme/README.md).
159+
You can also optionally generate high contrast override mixins for your custom theme that allows for
160+
a better accessibility experience. Learn more about this schematic in its [documentation](https://github.com/angular/components/blob/main/src/material/schematics/ng-generate/theme-color/README.md).
155161

156162
<!-- TODO(mmalerba): Illustrate palettes with example. -->
157163

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"@bazel/terser": "5.8.1",
9999
"@bazel/worker": "5.8.1",
100100
"@firebase/app-types": "^0.7.0",
101-
"@material/material-color-utilities": "^0.2.7",
101+
"@material/material-color-utilities": "^0.3.0",
102102
"@octokit/rest": "18.3.5",
103103
"@rollup/plugin-commonjs": "^21.0.0",
104104
"@rollup/plugin-node-resolve": "^13.1.3",

src/material/schematics/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pkg_npm(
7676
name = "npm_package",
7777
srcs = ["package.json"],
7878
nested_packages = [
79-
"//src/material/schematics/ng-generate/m3-theme:npm_package",
79+
"//src/material/schematics/ng-generate/theme-color:npm_package",
8080
],
8181
deps = [
8282
":collection_assets",

src/material/schematics/collection.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
},
4848
"m3Theme": {
4949
"description": "Generate M3 theme",
50-
"factory": "./ng-generate/m3-theme/index_bundled",
51-
"schema": "./ng-generate/m3-theme/schema.json",
52-
"aliases": ["m3-theme", "M3-theme"]
50+
"factory": "./ng-generate/theme-color/index_bundled",
51+
"schema": "./ng-generate/theme-color/schema.json",
52+
"aliases": ["theme-color"]
5353
}
5454
}
5555
}

src/material/schematics/ng-generate/m3-theme/README.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)