@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.
79 lines (74 loc) • 2.69 kB
JavaScript
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 "../layout";
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 (_ref2) {
var theme = _ref2.theme,
spaceAfter = _ref2.spaceAfter,
props = _objectWithoutProperties(_ref2, ["theme", "spaceAfter"]);
return DEVICES.map(function (viewport, index, devices) {
return viewport in mediaQueries ? mediaQueries[viewport](css(["", ";"], isDefined(props[viewport]) && getViewportGridStyles({
viewport: viewport,
index: index,
theme: theme,
devices: devices
}))) : viewport === "smallMobile" && css(["", ";"], getViewportGridStyles({
viewport: viewport,
index: index,
devices: devices,
theme: theme
}));
});
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledGrid.defaultProps = {
theme: defaultTheme
};
var Grid = function Grid(_ref3) {
var inline = _ref3.inline,
_ref3$rows = _ref3.rows,
rows = _ref3$rows === void 0 ? "1fr" : _ref3$rows,
_ref3$columns = _ref3.columns,
columns = _ref3$columns === void 0 ? "1fr" : _ref3$columns,
gap = _ref3.gap,
rowGap = _ref3.rowGap,
columnGap = _ref3.columnGap,
maxWidth = _ref3.maxWidth,
width = _ref3.width,
children = _ref3.children,
dataTest = _ref3.dataTest,
_ref3$as = _ref3.as,
as = _ref3$as === void 0 ? "div" : _ref3$as,
props = _objectWithoutProperties(_ref3, ["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;