Skip to content

Commit

Permalink
Change to useStyles for Error component
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytula committed Aug 21, 2019
1 parent 875d719 commit cae91b5
Showing 1 changed file with 41 additions and 34 deletions.
75 changes: 41 additions & 34 deletions packages/ra-ui-materialui/src/layout/Error.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,59 @@ import Button from '@material-ui/core/Button';
import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import { withStyles, createStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import ErrorIcon from '@material-ui/icons/Report';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import History from '@material-ui/icons/History';

import Title, { TitlePropType } from './Title';
import { useTranslate } from 'ra-core';

const styles = theme =>
createStyles({
container: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
[theme.breakpoints.down('sm')]: {
padding: '1em',
},
fontFamily: 'Roboto, sans-serif',
opacity: 0.5,
const useStyles = makeStyles(theme => ({
container: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
[theme.breakpoints.down('sm')]: {
padding: '1em',
},
title: {
display: 'flex',
alignItems: 'center',
},
icon: {
width: '2em',
height: '2em',
marginRight: '0.5em',
},
panel: {
marginTop: '1em',
},
panelDetails: {
whiteSpace: 'pre-wrap',
},
toolbar: {
marginTop: '2em',
},
});
fontFamily: 'Roboto, sans-serif',
opacity: 0.5,
},
title: {
display: 'flex',
alignItems: 'center',
},
icon: {
width: '2em',
height: '2em',
marginRight: '0.5em',
},
panel: {
marginTop: '1em',
},
panelDetails: {
whiteSpace: 'pre-wrap',
},
toolbar: {
marginTop: '2em',
},
}));

function goBack() {
window.history.go(-1);
}

const Error = ({ error, errorInfo, classes, className, title, ...rest }) => {
const Error = ({
error,
errorInfo,
classes: classesOverride,
className,
title,
...rest
}) => {
const classes = useStyles({ classes: classesOverride });
const translate = useTranslate();
return (
<Fragment>
Expand Down Expand Up @@ -96,4 +103,4 @@ Error.propTypes = {
title: TitlePropType,
};

export default withStyles(styles)(Error);
export default Error;

0 comments on commit cae91b5

Please sign in to comment.