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 CardContentInner component #3559

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: 27 additions & 21 deletions packages/ra-ui-materialui/src/layout/CardContentInner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import CardContent from '@material-ui/core/CardContent';
import { withStyles, createStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';

var styles = theme =>
createStyles({
root: {
paddingTop: 0,
paddingBottom: 0,
'&:first-child': {
paddingTop: 16,
},
'&:last-child': {
paddingBottom: 16,
[theme.breakpoints.only('xs')]: {
paddingBottom: 70,
},
var useStyles = makeStyles(theme => ({
root: {
paddingTop: 0,
paddingBottom: 0,
'&:first-child': {
paddingTop: 16,
},
'&:last-child': {
paddingBottom: 16,
[theme.breakpoints.only('xs')]: {
paddingBottom: 70,
},
},
});
},
}));

/**
* Overrides material-ui CardContent to allow inner content
Expand All @@ -28,16 +27,23 @@ var styles = theme =>
* padding double the spacing between each CardContent, leading to too much
* wasted space. Use this component as a CardContent alternative.
*/
const CardContentInner = ({ classes, className, children }) => (
<CardContent className={classnames(classes.root, className)}>
{children}
</CardContent>
);
const CardContentInner = ({
classes: classesOverride,
className,
children,
}) => {
const classes = useStyles({ classes: classesOverride });
return (
<CardContent className={classnames(classes.root, className)}>
{children}
</CardContent>
);
};

CardContentInner.propTypes = {
className: PropTypes.string,
classes: PropTypes.object.isRequired,
children: PropTypes.node,
};

export default withStyles(styles)(CardContentInner);
export default CardContentInner;