@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.
75 lines (70 loc) • 2.04 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["theme", "spaceAfter"],
_excluded2 = ["inline", "rows", "columns", "gap", "rowGap", "columnGap", "maxWidth", "width", "children", "dataTest", "as"];
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";
const StyledGrid = styled(({
className,
children,
dataTest
}) => /*#__PURE__*/React.createElement("div", {
className: className,
"data-test": dataTest
}, children)).withConfig({
displayName: "Grid__StyledGrid",
componentId: "sc-9eqnnl-0"
})(["", ";"], (_ref) => {
let {
theme,
spaceAfter
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
return DEVICES.map(viewport => viewport in mediaQueries ? mediaQueries[viewport](css(["", ";"], isDefined(props[viewport]) && getViewportGridStyles({
viewport,
theme
}))) : viewport === "smallMobile" && css(["", ";"], getViewportGridStyles({
viewport,
theme
})));
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledGrid.defaultProps = {
theme: defaultTheme
};
const Grid = (_ref2) => {
let {
inline,
rows = "1fr",
columns = "1fr",
gap,
rowGap,
columnGap,
maxWidth,
width,
children,
dataTest,
as = "div"
} = _ref2,
props = _objectWithoutProperties(_ref2, _excluded2);
const smallMobile = {
inline,
rows,
columns,
gap,
rowGap,
columnGap,
maxWidth,
width
};
return /*#__PURE__*/React.createElement(StyledGrid, _extends({}, props, {
smallMobile: smallMobile,
"data-test": dataTest,
as: as
}), children);
};
export default Grid;