Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 88c5c29

Browse files
committed
Updates to MediaBlocks
1 parent ea96bfa commit 88c5c29

File tree

4 files changed

+40
-49
lines changed

4 files changed

+40
-49
lines changed

components/blocks/BlockButtons/BlockButtons.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ import PropTypes from 'prop-types'
88
* The core Buttons block from Gutenberg.
99
*
1010
* @author WebDevStudios
11-
* @param options.options
12-
* @param {object} options Option props.
13-
* @param {string} options.anchor The anchor/id of the block.
14-
* @param {string} options.orientation The orientation of buttons.
15-
* @param {string} options.contentJustification The justification of the buttons.
16-
* @param options.innerBlocks
17-
* @param {Array} innerBlocks The array of inner blocks to display.
18-
* @return {Element} The Buttons component.
11+
* @param {object} options Option props.
12+
* @param {string} options.anchor The anchor/id of the block.
13+
* @param {string} options.orientation The orientation of buttons.
14+
* @param {string} options.contentJustification The justification of the buttons.
15+
* @param {Array} innerBlocks The array of inner blocks to display.
16+
* @return {Element} The Buttons component.
1917
*/
2018
export default function BlockButtons({options, innerBlocks}) {
2119
return (

components/blocks/BlockMediaText/BlockMediaText.js

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
11
import Image from '@/components/atoms/Image'
22
import Blocks from '@/components/molecules/Blocks'
3+
import MediaText from '@/components/organisms/MediaText'
34
import PropTypes from 'prop-types'
45

6+
// TODO: Swap `img` in `MediaText` component with `Image` atom component.
7+
58
/**
69
* Code Block
710
*
811
* The core Code block from Gutenberg.
912
*
1013
* @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.
2829
*/
2930
export default function BlockMediaText({media, innerBlocks}) {
3031
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>
4640
)}
47-
{!!innerBlocks?.length && <Blocks blocks={innerBlocks} />}
48-
</div>
41+
</>
4942
)
5043
}
5144

components/molecules/ButtonGroup/ButtonGroup.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import styles from './ButtonGroup.module.css'
99
* Render the ButtonGroup component.
1010
*
1111
* @author WebDevStudios
12-
* @param {string} id The id of the block.
13-
* @param {string} orientation The orientation of buttons.
14-
* @param {string} contentJustification The justification of the buttons.
15-
* @param {children} children The children props to render.
16-
* @return {Element} The ButtonGroup component.
12+
* @param {string} id The id of the block.
13+
* @param {string} orientation The orientation of buttons.
14+
* @param {string} contentJustification The justification of the buttons.
15+
* @param {element} children The children props to render.
16+
* @return {Element} The ButtonGroup component.
1717
*/
1818
export default function ButtonGroup({
1919
id,
@@ -41,5 +41,5 @@ ButtonGroup.propTypes = {
4141
id: PropTypes.string,
4242
orientation: PropTypes.string,
4343
contentJustification: PropTypes.string,
44-
children: PropTypes.children
44+
children: PropTypes.element
4545
}

functions/displayBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
77
* @author WebDevStudios
88
* @param {object} block The block data.
99
* @param {number} index A unique key required by React.
10-
* @return {Element} A block-based component.
10+
* @return {Element} A block-based component.
1111
*/
1212
export default function displayBlock(block, index) {
1313
const {attributes, name, innerBlocks} = block

0 commit comments

Comments
 (0)