Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

how to disable theming globally? #943

Closed
haoxins opened this issue Dec 15, 2014 · 15 comments
Closed

how to disable theming globally? #943

haoxins opened this issue Dec 15, 2014 · 15 comments

Comments

@haoxins
Copy link

haoxins commented Dec 15, 2014

Is it possiable to add a option to enable/disable theming globally

@mzbyszynski
Copy link
Contributor

Hi @coderhaoxin,

the md-theme="green" attribute mainly just adds the correct theme class to the element the attribute is defined for, so md-theme="green" would the class md-green-theme. If you want to force an element back to the default theme (because it is inheriting the theme from a parent element), you would just need md-theme="default". If you want no theme styles at all, then you just need to set md-theme to point to a theme that doesn't exist. For example, md-theme="none" would add the md-none-theme class to your element. Since that class is not actually defined in the css anywhere, no theming styles would be applied.

Hope that helps!

-Marc

ps. One more word of caution about this solution: The themeing api is still under discussion (see #537 for example), so while the above solution works now, it could very well change in the near future. Good luck!

@haoxins
Copy link
Author

haoxins commented Dec 15, 2014

thanks. But I want to disable theming globally.

@haoxins haoxins changed the title how to disable theming? how to disable theming globally? Dec 15, 2014
@mzbyszynski
Copy link
Contributor

There is no way to turn theming off globally that I know of, but you could change the default theme to a non-existent one globally by configuring the $mdThemingProvider:

app.config(function($mdThemingProvider) {
  $mdThemingProvider.setDefaultTheme('none');
});

@haoxins
Copy link
Author

haoxins commented Dec 16, 2014

yeah, it works.

@haoxins haoxins closed this as completed Dec 16, 2014
@DominicBoettger
Copy link

Sorry to mention this again, but i don't like that behaviour. I think these theming stuff should be done via SASS and not be injected via javascript. Even when setting it to 'none' the default theme will be injected.
In my opinion there should be a body class or Attributewhich toggles the default theme.
Everything else could be done via sass and even the material color stuff can be calculated there. The performance would be much better as i can see all the stuff going in the head section when loading material....

@sergonius
Copy link

Yeah, at least "none" should remove the default, it is a pain to inspect everything and override a large amount of styles. A SASS config and more control over this would make the whole thing more usable.

@mackelito
Copy link

Would kind of like to bring this question/issue back to life..
I don't think that the concept of setting theme to none/null/whatever is a proper solution.

All things needed for the themes are still loaded and executed. Surely there must/should be away to really disable it?

@DominicBoettger
Copy link

I am pretty sure that material is doing too much stuff in js at the moment. I think there would be a dramatic performance increase when doing layout and theming stuff in scss. I am using stuff like sass-material-colors in my themes and i am also able to define a lot of stuff. I also had issues with browser compatibily which i solved in scss with bourbon.

@mackelito
Copy link

And it you are not using themes in this matter?... What if you don't benefit from the themes?... Just think there would be an option to disable it..

@DominicBoettger
Copy link

I think it's a misunderstanding. I want to be able to disable the themes in javascript and write the theme information in SCSS.

👍 for doing something like $mdThemingProvider.setDefaultTheme('none');

@mackelito
Copy link

When you specify it like $mdThemingProvider.setDefaultTheme('none'); it will still look for a theme with the name "none". And it will add a lot of references to your "none" theme..

So you are not disabling themes you are just calling a none existing theme ;)

@DominicBoettger
Copy link

Yes, i know.... The idea was that i think that it should be possible to completely disable the theme.

@mackelito
Copy link

A member of our team just found out that can override the constans.

// Setting this will result in not adding theme classes on components
.constant("$MD_THEME_CSS","");

Try it out and tell us if it works for you!

@DominicBoettger
Copy link

That helped a lot. Thanks.
Did someone already implement all the structures in sass?

ThomasBurleson added a commit that referenced this issue Apr 11, 2016
Support config-time disabling of Theming which in turn prevents
dynamic theme css generation and stylesheet injections.

```js
angular
   .module('myApp',['ngMaterial'])
   .config(['$mdThemingProvider', function($mdThemingProvider ){
      $mdThemingProvider.disableTheming();
   }]);
```

Refs #943. Closes #7959.
ilovett pushed a commit to ilovett/material that referenced this issue Apr 22, 2016
Support config-time disabling of Theming which in turn prevents
dynamic theme css generation and stylesheet injections.

```js
angular
   .module('myApp',['ngMaterial'])
   .config(['$mdThemingProvider', function($mdThemingProvider ){
      $mdThemingProvider.disableTheming();
   }]);
```

Refs angular#943. Closes angular#7959.
@luncht1me
Copy link

@mackelito Thank you for that constant! We're using angular-material for the first time at my company, and our css guy doesn't really like overwriting styles but rather structure his own from the ground up.

This has helped a lot!

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

6 participants