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.

42 lines (36 loc) 1.46 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import * as React from "react"; import styled, { css } from "styled-components"; import defaultTheme from "../defaultTheme"; import Grid from "../utils/Grid"; import { LAYOUT_SETTINGS } from "./consts"; import mq from "../utils/mediaQuery"; const getChildrenProps = (type, key) => { if (LAYOUT_SETTINGS[type].layoutColumns && LAYOUT_SETTINGS[type].layoutColumns[key]) { return LAYOUT_SETTINGS[type].layoutColumns[key]; } return null; }; const StyledLayout = styled(Grid).withConfig({ displayName: "Layout__StyledLayout", componentId: "sc-2e7ifp-0" })(["box-sizing:border-box;margin:0 auto;width:100%;padding:0 ", ";", ";"], ({ theme }) => theme.orbit.spaceMedium, mq.desktop(css(["padding:", ";"], ({ theme }) => theme.orbit.spaceLarge))); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledLayout.defaultProps = { theme: defaultTheme }; const Layout = ({ children, type, dataTest }) => /*#__PURE__*/React.createElement(StyledLayout, _extends({}, LAYOUT_SETTINGS[type], { dataTest: dataTest }), React.Children.map(children, (item, key) => { return /*#__PURE__*/React.cloneElement(item, _objectSpread(_objectSpread({}, getChildrenProps(type, key)), item.props)); })); export default Layout; export { default as LayoutColumn } from "./LayoutColumn";