pouncejs
Version:
A collection of UI components from Panther labs
39 lines (35 loc) • 1.32 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import React from 'react';
import Grid from '../Grid';
import { countToColumns, widthToColumns } from './utils';
/**
* Extends <a href="/#/Grid">Grid</a>
*
* An alternative to the simple Grid component that aims to conventiently help with the average
* use cases of a grid.
*
* Inspired from <a href="https://chakra-ui.com/" target="_blank">Chakra UI</a>
*/
export var SimpleGrid = /*#__PURE__*/React.forwardRef(function SimpleGrid(props, ref) {
var columns = props.columns,
spacingX = props.spacingX,
spacingY = props.spacingY,
spacing = props.spacing,
minChildWidth = props.minChildWidth,
rest = _objectWithoutPropertiesLoose(props, ["columns", "spacingX", "spacingY", "spacing", "minChildWidth"]);
var templateColumns;
if (minChildWidth && minChildWidth > 0) {
templateColumns = widthToColumns(minChildWidth);
} else if (columns && columns > 0) {
templateColumns = countToColumns(columns);
}
return /*#__PURE__*/React.createElement(Grid, _extends({
ref: ref,
gap: spacing,
columnGap: spacingX,
rowGap: spacingY,
templateColumns: templateColumns
}, rest));
});
export default SimpleGrid;