@bigfishtv/cockpit
Version:
32 lines (28 loc) • 636 B
JavaScript
import PropTypes from 'prop-types'
import React, { Component, Children } from 'react'
/**
* Wraps children (buttons) in a 'button-group' div
*/
export default class ButtonGroup extends Component {
static propTypes = {
/** button size prop that will overwrite children button sizes */
size: PropTypes.string,
}
static defaultProps = {
size: 'medium',
}
render() {
return (
<div className="button-group">
{Children.toArray(this.props.children)
.filter(child => child)
.map((child, i) =>
React.cloneElement(child, {
key: i,
size: this.props.size,
})
)}
</div>
)
}
}