2019-01-29 11:06:11 +01:00
|
|
|
// @flow
|
2019-02-07 09:29:53 +01:00
|
|
|
import * as React from "react";
|
2019-06-20 13:40:12 +02:00
|
|
|
import classNames from "classnames";
|
2019-01-29 11:06:11 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-06-20 13:40:12 +02:00
|
|
|
connected?: boolean,
|
2019-02-07 09:29:53 +01:00
|
|
|
addons?: boolean,
|
|
|
|
|
className?: string,
|
|
|
|
|
children: React.Node
|
2019-01-29 11:06:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ButtonGroup extends React.Component<Props> {
|
|
|
|
|
|
2019-02-07 09:29:53 +01:00
|
|
|
static defaultProps = {
|
|
|
|
|
addons: true
|
|
|
|
|
};
|
2019-01-29 11:06:11 +01:00
|
|
|
|
2019-02-07 09:29:53 +01:00
|
|
|
render() {
|
2019-06-20 13:40:12 +02:00
|
|
|
const {connected, addons, className, children} = this.props;
|
|
|
|
|
|
|
|
|
|
if (!connected) {
|
|
|
|
|
var childWrapper = [];
|
|
|
|
|
React.Children.forEach(children, child => {
|
|
|
|
|
if (child) {
|
|
|
|
|
childWrapper.push(<p className="control">{child}</p>);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={classNames("field", "is-grouped", className)}>
|
|
|
|
|
{childWrapper}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2019-01-29 11:06:11 +01:00
|
|
|
}
|
2019-06-20 13:40:12 +02:00
|
|
|
|
2019-01-29 11:06:11 +01:00
|
|
|
return (
|
2019-06-20 13:40:12 +02:00
|
|
|
<div className={classNames("buttons", addons ? "has-addons" : "", className)}>
|
|
|
|
|
{children}
|
2019-01-29 11:06:11 +01:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ButtonGroup;
|