UNPKG

design-system-simplefi

Version:

Design System for SimpleFi Applications

57 lines 2.77 kB
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import styled from 'styled-components'; import PropTypes from 'prop-types'; import { getSpace } from '../../../utils'; import { SpaceSizes } from '../../../theme/space/space.enums'; import { AlignItemsPropType } from '../../../types/flex.types'; var GridWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n"], ["\n overflow: hidden;\n"]))); var GridParent = styled.div(function (_a) { var $cols = _a.$cols, $gap = _a.$gap, $align = _a.$align, theme = _a.theme; var gapSize = getSpace($gap, { theme: theme }); return "\n display: flex;\n flex-wrap: wrap;\n align-items: " + $align + ";\n margin: calc(" + gapSize + " / -2);\n\n & > * {\n width: calc(" + 100 / $cols + "% - " + gapSize + ");\n margin: calc(" + gapSize + " / 2);\n }\n "; }); var Grid = function (_a) { var children = _a.children, gap = _a.gap, align = _a.align, cols = _a.cols, parentEl = _a.parentEl, wrapperEl = _a.wrapperEl, props = __rest(_a, ["children", "gap", "align", "cols", "parentEl", "wrapperEl"]); return (React.createElement(GridWrapper, { as: wrapperEl }, React.createElement(GridParent, __assign({ "$align": align, "$cols": cols, "$gap": gap, as: parentEl }, props), children))); }; Grid.propTypes = { gap: PropTypes.oneOf(Object.values(SpaceSizes)), cols: PropTypes.number, align: AlignItemsPropType, wrapperEl: PropTypes.elementType, parentEl: PropTypes.elementType, }; Grid.defaultProps = { gap: SpaceSizes.none, cols: 6, }; export default Grid; var templateObject_1; //# sourceMappingURL=Grid.js.map