Files
SCM-Manager/scm-ui/ui-components/src/buttons/ButtonAddons.js

41 lines
790 B
JavaScript
Raw Normal View History

2019-06-20 14:57:00 +02:00
// @flow
import * as React from "react";
import classNames from "classnames";
2019-10-16 17:28:06 +02:00
import styled from "styled-components";
const Flex = styled.div`
&.field:not(:last-child) {
margin-bottom: 0;
}
`;
2019-06-20 14:57:00 +02:00
type Props = {
className?: string,
children: React.Node
};
class ButtonAddons extends React.Component<Props> {
render() {
const { className, children } = this.props;
2019-06-25 12:54:20 +02:00
const childWrapper = [];
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}
</p>
);
2019-06-20 14:57:00 +02:00
}
});
return (
2019-10-16 17:28:06 +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;