@blockstack/ui
Version:
Blockstack UI components built using React and styled-components with styled-system.
50 lines (43 loc) • 1.66 kB
JavaScript
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { Children, cloneElement } from 'react';
import { Box } from '../box/index.esm.js';
var ButtonGroup = function ButtonGroup(_ref) {
var size = _ref.size,
variantColor = _ref.variantColor,
variant = _ref.variant,
isAttached = _ref.isAttached,
_ref$spacing = _ref.spacing,
spacing = _ref$spacing === void 0 ? 2 : _ref$spacing,
children = _ref.children,
rest = _objectWithoutPropertiesLoose(_ref, ["size", "variantColor", "variant", "isAttached", "spacing", "children"]);
var clones = Children.map(children, function (child, index) {
var isFirst = index === 0;
var isLast = index === Children.count(children) - 1;
if (!React__default.isValidElement(child)) {
return null;
}
return cloneElement(child, _objectSpread2({
size: size || child.props.size,
variantColor: child.props.variantColor || variantColor,
variant: child.props.variant || variant,
_focus: {
boxShadow: 'outline',
zIndex: 1
}
}, !isLast && !isAttached && {
mr: spacing
}, {}, isFirst && isAttached && {
roundedRight: 0
}, {}, isLast && isAttached && {
roundedLeft: 0
}, {}, !isFirst && !isLast && isAttached && {
rounded: 0
}));
});
return React__default.createElement(Box, Object.assign({
display: "inline-block"
}, rest), clones);
};
ButtonGroup.displayName = 'ButtonGroup';
export { ButtonGroup };
//# sourceMappingURL=index.esm.js.map