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

Commit 6fe05d0

Browse files
authored
Merge pull request #41 from WebDevStudios/feature/block-handling
Feature/block handling
2 parents 8848900 + b2468ac commit 6fe05d0

File tree

29 files changed

+597
-0
lines changed

29 files changed

+597
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import PropTypes from 'prop-types'
2+
3+
/**
4+
* Accordion Block
5+
*
6+
* A custom ACF Block for displaying accordions.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
*/
11+
export default function BlockAccordions({props}) {
12+
const {
13+
id,
14+
anchor,
15+
className,
16+
data: {accordions, button_label, button_url, title}
17+
} = props
18+
19+
return (
20+
<pre>
21+
{JSON.stringify(
22+
{
23+
id,
24+
anchor,
25+
className,
26+
data: {accordions, button_label, button_url, title}
27+
},
28+
null,
29+
2
30+
)}
31+
</pre>
32+
)
33+
}
34+
35+
BlockAccordions.propTypes = {
36+
anchor: PropTypes.string,
37+
className: PropTypes.string,
38+
data: PropTypes.shape({
39+
accordions: PropTypes.object,
40+
button_label: PropTypes.string,
41+
button_url: PropTypes.string,
42+
description: PropTypes.string,
43+
title: PropTypes.string
44+
}),
45+
id: PropTypes.string,
46+
props: PropTypes.object.isRequired
47+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockAccordions'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import PropTypes from 'prop-types'
2+
3+
/**
4+
* Algolia Block
5+
*
6+
* A custom ACF Block for displaying Algolia results.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
*/
11+
export default function BlockAlgolia({props, indexName}) {
12+
const {
13+
data: {title, post_type, show_filters, sort_order}
14+
} = props
15+
16+
return (
17+
<pre>
18+
{JSON.stringify(
19+
indexName,
20+
{title, post_type, show_filters, sort_order},
21+
null,
22+
2
23+
)}
24+
</pre>
25+
)
26+
}
27+
28+
BlockAlgolia.propTypes = {
29+
indexName: PropTypes.string.isRequired,
30+
props: PropTypes.object.isRequired,
31+
id: PropTypes.string,
32+
anchor: PropTypes.string,
33+
align: PropTypes.string,
34+
className: PropTypes.string,
35+
data: PropTypes.shape({
36+
title: PropTypes.string,
37+
post_type: PropTypes.string,
38+
show_filters: PropTypes.string,
39+
sort_order: PropTypes.string
40+
})
41+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockAlgolia'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import PropTypes from 'prop-types'
2+
3+
/**
4+
* Block Quote Block
5+
*
6+
* The core Block Quote block from Gutenberg.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
*/
11+
export default function BlockBlockquote({props}) {
12+
const {
13+
id,
14+
anchor,
15+
className,
16+
data: {quote, style}
17+
} = props
18+
19+
const type = style === 'misc-white' ? 'a' : 'b'
20+
return (
21+
<pre>
22+
{JSON.stringify(
23+
type,
24+
{
25+
id,
26+
anchor,
27+
className,
28+
data: {quote, style}
29+
},
30+
null,
31+
2
32+
)}
33+
</pre>
34+
)
35+
}
36+
37+
BlockBlockquote.propTypes = {
38+
props: PropTypes.object.isRequired,
39+
id: PropTypes.string,
40+
anchor: PropTypes.string,
41+
className: PropTypes.string,
42+
data: PropTypes.shape({
43+
quote: PropTypes.string,
44+
style: PropTypes.string
45+
})
46+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockBlockquote'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import cn from 'classnames'
2+
import PropTypes from 'prop-types'
3+
4+
/**
5+
* Headings Block
6+
*
7+
* The core Headings block from Gutenberg.
8+
*
9+
* @author WebDevStudios
10+
* @param {object} props The component attributes as props.
11+
*/
12+
export default function BlockHeadings({props}) {
13+
const {anchor, align, className, content, level} = props
14+
const alignment = !align ? 'left' : align
15+
16+
return (
17+
<h1
18+
tag={'h' + level}
19+
className={cn('container container--sm', `text-${alignment}`, className)}
20+
id={anchor}
21+
>
22+
{content}
23+
</h1>
24+
)
25+
}
26+
27+
BlockHeadings.propTypes = {
28+
props: PropTypes.object.isRequired,
29+
anchor: PropTypes.string,
30+
align: PropTypes.string,
31+
backgroundColor: PropTypes.string,
32+
className: PropTypes.string,
33+
content: PropTypes.string,
34+
fontSize: PropTypes.string,
35+
level: PropTypes.string,
36+
textColor: PropTypes.string
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './BlockHeadings'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import PropTypes from 'prop-types'
2+
3+
/**
4+
* Image Block
5+
*
6+
* The core Image block from Gutenberg.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
*/
11+
export default function BlockImage({props: {alt, anchor, caption, image}}) {
12+
return <pre>{JSON.stringify({alt, anchor, caption, image}, null, 2)}</pre>
13+
}
14+
15+
BlockImage.propTypes = {
16+
props: PropTypes.shape({
17+
alt: PropTypes.string,
18+
anchor: PropTypes.string,
19+
caption: PropTypes.string,
20+
className: PropTypes.string,
21+
id: PropTypes.number,
22+
image: PropTypes.object,
23+
linkClass: PropTypes.string,
24+
title: PropTypes.string,
25+
url: PropTypes.string
26+
})
27+
}

components/blocks/BlockImage/index.js

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

0 commit comments

Comments
 (0)