import cx from "classnames"; import React from "react"; import { genResponsiveClasses } from "../../utils"; export type GridVAlign = "stretch" | "start" | "end" | "center"; export type GridHAlign = "end" | "center" | "space-around" | "space-between"; export type GridRowGapSize = | "none" | "xsmall" | "small" | "medium" | "large" | "xlarge" | Record; export type GridColumnGapSize = | "none" | "small" | "default" | "large" | "xlarge" | Record; export interface GridProps extends React.HTMLAttributes { vAlign?: GridVAlign; hAlign?: GridHAlign; tag?: React.ElementType; justifyHeight?: boolean; rowGapSize?: GridRowGapSize; columnGapSize?: GridColumnGapSize; } const CLASS_ROOT = "grid"; export const Grid = React.forwardRef( ( { className, hAlign, vAlign, tag = "div", justifyHeight, rowGapSize, columnGapSize, ...other }, ref, ) => { const classes = cx( CLASS_ROOT, { [`align-items-${vAlign}`]: vAlign, [`justify-content-${hAlign}`]: hAlign, [`${CLASS_ROOT}--justify-height`]: justifyHeight, }, ...genResponsiveClasses(`${CLASS_ROOT}-column-gap`, columnGapSize), ...genResponsiveClasses(`${CLASS_ROOT}-row-gap`, rowGapSize), className, ); const TagName = tag; return ; }, ); Grid.displayName = "Grid";