@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
39 lines (37 loc) • 1.63 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import { warning } from "@kiwicom/js";
import defaultTheme from "../defaultTheme";
import { StyledButtonLink } from "../ButtonLink";
import { StyledButton } from "../Button";
import { borderRadius, rtlSpacing } from "../utils/rtl";
const StyledButtonGroup = styled.div.withConfig({
displayName: "ButtonGroup__StyledButtonGroup",
componentId: "sc-82hrp5-0"
})(["display:flex;& ", ",& ", "{border-radius:", ";margin:", ";&:first-child{border-radius:", ";}&:last-child{border-radius:", ";margin:0;}}"], StyledButtonLink, StyledButton, ({
connected
}) => connected && "0", ({
theme,
connected
}) => rtlSpacing(connected ? theme.orbit.marginButtonGroupConnected : theme.orbit.marginButtonGroup), ({
connected,
theme
}) => connected && borderRadius(`${theme.orbit.borderRadiusNormal} 0 0 ${theme.orbit.borderRadiusNormal}`), ({
connected,
theme
}) => connected && borderRadius(`0 ${theme.orbit.borderRadiusNormal} ${theme.orbit.borderRadiusNormal} 0`));
StyledButtonGroup.defaultProps = {
theme: defaultTheme
};
const ButtonGroup = ({
children,
connected,
dataTest
}) => {
warning(!connected, "Warning: connected property of ButtonGroup component is deprecated. In the next major release, the connected variant will be the default. For unconnected variant, please use Stack component. Check https://orbit.kiwi/roadmap/road-to-1-0-0/#planned-breaking-changes for more information");
return React.createElement(StyledButtonGroup, {
connected: connected,
"data-test": dataTest
}, children);
};
export default ButtonGroup;