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

MUITheme needs to affect Login as it does for the rest of the Application #2368

Closed
zifnab87 opened this issue Sep 30, 2018 · 5 comments
Closed
Assignees
Labels

Comments

@zifnab87
Copy link
Contributor

zifnab87 commented Sep 30, 2018

Is your feature request related to a problem? Please describe.
Adding a Mui theme on <Admin> using theme={customTheme} doesn't affect Login

image

image

Describe the solution you'd like
Adding a MUI theme like that would affect Login as it does with the rest of the Application:

const customTheme = createMuiTheme({
    palette: {
        primary: {
            light: '#ffcc00',
            main: '#ff9900',
            dark: "#cc6600",
            contrastText: '#ffffff',
        },
        secondary: {
            light: '#ffcc00',
            main: '#ff9900',
            dark: "#cc6600",
            contrastText: '#ffffff',
        },
    },
});
<Admin
        theme={customTheme} [...] >
     [....]
</Admin>

Something that looks like:
image

Describe alternatives you've considered
Using withStyles feels hacky and it is difficult to change error color, labels when inputs are on focus etc

import React from 'react';
import { Login, LoginForm } from 'react-admin';
import { withStyles } from '@material-ui/core';
import customTheme from '../theme';

const styles = ({
    main: { background: '#333' },
    avatar: {
        background: 'url(//cdn.example.com/background.jpg)',
        backgroundRepeat: 'no-repeat',
        backgroundSize: 'contain',
        height: 80,
    },
    icon: { display: 'none' },
});

const CustomLoginForm = withStyles({
    button: { 
        background: customTheme.palette.primary.light, 
        '&:hover': { background: customTheme.palette.primary.main } 
    },
})(LoginForm);

const CustomLoginPage = props => (
    <Login
        loginForm={<CustomLoginForm theme={customTheme}/>}
        {...props}
    />
);

export default withStyles(styles)(CustomLoginPage);
<Admin
        loginPage={CustomLoginPage} [...] > 
    [...] 
</Admin>
@zifnab87 zifnab87 changed the title MUITheme needs to affect Login MUITheme needs to affect Login as it does for the rest of the Application Sep 30, 2018
@fzaninotto fzaninotto added the bug label Oct 1, 2018
@trsteel88
Copy link

Is there a solution to bring the theme through that is defined in app.js?

I tried using what's in the demo (https://github.com/marmelab/react-admin/blob/master/examples/demo/src/Login.js) but it doesn't match my app theme.

@fzaninotto fzaninotto self-assigned this Nov 29, 2018
fzaninotto added a commit that referenced this issue Nov 29, 2018
@Kmaschta
Copy link
Contributor

Fixed by #2591

@trsteel88
Copy link

trsteel88 commented Dec 2, 2018

If I don't set a theme, the login page still comes through as pink (and the logged in areas with a blue header).

Am I missing something?

@fzaninotto
Copy link
Member

@trsteel88 The new default login page does support theming in react-admin 2.5. If you created your own Login page, you should decorate it with MuiThemeProvider. I'll update the Authentication docs accordingly.

@trsteel88
Copy link

Thanks. Works with the new docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants