UNPKG

@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.

73 lines (70 loc) 1.94 kB
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; const _excluded = ["as", "id", "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, id, ref }) => /*#__PURE__*/React.createElement(Element, { className: className, "data-test": dataTest, id: id, ref: ref }, 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 = /*#__PURE__*/React.forwardRef((_ref, ref) => { let { as = "div", id, 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, { ref: ref, asComponent: as, id: id, dataTest: dataTest, className: className, viewports: viewports }, children); }); export default Box;