-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3556 from jaytula/usestyles-node-actions
[RFR] Change to useStyles for NodeActions component
- Loading branch information
Showing
1 changed file
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
import React, { cloneElement, Children, Component } from 'react'; | ||
import React, { cloneElement, Children } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
const styles = theme => ({ | ||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
alignItems: 'center', | ||
marginLeft: 'auto', | ||
marginRight: theme.spacing(4), | ||
}, | ||
}); | ||
})); | ||
|
||
export class NodeActions extends Component { | ||
static propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
basePath: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
record: PropTypes.object.isRequired, | ||
resource: PropTypes.string.isRequired, | ||
}; | ||
function NodeActions({ children, classes: classesOverride, ...props }) { | ||
const classes = useStyles({ classes: classesOverride }); | ||
|
||
render() { | ||
const { children, classes, ...props } = this.props; | ||
return ( | ||
<span className={classes.root}> | ||
{Children.map(children, action => | ||
action ? cloneElement(action, props) : null | ||
)} | ||
</span> | ||
); | ||
} | ||
return ( | ||
<span className={classes.root}> | ||
{Children.map(children, action => | ||
action ? cloneElement(action, props) : null | ||
)} | ||
</span> | ||
); | ||
} | ||
|
||
export default withStyles(styles)(NodeActions); | ||
NodeActions.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
basePath: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
record: PropTypes.object.isRequired, | ||
resource: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default NodeActions; |