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

Theme documentation doesn't work #6063

Closed
ghost opened this issue Jul 26, 2017 · 10 comments
Closed

Theme documentation doesn't work #6063

ghost opened this issue Jul 26, 2017 · 10 comments

Comments

@ghost
Copy link

ghost commented Jul 26, 2017

Bug, feature request, or proposal:

BUG

What is the expected behavior?

Documentation does not specify where to include your custom color theme.scss file.

What is the current behavior?

Error Could not find Angular Material core theme

What are the steps to reproduce?

Follow these instructions:
https://material.angular.io/guide/theming

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U

What is the use-case or motivation for changing an existing behavior?

I want to modify fonts and colors using scss before any components or modules are loaded throwing the above error.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Every version including the latest.

Is there anything else we should know?

Your documentation is wrong or got left behind the most up to date procedures.

@willshowell
Copy link
Contributor

Assuming this is somewhat in response to this #2800 (comment)...

You must @include mat-core() exactly once, and if you follow the guide, you will have done that.

@ghost
Copy link
Author

ghost commented Jul 26, 2017

@willshowell What file do I include @include mat-cor() in?

@willshowell
Copy link
Contributor

This is the setup we've opted for:

// in styles/_custom_theme.scss
@import '~@angular/material/theming';

$primary: ...
$accent: ...
$warn: ...

$theme: mat-light-theme(...)
// in styles/required.scss
@import 'custom-theme';

@include mat-core();
@include angular-material-theme($theme);

// other global styles
// in .angular-cli.json

"apps": [{
  ...

  "styles": [
    "style/required.scss"
  ],
  "stylePreprocessorOptions": {
    "includePaths": [ "style" ]
  },

  ...
}]

@ghost
Copy link
Author

ghost commented Jul 26, 2017

Beautiful! So angular-cli does compile scss files. Where is the documentation for that?

#6068

@maxisam
Copy link

maxisam commented Aug 30, 2017

Weird, I have above settings but it still showing the warning with AngularCli 1.3.2. But all my material ui work correctly with my customized theme.

I wonder if anyone has the same issue.

update:

Ok, I figured out.

I put it like

.main-theme {
  @include angular-material-theme($main-theme);
}

So I can dynamic change theme. However, it is the reason causing the issue.

Apparently, angular-material doesn't like this nesting setup.

So the real question is how to dynamically change the theme properly?

@ghost
Copy link
Author

ghost commented Aug 30, 2017 via email

@maxisam
Copy link

maxisam commented Aug 30, 2017

@megamindbrian what is colors-theme.scss? I don't see anything about it.

@ghost
Copy link
Author

ghost commented Aug 30, 2017 via email

@maxisam
Copy link

maxisam commented Aug 30, 2017

@megamindbrian I think inline @import works fine.

@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 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants