material icon indicating copy to clipboard operation
material copied to clipboard

$mdThemingProvider backgroundPalette does not theme the background

Open jaderabbit opened this issue 11 years ago • 12 comments

I configure the theme provider as follows:

$mdThemingProvider
            .theme('default')
            .primaryPalette('deep-orange', {
                'default': '900',
                'hue-2': '500'
            })
            .backgroundPalette('grey', {
                'default': '200'
            })
            .accentPalette('orange');

But the background remain's white

jaderabbit avatar Feb 10 '15 10:02 jaderabbit

It would be really great to have this working.

bonzanni avatar Feb 26 '15 00:02 bonzanni

@rschmukler - any interim thoughts while we resolve this for 0.9.x ?

ThomasBurleson avatar Feb 26 '15 04:02 ThomasBurleson

it takes the 'A100' value when you set the backgroundPalette, so maybe an easy workaround will be that you can put the background color on the 'A100' while this get fix... what do u think?

aneurysmjs avatar Feb 26 '15 19:02 aneurysmjs

@blackendstudios that trick helped me, but I rather use something less "hacky", so I'll just :+1: this issue.

gustavohenke avatar Mar 02 '15 12:03 gustavohenke

ohhhh glad that helped...it was my firts contribution on git hubjajajaja ...great...hope to help more in the future

aneurysmjs avatar Mar 02 '15 13:03 aneurysmjs

:+1:

Hendrixer avatar Mar 09 '15 05:03 Hendrixer

This issue is similar to #1321 . The reason why it takes the 'A100' value always is because it is the default color for 'hue-3'. Below is the excerpt from theming.js

THEME_COLOR_TYPES.forEach(function(colorType) {
  // Color types with unspecified default hues will use these default hue values
  var defaultDefaultHues = {
    'default': '500',
    'hue-1': '300',
    'hue-2': '800',
    'hue-3': 'A100'
  };
  if (!LIGHT_DEFAULT_HUES[colorType]) LIGHT_DEFAULT_HUES[colorType] = defaultDefaultHues;
  if (!DARK_DEFAULT_HUES[colorType]) DARK_DEFAULT_HUES[colorType] = defaultDefaultHues;
});

And after digging in the code i found that the theme sass files for components have hard coded background color as:

md-content.md-THEME_NAME-theme {
  background-color: '{{background-hue-3}}';
}

The above example is from content-theme.scss. Similar mention is also found in other theme files like dialog-theme.scss, sidenav-theme.scss, slider-theme.scss and subheader-theme.scss.

The solution that i propose for this is something like this

md-content.md-THEME_NAME-theme {
  background-color: '{{background-color}}';
}

This has started working for me in my local build. But i guess the solution would be more comprehensive - providing background capabilities in a more generic manner. Just putting it out there. Hope it helps

arshabh avatar Mar 18 '15 09:03 arshabh

@blackendstudios Do you change the 'A100' value on primaryPalette or accentPalette?

ppkn avatar Mar 31 '15 17:03 ppkn

@dpipkin it is on backgroundPalette

arshabh avatar Mar 31 '15 19:03 arshabh

backgroundPalette :)

aneurysmjs avatar Mar 31 '15 19:03 aneurysmjs

Awesome! Thank you.
The hacky way that I made it work:

var background = $mdThemingProvider.extendPalette('grey', {
  'A100': 'f2f2f2'
});
$mdThemingProvider.definePalette('background', background);
$mdThemingProvider.theme('default')

...

  .backgroundPalette('background');

I hope that isn't too roundabout.

ppkn avatar Mar 31 '15 22:03 ppkn

@dpipkin that is the proper way to achieve this. Waiting on #1950 to see if a clearer way emerges from it.

Closing this issue for now, but follow #1950 to see a potential enhancement

rschmukler avatar Apr 02 '15 16:04 rschmukler