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

feat(material/schematics): Add custom M3 theme schematic #28766

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

amysorto
Copy link
Contributor

No description provided.

@amysorto amysorto added the area: ng-generate Schematics that generate code in user projects label Mar 22, 2024
@amysorto amysorto requested a review from mmalerba March 22, 2024 18:21
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 22, 2024
Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo exciting!

This PR should also edit the docs to include information about using this schematic

src/material/schematics/ng-generate/m3-theme/index.ts Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/index.ts Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/index.ts Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/index.ts Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/schema.json Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/schema.json Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/schema.json Outdated Show resolved Hide resolved
src/material/schematics/ng-generate/m3-theme/index.ts Outdated Show resolved Hide resolved
@devversion devversion removed their request for review March 25, 2024 10:36
@amysorto amysorto force-pushed the m3-schematic branch 2 times, most recently from a033492 to d1cc7ae Compare March 26, 2024 20:33
@amysorto amysorto requested a review from jelbourn as a code owner March 26, 2024 20:33
@josephperrott josephperrott removed their request for review April 11, 2024 18:43
guides/material-3.md Outdated Show resolved Hide resolved
@amysorto amysorto force-pushed the m3-schematic branch 4 times, most recently from a4384c4 to 78c7345 Compare April 16, 2024 18:08
@amysorto
Copy link
Contributor Author

I just changed the theme names from $m3-light-theme to $light-theme and $m3-dark-theme to $dark-theme.

Since in docs example the file is imported with @use instead of @import, you will need the namespace when using the variable. Removing the m3- prefix from the theme just makes it less repetitive. If left unaliased, the import would look like @use './path/to/m3-theme', and using the themes would look like m3-theme.$light-theme.

@amysorto amysorto force-pushed the m3-schematic branch 2 times, most recently from 2e464c9 to 8978c2d Compare April 16, 2024 20:29
Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add the new schematic to guides/schematics.md

guides/material-3.md Outdated Show resolved Hide resolved
guides/material-3.md Show resolved Hide resolved
… README and link to it from the m3 and schematics guide
@amysorto amysorto added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release merge: squash commits When the PR is merged, a squash and merge should be performed and removed target: patch This PR is targeted for the next patch release labels Apr 17, 2024
@amysorto amysorto removed the request for review from jelbourn April 17, 2024 18:33
@amysorto amysorto merged commit 295fd67 into angular:main Apr 17, 2024
32 checks passed
@userhv
Copy link

userhv commented Apr 25, 2024

[ERROR] "Calls to Angular Material theme mixins with an M3 theme must be wrapped in a selector"

theme.scss

@use '@angular/material' as mat;
@use '../m3-theme.scss' as my-theme;



@include mat.core();

// Apply the light theme by default
@include mat.core-theme(my-theme.$light-theme);
@include mat.button-theme(my-theme.$light-theme);

@amysorto
Copy link
Contributor Author

Hi @userhv, thanks for trying out M3! That error is specific to how you set up your theme.scss file not the schematic itself. So the calls to core-theme and button-theme need to be wrapped in a selector (wasn't required in M2, but is now in M3), for example your file might look like this:

@use '@angular/material' as mat;
@use '../m3-theme.scss' as my-theme;

@include mat.core();

html {
  // Apply the light theme by default
  @include mat.core-theme(my-theme.$light-theme);
  @include mat.button-theme(my-theme.$light-theme);
}

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: ng-generate Schematics that generate code in user projects detected: feature PR contains a feature commit merge: squash commits When the PR is merged, a squash and merge should be performed target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants