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] Theme not applied, don't understand why (w/ code) #1938

Closed
pandaiolo opened this issue Oct 20, 2015 · 3 comments
Closed

[Theme] Theme not applied, don't understand why (w/ code) #1938

pandaiolo opened this issue Oct 20, 2015 · 3 comments
Labels
customization: theme Centered around the theming features

Comments

@pandaiolo
Copy link
Contributor

Hi,

I am trying to change the color of the "primary" button, among other things. As per the docs, I proceeded as following:

File Theme.js :

export default {
    spacing: spacing, // defined in same file
    fontFamily: 'Roboto, sans-serif',
    palette: {
        primary1Color: Colors.blue500, // changed
        primary2Color: Colors.blue700, // changed
        primary3Color: Colors.lightBlack,
        accent1Color: Colors.blueA200, // changed
        accent2Color: Colors.grey100,
        accent3Color: Colors.grey500,
        textColor: Colors.darkBlack,
        alternateTextColor: Colors.white,
        canvasColor: Colors.white,
        borderColor: Colors.grey100,
        disabledColor: ColorManipulator.fade(Colors.darkBlack, 0.3)
    }
};

In my <App> Component :

import ThemeManager from 'material-ui/lib/styles/theme-manager';
import Theme from './Theme';
[...]
let App = React.createClass({
    [...]
    childContextTypes: {
        muiTheme: React.PropTypes.object
    },
    [...]
    getChildContext() {
        return {
            muiTheme: ThemeManager.getMuiTheme(Theme)
        };
    },

All other components are children of App, yet, don't seem to get the modified theme.

Any hint ?

Thanks

@pandaiolo
Copy link
Contributor Author

k, I did not see all these warnings in my console :

Warning: owner-based and parent-based contexts differ (values:undefinedvs[object Object]) for key (muiTheme) while mounting XXXXX (see: http://fb.me/react-context-by-parent)

XXXX being sub components of my app.

Not sure how to fix that. Do I have to repeat childContextTypes and getChildContext() in every intermediate component between App and XXX - XXX being a Mui component ?

EDIT: Ok, when childContextTypes and getChildContext() are included in a component using Mui component, it seems to fix the issue (warnings and theme not being applied).

This is a bit cumbersome though, is there any way of declaring a theme globally ?

Thanks

@c0b41
Copy link

c0b41 commented Oct 21, 2015

create mixins and added component?

@pandaiolo
Copy link
Contributor Author

I did that more or less, thanks !

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
Bumps [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/HEAD/packages/eslint-plugin-react-hooks) from 1.7.0 to 4.0.4.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/HEAD/packages/eslint-plugin-react-hooks)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
@zannager zannager added the customization: theme Centered around the theming features label Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features
Projects
None yet
Development

No branches or pull requests

3 participants