clarified ButtonGroup vs ButtonAddons

This commit is contained in:
Florian Scholdei
2019-06-20 14:57:00 +02:00
parent 9c787d99ea
commit a9e89313bc
9 changed files with 53 additions and 39 deletions

View File

@@ -3,39 +3,24 @@ import * as React from "react";
import classNames from "classnames";
type Props = {
connected?: boolean,
addons?: boolean,
className?: string,
children: React.Node
};
class ButtonGroup extends React.Component<Props> {
static defaultProps = {
addons: true
};
render() {
const {connected, addons, className, children} = this.props;
const { 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>
);
}
var childWrapper = [];
React.Children.forEach(children, child => {
if (child) {
childWrapper.push(<p className="control">{child}</p>);
}
});
return (
<div className={classNames("buttons", addons ? "has-addons" : "", className)}>
{children}
<div className={classNames("field", "is-grouped", className)}>
{childWrapper}
</div>
);
}