-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathcomponent.tsx
45 lines (40 loc) · 994 Bytes
/
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 { View } from '../../view';
import { useCardMedia } from './hook';
import type { MediaProps } from '../types';
function CardMedia(
props: WordPressComponentProps< MediaProps, 'div' >,
forwardedRef: ForwardedRef< HTMLDivElement >
) {
const cardMediaProps = useCardMedia( props );
return <View { ...cardMediaProps } ref={ forwardedRef } />;
}
/**
* `CardMedia` provides a container for media elements within a `Card`.
*
* @example
* ```jsx
* import { Card, CardBody, CardMedia } from '@wordpress/components';
*
* const Example = () => (
* <Card>
* <CardMedia>
* <img src="..." />
* </CardMedia>
* <CardBody>...</CardBody>
* </Card>
* );
* ```
*/
const ConnectedCardMedia = contextConnect< MediaProps >(
CardMedia,
'CardMedia'
);
export default ConnectedCardMedia;