Skip to content

Commit

Permalink
Rollback MuiThemeProvider => ThemeProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed May 7, 2019
1 parent 32e22a9 commit 1881da3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ For more details on predefined themes and custom themes, refer to the [Material

## `appLayout`

If you want to deeply customize the app header, the menu, or the notifications, the best way is to provide a custom layout component. It must contain a `{children}` placeholder, where react-admin will render the resources. If you use material UI fields and inputs, it should contain a `<ThemeProvider>` element. And finally, if you want to show the spinner in the app header when the app fetches data in the background, the Layout should connect to the redux store.
If you want to deeply customize the app header, the menu, or the notifications, the best way is to provide a custom layout component. It must contain a `{children}` placeholder, where react-admin will render the resources. If you use material UI fields and inputs, it should contain a `<MuiThemeProvider>` element. And finally, if you want to show the spinner in the app header when the app fetches data in the background, the Layout should connect to the redux store.

Use the [default layout](https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/layout/Layout.js) as a starting point, and check [the Theming documentation](./Theming.md#using-a-custom-layout) for examples.

Expand Down
6 changes: 3 additions & 3 deletions docs/Authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ For all these cases, it's up to you to implement your own `LoginPage` component,
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { userLogin } from 'react-admin';
import { ThemeProvider } from '@material-ui/styles';
import { MuiThemeProvider } from '@material-ui/core/styles';

class MyLoginPage extends Component {
submit = (e) => {
Expand All @@ -263,11 +263,11 @@ class MyLoginPage extends Component {

render() {
return (
<ThemeProvider theme={this.props.theme}>
<MuiThemeProvider theme={this.props.theme}>
<form onSubmit={this.submit}>
...
</form>
</ThemeProvider>
</MuiThemeProvider>
);
}
};
Expand Down
6 changes: 3 additions & 3 deletions docs/CustomApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ import { createHashHistory } from 'history';
+import { TranslationProvider, Resource } from 'react-admin';
import restProvider from 'ra-data-simple-rest';
import defaultMessages from 'ra-language-english';
+import { ThemeProvider } from '@material-ui/styles';
+import { MuiThemeProvider } from '@material-ui/core/styles';
+import AppBar from '@material-ui/core/AppBar';
+import Toolbar from '@material-ui/core/Toolbar';
+import Typography from '@material-ui/core/Typography';
Expand Down Expand Up @@ -202,7 +202,7 @@ const App = () => (
- <Resource name="comments" list={CommentList} edit={CommentEdit} create={CommentCreate} />
- <Resource name="users" list={UserList} edit={UserEdit} create={UserCreate} />
+ <TranslationProvider>
+ <ThemeProvider>
+ <MuiThemeProvider>
+ <Resource name="posts" intent="registration" />
+ <Resource name="comments" intent="registration" />
+ <Resource name="users" intent="registration" />
Expand All @@ -228,7 +228,7 @@ const App = () => (
+ <Route exact path="/users/:id" render={(routeProps) => <UsersEdit resource="users" {...routeProps} />} />
+ </Switch>
+ </ConnectedRouter>
+ </ThemeProvider>
+ </MuiThemeProvider>
+ </TranslationProvider>
- </Admin>
</Provider>
Expand Down
2 changes: 1 addition & 1 deletion docs/Theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withStyles, createMuiTheme } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import { MuiThemeProvider } from '@material-ui/Core/styles';
import {
AppBar,
Menu,
Expand Down
8 changes: 4 additions & 4 deletions examples/demo/src/layout/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CardActions from '@material-ui/core/CardActions';
import CircularProgress from '@material-ui/core/CircularProgress';
import TextField from '@material-ui/core/TextField';
import { createMuiTheme, withStyles } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/core/styles';
import { MuiThemeProvider } from '@material-ui/core/styles';
import LockIcon from '@material-ui/icons/Lock';

import { Notification, useTranslate, translate, userLogin } from 'react-admin';
Expand Down Expand Up @@ -165,13 +165,13 @@ const enhance = compose(

const EnhancedLogin = enhance(Login);

// We need to put the ThemeProvider decoration in another component
// We need to put the MuiThemeProvider decoration in another component
// Because otherwise the withStyles() HOC used in EnhancedLogin won't get
// the right theme
const LoginWithTheme = props => (
<ThemeProvider theme={createMuiTheme(lightTheme)}>
<MuiThemeProvider theme={createMuiTheme(lightTheme)}>
<EnhancedLogin {...props} />
</ThemeProvider>
</MuiThemeProvider>
);

export default LoginWithTheme;
2 changes: 0 additions & 2 deletions packages/ra-ui-materialui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"devDependencies": {
"@material-ui/core": "^4.0.0-beta.0",
"@material-ui/styles": "^4.0.0-beta.0",
"@material-ui/icons": "^4.0.0-beta.0",
"cross-env": "^5.2.0",
"enzyme": "~3.9.0",
Expand All @@ -45,7 +44,6 @@
},
"dependencies": {
"@material-ui/core": "^4.0.0-beta.0",
"@material-ui/styles": "^4.0.0-beta.0",
"@material-ui/icons": "^4.0.0-beta.0",
"autosuggest-highlight": "^3.1.1",
"classnames": "~2.2.5",
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-ui-materialui/src/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
WithStyles,
Theme,
} from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import { MuiThemeProvider } from '@material-ui/core/styles';
import LockIcon from '@material-ui/icons/Lock';
import { StaticContext } from 'react-router';

Expand Down Expand Up @@ -121,7 +121,7 @@ class Login extends Component<
} = this.props;

return (
<ThemeProvider theme={this.theme}>
<MuiThemeProvider theme={this.theme}>
<div
className={classnames(classes.main, className)}
{...rest}
Expand All @@ -137,7 +137,7 @@ class Login extends Component<
</Card>
<Notification />
</div>
</ThemeProvider>
</MuiThemeProvider>
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-ui-materialui/src/layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
withStyles,
createStyles,
} from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import { MuiThemeProvider } from '@material-ui/core/styles';
import compose from 'recompose/compose';
import { ComponentPropType } from 'ra-core';

Expand Down Expand Up @@ -187,9 +187,9 @@ class LayoutWithTheme extends Component {
render() {
const { theme, ...rest } = this.props;
return (
<ThemeProvider theme={this.theme}>
<MuiThemeProvider theme={this.theme}>
<EnhancedLayout {...rest} />
</ThemeProvider>
</MuiThemeProvider>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@
dependencies:
"@babel/runtime" "^7.2.0"

"@material-ui/styles@^4.0.0-beta.0", "@material-ui/styles@^4.0.0-beta.1":
"@material-ui/styles@^4.0.0-beta.1":
version "4.0.0-beta.1"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.0.0-beta.1.tgz#a552fe402763f0579cbd39e79a9e42fbf6762139"
integrity sha512-k41Xw6U6CHLNupWMCcc5w7AONNddsZVTUL7qe6nIMWZeBdLxX77N/nNZBq5sU2aFY5sShB8JwXK5X/xhDNfPgg==
Expand Down

0 comments on commit 1881da3

Please sign in to comment.