@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.
46 lines (40 loc) • 1.64 kB
JavaScript
import * as React from "react";
import styled, { css } from "styled-components";
import defaultTheme from "../defaultTheme";
import getSpacingToken from "../common/getSpacingToken";
import { left, right } from "../utils/rtl";
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getIndentAmount({
theme,
indent
}) {
return indent === "none" ? 0 : theme.orbit[`space${capitalize(indent)}`];
}
const StyledContainer = styled.div.withConfig({
displayName: "Separator__StyledContainer",
componentId: "sc-196v0by-0"
})(["", ";"], ({
align
}) => css(["box-sizing:border-box;width:100%;", ";", ";", ";"], align === "left" && css(["padding-", ":", ";"], right, getIndentAmount), align === "right" && css(["padding-", ":", ";"], left, getIndentAmount), align === "center" && css(["padding:0 ", ";"], getIndentAmount)));
const StyledSeparator = styled.hr.withConfig({
displayName: "Separator__StyledSeparator",
componentId: "sc-196v0by-1"
})(["", ";"], ({
theme
}) => css(["height:", ";background:", ";box-sizing:border-box;border-style:none;margin-top:0;margin-bottom:", ";"], theme.orbit.heightSeparator, theme.orbit.backgroundSeparator, getSpacingToken)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledSeparator.defaultProps = {
theme: defaultTheme
};
const Separator = ({
align = "left",
indent = "none",
spaceAfter
}) => /*#__PURE__*/React.createElement(StyledContainer, {
align: align,
indent: indent
}, /*#__PURE__*/React.createElement(StyledSeparator, {
spaceAfter: spaceAfter
}));
export default Separator;