2019-10-20 16:59:02 +02:00
|
|
|
import React, { ReactNode } from "react";
|
|
|
|
|
import classNames from "classnames";
|
|
|
|
|
import styled from "styled-components";
|
2019-10-16 17:28:06 +02:00
|
|
|
|
|
|
|
|
const Flex = styled.div`
|
|
|
|
|
&.field:not(:last-child) {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
`;
|
2019-06-20 14:57:00 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
className?: string;
|
2019-10-20 16:59:02 +02:00
|
|
|
children: ReactNode;
|
2019-06-20 14:57:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ButtonAddons extends React.Component<Props> {
|
|
|
|
|
render() {
|
|
|
|
|
const { className, children } = this.props;
|
|
|
|
|
|
2019-10-20 16:59:02 +02:00
|
|
|
const childWrapper: ReactNode[] = [];
|
2019-06-20 14:57:00 +02:00
|
|
|
React.Children.forEach(children, child => {
|
|
|
|
|
if (child) {
|
2019-10-16 17:28:06 +02:00
|
|
|
childWrapper.push(
|
|
|
|
|
<p className="control" key={childWrapper.length}>
|
|
|
|
|
{child}
|
2019-10-20 16:59:02 +02:00
|
|
|
</p>
|
2019-10-16 17:28:06 +02:00
|
|
|
);
|
2019-06-20 14:57:00 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return (
|
2019-10-20 16:59:02 +02:00
|
|
|
<Flex className={classNames("field", "has-addons", className)}>
|
2019-06-20 14:57:00 +02:00
|
|
|
{childWrapper}
|
2019-10-16 17:28:06 +02:00
|
|
|
</Flex>
|
2019-06-20 14:57:00 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ButtonAddons;
|