@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.
68 lines (63 loc) • 1.82 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["as", "mediumMobile", "largeMobile", "tablet", "desktop", "largeDesktop", "children", "dataTest", "className"];
import * as React from "react";
import styled, { css } from "styled-components";
import defaultTheme from "../defaultTheme";
import media from "../utils/mediaQuery";
import { DEVICES as DEVICES_CONSTS } from "../utils/mediaQuery/consts";
import normalize from "./normalize";
const StyledBox = styled(({
className,
asComponent: Element,
children,
dataTest
}) => /*#__PURE__*/React.createElement(Element, {
className: className,
"data-test": dataTest
}, children)).withConfig({
displayName: "Box__StyledBox",
componentId: "sc-19rtrat-0"
})(["font-family:", ";box-sizing:border-box;", ""], ({
theme
}) => theme.orbit.fontFamily, ({
viewports
}) => {
return Object.entries(viewports).map(([query, value]) => {
if (query !== DEVICES_CONSTS[0] && typeof value !== "undefined") {
return media[query](css(["", ""], normalize(value)));
}
return normalize(value);
});
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledBox.defaultProps = {
theme: defaultTheme
};
const Box = _ref => {
let {
as = "div",
mediumMobile,
largeMobile,
tablet,
desktop,
largeDesktop,
children,
dataTest,
className
} = _ref,
smallMobile = _objectWithoutProperties(_ref, _excluded);
const viewports = {
smallMobile,
mediumMobile,
largeMobile,
tablet,
desktop,
largeDesktop
};
return /*#__PURE__*/React.createElement(StyledBox, {
asComponent: as,
dataTest: dataTest,
className: className,
viewports: viewports
}, children);
};
export default Box;