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

$mdThemingProvider backgroundPalette does not theme the background #1450

Closed

Description

@jaderabbit

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

Activity

  1. added this to the 0.9.0 milestone on Feb 10, 2015
  2. bonzanni commented on Feb 26, 2015

    @bonzanni

    It would be really great to have this working.

  3. ThomasBurleson commented on Feb 26, 2015

    @ThomasBurleson
    Contributor

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

  4. aneurysmjs commented on Feb 26, 2015

    @aneurysmjs

    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?

  5. gustavohenke commented on Mar 2, 2015

    @gustavohenke

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

  6. aneurysmjs commented on Mar 2, 2015

    @aneurysmjs

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

  7. Hendrixer commented on Mar 9, 2015

    @Hendrixer

    👍

  8. arshabh commented on Mar 18, 2015

    @arshabh
    Contributor

    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

  9. ppkn commented on Mar 31, 2015

    @ppkn

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

  10. arshabh commented on Mar 31, 2015

    @arshabh
    Contributor

    @dpipkin it is on backgroundPalette

  11. aneurysmjs commented on Mar 31, 2015

    @aneurysmjs

    backgroundPalette :)

  12. ppkn commented on Mar 31, 2015

    @ppkn

    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.

  13. rschmukler commented on Apr 2, 2015

    @rschmukler
    Contributor

    @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

  14. added a commit that references this issue on Apr 8, 2015
    0df4b16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions