-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathcomponent.tsx
45 lines (39 loc) · 1.07 KB
/
component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* External dependencies
*/
import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import { Scrollable } from '../../scrollable';
import { View } from '../../view';
import { useCardBody } from './hook';
import type { BodyProps } from '../types';
function CardBody(
props: WordPressComponentProps< BodyProps, 'div' >,
forwardedRef: ForwardedRef< HTMLDivElement >
) {
const { isScrollable, ...otherProps } = useCardBody( props );
if ( isScrollable ) {
return <Scrollable { ...otherProps } ref={ forwardedRef } />;
}
return <View { ...otherProps } ref={ forwardedRef } />;
}
/**
* `CardBody` renders an optional content area for a `Card`.
* Multiple `CardBody` components can be used within `Card` if needed.
*
* @example
* ```jsx
* import { Card, CardBody } from `@wordpress/components`;
*
* <Card>
* <CardBody>
* ...
* </CardBody>
* </Card>
* ```
*/
const ConnectedCardBody = contextConnect< BodyProps >( CardBody, 'CardBody' );
export default ConnectedCardBody;