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.

57 lines (52 loc) 1.71 kB
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; const _excluded = ["as", "mediumMobile", "largeMobile", "className", "tablet", "desktop", "largeDesktop", "children", "dataTest"]; import * as React from "react"; import styled, { css } from "styled-components"; import defaultTheme from "../defaultTheme"; import { DEVICES as DEVICES_CONSTS } from "../utils/mediaQuery/consts"; import media from "../utils/mediaQuery"; import { normalize } from "./helpers"; const StyledInlineInner = styled.div.withConfig({ displayName: "Inline__StyledInlineInner", componentId: "sc-1ct8nhm-0" })(["display:flex;flex-direction:row;flex-wrap:wrap;", ""], ({ viewportSizes }) => { return Object.entries(viewportSizes).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 StyledInlineInner.defaultProps = { theme: defaultTheme }; const Inline = (_ref) => { let { as: Component = "div", mediumMobile, largeMobile, className, tablet, desktop, largeDesktop, children, dataTest } = _ref, smallMobile = _objectWithoutProperties(_ref, _excluded); const viewportSizes = { smallMobile, mediumMobile, largeMobile, tablet, desktop }; return /*#__PURE__*/React.createElement(Component, { className: className, "data-test": dataTest }, /*#__PURE__*/React.createElement(StyledInlineInner, { viewportSizes: viewportSizes }, children)); }; export default Inline;