-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionButtons.js
42 lines (37 loc) · 1022 Bytes
/
ActionButtons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
export default class ActionButtons extends React.Component {
addButtonClassToChildren = () => {
return React.Children.map(this.props.children, (item) => {
const className = classnames(
item.props.className, 'mdc-card__action', 'mdc-card__action--button');
const props = Object.assign({}, item.props, {className});
return React.cloneElement(item, props);
});
};
render() {
const {
className,
children, // eslint-disable-line no-unused-vars
...otherProps
} = this.props;
const classes = classnames('mdc-card__action-buttons', className);
return (
<div
className={classes}
{...otherProps}
>
{this.addButtonClassToChildren()}
</div>
);
}
}
ActionButtons.propTypes = {
className: PropTypes.string,
children: PropTypes.node,
};
ActionButtons.defaultProps = {
className: '',
children: null,
};