@wordpress/components
Version:
UI components for WordPress.
61 lines (54 loc) • 1.54 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { cx as _cx } from "emotion";
import { createElement } from "@wordpress/element";
/**
* WordPress dependencies
*/
import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { contextConnect, useContextSystem } from '../context';
import { Scrollable } from '../scrollable';
import { View } from '../view';
import * as styles from './styles';
/**
* @param {import('../context').ViewOwnProps<import('./types').CardBodyProps, 'div'>} props
* @param {import('react').Ref<any>} forwardedRef
*/
function CardBody(props, forwardedRef) {
const {
className,
scrollable = true,
...otherProps
} = useContextSystem(props, 'CardBody');
const classes = useMemo(() => _cx(styles.Body, styles.borderRadius, className), [className]);
if (scrollable) {
return createElement(Scrollable, _extends({}, otherProps, {
className: classes,
ref: forwardedRef
}));
}
return createElement(View, _extends({}, otherProps, {
className: classes,
ref: forwardedRef
}));
}
/**
* `CardBody` is a layout component, rendering the contents of a `Card`.
* Multiple `CardBody` components can be used within `Card` if needed.
*
* @example
* ```jsx
* import { Card, CardBody } from `@wordpress/components/ui`;
*
* <Card>
* <CardBody>
* ...
* </CardBody>
* </Card>
* ```
*/
const ConnectedCardBody = contextConnect(CardBody, 'CardBody');
export default ConnectedCardBody;
//# sourceMappingURL=body.js.map