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

Commit fb4b113

Browse files
committed
Merge branch 'staging' into feature/lazy-blocks
2 parents 2bb61ab + cb39881 commit fb4b113

File tree

15 files changed

+309
-298
lines changed

15 files changed

+309
-298
lines changed

components/atoms/Columns/Columns.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import cn from 'classnames'
2+
import PropTypes from 'prop-types'
3+
import React from 'react'
4+
import styles from './Columns.module.css'
5+
6+
/**
7+
* Render the Columns component.
8+
*
9+
* @param {object} props Container component props.
10+
* @param {string} props.id Optional ID/Anchor.
11+
* @param {string} props.className Optional className.
12+
* @param {string} props.columnCount Total number of columns.
13+
* @param {object} props.children React children.
14+
* @return {Element} The Columns component.
15+
*/
16+
export default function Columns({id, className, columnCount, children}) {
17+
return (
18+
<div
19+
id={id || null}
20+
className={cn(
21+
styles.columns,
22+
columnCount && styles[`columns-${columnCount}`],
23+
className
24+
)}
25+
>
26+
{children && children}
27+
</div>
28+
)
29+
}
30+
31+
Columns.propTypes = {
32+
id: PropTypes.string,
33+
className: PropTypes.string,
34+
columnCount: PropTypes.number,
35+
children: PropTypes.node
36+
}
37+
Columns.defaultProps = {
38+
columnCount: 3
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.columns {
2+
@apply grid gap-16 grid-cols-3;
3+
4+
&.columns-1 {
5+
@apply grid-cols-1;
6+
}
7+
8+
&.columns-2 {
9+
@apply grid-cols-2;
10+
}
11+
12+
&.columns-3 {
13+
@apply grid-cols-3;
14+
}
15+
16+
&.columns-4 {
17+
@apply grid-cols-4;
18+
}
19+
20+
&.columns-5 {
21+
@apply grid-cols-5;
22+
}
23+
24+
&.columns-6 {
25+
@apply grid-cols-6;
26+
}
27+
}

components/atoms/Columns/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './Columns'

components/blocks/BlockButtons/BlockButtons.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import PropTypes from 'prop-types'
88
* The core Buttons block from Gutenberg.
99
*
1010
* @author WebDevStudios
11-
* @param {object} props The component prope
12-
* @param {object} props.options Option props object.
13-
* @param {string} props.options.anchor The anchor/id of the block.
14-
* @param {string} props.options.orientation The orientation of buttons.
15-
* @param {string} props.options.contentJustification The justification of the buttons.
16-
* @param {Array} props.innerBlocks The array of inner blocks to display.
17-
* @return {Element} The Buttons component.
11+
* @param {object} props The component properties.
12+
* @param props.options
13+
* @param {object} options Option props object.
14+
* @param {string} options.anchor The anchor/id of the block.
15+
* @param {string} options.orientation The orientation of buttons.
16+
* @param {string} options.contentJustification The justification of the buttons.
17+
* @param props.innerBlocks
18+
* @param {Array} innerBlocks The array of inner blocks to display.
19+
* @return {Element} The Buttons component.
1820
*/
1921
export default function BlockButtons({options, innerBlocks}) {
2022
return (
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import Columns from '@/components/atoms/Columns'
2+
import Blocks from '@/components/molecules/Blocks'
3+
import PropTypes from 'prop-types'
4+
5+
/**
6+
* Columns Block
7+
*
8+
* The core Columns block from Gutenberg.
9+
*
10+
* @author WebDevStudios
11+
* @param {object} props The component properties.
12+
* @param {string} options.anchor The optional anchor/id of the block.
13+
* @param {string} options.className The optional classname.
14+
* @param props.options
15+
* @param props.innerBlocks
16+
* @param {Array} innerBlocks The array of inner blocks to display.
17+
* @return {Element} The Columns component.
18+
*/
19+
export default function BlockColumns({options, innerBlocks}) {
20+
return (
21+
<>
22+
{!!innerBlocks?.length && (
23+
<Columns
24+
id={options?.anchor}
25+
className={options?.className}
26+
columnCount={innerBlocks?.length}
27+
>
28+
{innerBlocks.map((block, index) => {
29+
return (
30+
<div key={`column-${index}`}>
31+
{!!block?.innerBlocks?.length && (
32+
<Blocks blocks={block.innerBlocks} />
33+
)}
34+
</div>
35+
)
36+
})}
37+
</Columns>
38+
)}
39+
</>
40+
)
41+
}
42+
43+
BlockColumns.propTypes = {
44+
options: PropTypes.shape({
45+
anchor: PropTypes.string,
46+
className: PropTypes.string
47+
}),
48+
innerBlocks: PropTypes.arrayOf(
49+
PropTypes.shape({
50+
name: PropTypes.string,
51+
attributes: PropTypes.object
52+
})
53+
)
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockColumns'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Blocks from '@/components/molecules/Blocks'
2+
import Hero from '@/components/organisms/Hero'
3+
import PropTypes from 'prop-types'
4+
5+
/**
6+
* Cover Block
7+
*
8+
* The core Columns block from Gutenberg.
9+
*
10+
* @author WebDevStudios
11+
* @param {object} props The component properties.
12+
* @param {string} media.anchor The optional anchor/id of the block.
13+
* @param {string} media.url The background image URL.
14+
* @param props.media
15+
* @param props.innerBlocks
16+
* @param {Array} innerBlocks The array of inner blocks to display.
17+
* @return {Element} The Cover component.
18+
*/
19+
export default function BlockCover({media, innerBlocks}) {
20+
return (
21+
<>
22+
{!!media?.url && (
23+
<Hero backgroundImage={media.url} id={media?.anchor}>
24+
{!!innerBlocks?.length && <Blocks blocks={innerBlocks} />}
25+
</Hero>
26+
)}
27+
</>
28+
)
29+
}
30+
31+
BlockCover.propTypes = {
32+
media: PropTypes.shape({
33+
anchor: PropTypes.string,
34+
url: PropTypes.string
35+
}),
36+
innerBlocks: PropTypes.arrayOf(
37+
PropTypes.shape({
38+
name: PropTypes.string,
39+
attributes: PropTypes.object
40+
})
41+
)
42+
}

components/blocks/BlockCover/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockCover'

components/blocks/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export {default as BlockAccordions} from './BlockAccordions'
33
export {default as BlockButton} from './BlockButton'
44
export {default as BlockButtons} from './BlockButtons'
55
export {default as BlockCode} from './BlockCode'
6+
export {default as BlockColumns} from './BlockColumns'
7+
export {default as BlockCover} from './BlockCover'
68
export {default as BlockHeadings} from './BlockHeadings'
79
export {default as BlockHero} from './BlockHero'
810
export {default as BlockImage} from './BlockImage'

components/organisms/Hero/Hero.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import styles from './Hero.module.css'
1616
* @param {object} props.ctaUrl The cta url.
1717
* @param {string} props.subtitle Text for the subtitle.
1818
* @param {string} props.title Text for the title.
19+
* @param {object} props.children React children.
1920
* @return {Element} The Hero component.
2021
*/
2122
export default function Hero({
@@ -66,5 +67,6 @@ Hero.propTypes = {
6667
ctaText: PropTypes.string,
6768
ctaUrl: PropTypes.string,
6869
subtitle: PropTypes.string,
69-
title: PropTypes.string.isRequired
70+
children: PropTypes.node,
71+
title: PropTypes.string
7072
}

0 commit comments

Comments
 (0)