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

[RFR] Change to useStyles for Confirm component #3557

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions packages/ra-ui-materialui/src/layout/Confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,34 @@ import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import Button from '@material-ui/core/Button';
import { withStyles, createStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import { fade } from '@material-ui/core/styles/colorManipulator';
import ActionCheck from '@material-ui/icons/CheckCircle';
import AlertError from '@material-ui/icons/ErrorOutline';
import classnames from 'classnames';
import { useTranslate } from 'ra-core';

const styles = theme =>
createStyles({
contentText: {
minWidth: 400,
},
confirmPrimary: {
color: theme.palette.primary.main,
},
confirmWarning: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
const useStyles = makeStyles(theme => ({
contentText: {
minWidth: 400,
},
confirmPrimary: {
color: theme.palette.primary.main,
},
confirmWarning: {
color: theme.palette.error.main,
'&:hover': {
backgroundColor: fade(theme.palette.error.main, 0.12),
// Reset on mouse devices
'@media (hover: none)': {
backgroundColor: 'transparent',
},
},
iconPaddingStyle: {
paddingRight: '0.5em',
},
});
},
iconPaddingStyle: {
paddingRight: '0.5em',
},
}));

/**
* Confirmation dialog
Expand All @@ -60,9 +59,10 @@ const Confirm = ({
confirmColor,
onClose,
onConfirm,
classes,
classes: classesOverride,
translateOptions = {},
}) => {
const classes = useStyles({ classes: classesOverride });
const [loading, setLoading] = useState(false);
const translate = useTranslate();

Expand Down Expand Up @@ -116,7 +116,7 @@ const Confirm = ({

Confirm.propTypes = {
cancel: PropTypes.string.isRequired,
classes: PropTypes.object.isRequired,
classes: PropTypes.object,
confirm: PropTypes.string.isRequired,
confirmColor: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
Expand All @@ -134,4 +134,4 @@ Confirm.defaultProps = {
isOpen: false,
};

export default withStyles(styles)(Confirm);
export default Confirm;