@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
29 lines (26 loc) • 1.24 kB
JavaScript
import React, { Children } from 'react';
import cx from 'classnames';
import GhostButton from './GhostButton/index.js';
import InversedButton from './InversedButton/index.js';
import DefaultButton from './DefaultButton/index.js';
const isButton = (component) => React.isValidElement(component) &&
(component.type === GhostButton ||
component.type === GhostButton.Link ||
component.type === InversedButton ||
component.type === InversedButton.Link ||
component.type === DefaultButton ||
component.type === DefaultButton.Link);
const ButtonsGroup = ({ className, children, align }) => (React.createElement("div", { className: cx(className, "cobalt-buttons-group", {
"cobalt-buttons-group--right": align === "right",
"cobalt-buttons-group--center": align === "center",
}) }, Children.toArray(children).map((child, index) => isButton(child)
? React.cloneElement(child, {
key: index,
className: cx("cobalt-buttons-group__item", {
"cobalt-buttons-group__item--fullWidth": align === "fullWidth",
}),
fullWidth: align === "fullWidth",
})
: child)));
export { ButtonsGroup as default };
//# sourceMappingURL=ButtonsGroup.js.map