|
1 | 1 | import Image from '@/components/atoms/Image'
|
2 | 2 | import Blocks from '@/components/molecules/Blocks'
|
| 3 | +import MediaText from '@/components/organisms/MediaText' |
3 | 4 | import PropTypes from 'prop-types'
|
4 | 5 |
|
| 6 | +// TODO: Swap `img` in `MediaText` component with `Image` atom component. |
| 7 | + |
5 | 8 | /**
|
6 | 9 | * Code Block
|
7 | 10 | *
|
8 | 11 | * The core Code block from Gutenberg.
|
9 | 12 | *
|
10 | 13 | * @author WebDevStudios
|
11 |
| - * @param media.media |
12 |
| - * @param {object} media media props. |
13 |
| - * @param {string} media.anchor The anchor/id of the block. |
14 |
| - * @param {string} media.mediaAlt The image alt text. |
15 |
| - * @param {string} media.caption The image caption. |
16 |
| - * @param {string} media.className The image class. |
17 |
| - * @param {string} media.mediaId The image ID. |
18 |
| - * @param {string} media.href The URL of the link. |
19 |
| - * @param {string} media.linkTarget Target for the link. |
20 |
| - * @param {string} media.linkClass Class for the link. |
21 |
| - * @param {string} media.rel The rel attribute for the link. |
22 |
| - * @param {string} media.sizeSlug The WP image size. |
23 |
| - * @param {string} media.mediaUrl The full URL path of the image. |
24 |
| - * @param {string} media.mediaPosition The position of the image, left or right. |
25 |
| - * @param media.innerBlocks |
26 |
| - * @param {Array} innerBlocks The array of inner blocks to display. |
27 |
| - * @return {Element} The Code component. |
| 14 | + * @param {object} media media props. |
| 15 | + * @param {string} media.anchor The anchor/id of the block. |
| 16 | + * @param {string} media.mediaAlt The image alt text. |
| 17 | + * @param {string} media.caption The image caption. |
| 18 | + * @param {string} media.className The image class. |
| 19 | + * @param {string} media.mediaId The image ID. |
| 20 | + * @param {string} media.href The URL of the link. |
| 21 | + * @param {string} media.linkTarget Target for the link. |
| 22 | + * @param {string} media.linkClass Class for the link. |
| 23 | + * @param {string} media.rel The rel attribute for the link. |
| 24 | + * @param {string} media.sizeSlug The WP image size. |
| 25 | + * @param {string} media.mediaUrl The full URL path of the image. |
| 26 | + * @param {string} media.mediaPosition The position of the image, left or right. |
| 27 | + * @param {Array} innerBlocks The array of inner blocks to display. |
| 28 | + * @return {Element} The Code component. |
28 | 29 | */
|
29 | 30 | export default function BlockMediaText({media, innerBlocks}) {
|
30 | 31 | return (
|
31 |
| - <div> |
32 |
| - {!!media && ( |
33 |
| - <Image |
34 |
| - alt={media?.mediaAlt} |
35 |
| - anchor={media?.anchor} |
36 |
| - caption={media?.caption} |
37 |
| - className={media?.className} |
38 |
| - id={media?.mediaId} |
39 |
| - href={media?.href} |
40 |
| - linkTarget={media?.linkTarget} |
41 |
| - linkClass={media?.linkClass} |
42 |
| - rel={media?.rel} |
43 |
| - sizeSlug={media?.sizeSlug} |
44 |
| - url={media?.mediaUrl} |
45 |
| - /> |
| 32 | + <> |
| 33 | + {!!media && innerBlocks?.length && ( |
| 34 | + <MediaText |
| 35 | + mediaLeft={media?.mediaPosition === 'left' ? true : false} |
| 36 | + image={{url: media?.mediaUrl, alt: media?.mediaAlt}} |
| 37 | + > |
| 38 | + <Blocks blocks={innerBlocks} /> |
| 39 | + </MediaText> |
46 | 40 | )}
|
47 |
| - {!!innerBlocks?.length && <Blocks blocks={innerBlocks} />} |
48 |
| - </div> |
| 41 | + </> |
49 | 42 | )
|
50 | 43 | }
|
51 | 44 |
|
|
0 commit comments