@vectara/vectara-ui
Version:
Vectara's design system, codified as a React and Sass component library
34 lines (33 loc) • 1.64 kB
JavaScript
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 { jsx as _jsx } from "react/jsx-runtime";
import classNames from "classnames";
import { VuiGrid } from "./Grid";
export const VuiSimpleGrid = (_a) => {
var { children, columns, minChildWidth, spacing = "m", className } = _a, rest = __rest(_a, ["children", "columns", "minChildWidth", "spacing", "className"]);
let templateColumns;
if (minChildWidth) {
// Use auto-fit with minmax for responsive behavior
templateColumns = `repeat(auto-fit, minmax(${minChildWidth}, 1fr))`;
}
else if (typeof columns === "number") {
templateColumns = `repeat(${columns}, 1fr)`;
}
else if (columns && typeof columns === "object") {
// TODO: Responsive columns object - would need media queries or container queries
// For now, just use the first value as a fallback
const firstValue = Object.values(columns)[0];
templateColumns = `repeat(${firstValue}, 1fr)`;
}
const classes = classNames("vuiSimpleGrid", className);
return (_jsx(VuiGrid, Object.assign({ templateColumns: templateColumns, spacing: spacing, className: classes }, rest, { children: children })));
};