@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
69 lines (65 loc) • 2 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React__default from 'react';
import { usePrefix } from '../../internal/usePrefix.js';
import { GridSettings } from './GridContext.js';
function FlexGrid(_ref) {
let {
as: BaseComponent = 'div',
condensed = false,
narrow = false,
fullWidth = false,
className: containerClassName,
children,
...rest
} = _ref;
const prefix = usePrefix();
const className = cx(containerClassName, {
[`${prefix}--grid`]: true,
[`${prefix}--grid--condensed`]: condensed,
[`${prefix}--grid--narrow`]: narrow,
[`${prefix}--grid--full-width`]: fullWidth
});
// cast as any to let TypeScript allow passing in attributes to base component
const BaseComponentAsAny = BaseComponent;
return /*#__PURE__*/React__default.createElement(GridSettings, {
mode: "flexbox",
subgrid: false
}, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({
className: className
}, rest), children));
}
FlexGrid.propTypes = {
/**
* Provide a custom element to render instead of the default <div>
*/
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
/**
* Pass in content that will be rendered within the `FlexGrid`
*/
children: PropTypes.node,
/**
* Specify a custom className to be applied to the `FlexGrid`
*/
className: PropTypes.string,
/**
* Collapse the gutter to 1px. Useful for fluid layouts.
* Rows have 1px of margin between them to match gutter.
*/
condensed: PropTypes.bool,
/**
* Remove the default max width that the grid has set
*/
fullWidth: PropTypes.bool,
/**
* Container hangs 16px into the gutter. Useful for
* typographic alignment with and without containers.
*/
narrow: PropTypes.bool
};
const FlexGridComponent = FlexGrid;
export { FlexGridComponent as FlexGrid };