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.

72 lines (69 loc) 2.44 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import * as React from "react"; import styled, { css } from "styled-components"; import defaultTheme from "../../defaultTheme"; import mediaQueries from "../mediaQuery"; import { DEVICES } from "../mediaQuery/consts"; import getViewportGridStyles from "./helpers/getViewportGridStyles"; import isDefined from "../../Stack/helpers/isDefined"; var StyledGrid = styled(function (_ref) { var className = _ref.className, children = _ref.children, dataTest = _ref.dataTest; return /*#__PURE__*/React.createElement("div", { className: className, "data-test": dataTest }, children); }).withConfig({ displayName: "Grid__StyledGrid", componentId: "cj22hw-0" })(["", ";& > *{display:block;}"], function (props) { return DEVICES.map(function (viewport, index, devices) { return viewport in mediaQueries ? mediaQueries[viewport](css(["", ";"], isDefined(props[viewport]) && getViewportGridStyles({ viewport: viewport, index: index, devices: devices }))) : viewport === "smallMobile" && css(["", ";"], getViewportGridStyles({ viewport: viewport, index: index, devices: devices })); }); }); StyledGrid.defaultProps = { theme: defaultTheme }; var Grid = function Grid(_ref2) { var inline = _ref2.inline, _ref2$rows = _ref2.rows, rows = _ref2$rows === void 0 ? "1fr" : _ref2$rows, _ref2$columns = _ref2.columns, columns = _ref2$columns === void 0 ? "1fr" : _ref2$columns, gap = _ref2.gap, rowGap = _ref2.rowGap, columnGap = _ref2.columnGap, maxWidth = _ref2.maxWidth, width = _ref2.width, children = _ref2.children, dataTest = _ref2.dataTest, _ref2$as = _ref2.as, as = _ref2$as === void 0 ? "div" : _ref2$as, props = _objectWithoutProperties(_ref2, ["inline", "rows", "columns", "gap", "rowGap", "columnGap", "maxWidth", "width", "children", "dataTest", "as"]); var smallMobile = { inline: inline, rows: rows, columns: columns, gap: gap, rowGap: rowGap, columnGap: columnGap, maxWidth: maxWidth, width: width }; return /*#__PURE__*/React.createElement(StyledGrid, _extends({}, props, { smallMobile: smallMobile, "data-test": dataTest, as: as }), children); }; export default Grid;