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

Commit f2c9d73

Browse files
committed
Merge branch 'staging' into feature/33-breadcrumbs
2 parents 972e9e0 + d5fa0e5 commit f2c9d73

File tree

7 files changed

+72
-26
lines changed

7 files changed

+72
-26
lines changed

.eslintrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ module.exports = {
3333
rules: {
3434
'func-style': ['error', 'declaration'],
3535
'jsdoc/check-indentation': 'warn',
36-
'jsdoc/check-line-alignment': ['warn', 'always'],
36+
'jsdoc/check-line-alignment': [
37+
'warn',
38+
'always',
39+
{
40+
tags: ['author', 'param', 'see']
41+
}
42+
],
3743
'jsdoc/require-param': [
3844
'warn',
3945
{

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ yarn-error.log*
3030
.env.development.local
3131
.env.test.local
3232
.env.production.local
33+
wpe.json
3334

3435
# storybook
3536
build-storybook.log

api/wordpress/_global/getPostTypeArchive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const archiveQuerySeo = {
2929
* @param {string} cursor Start/end cursor for pagination.
3030
* @param {boolean} getNext Whether to retrieve next set of posts (true) or previous set (false).
3131
* @param {number} perPage Number of posts per page.
32-
* @return {object} Object containing Apollo client instance and post archive data or error object.
32+
* @return {object} Object containing Apollo client instance and post archive data or error object.
3333
*/
3434
export default async function getPostTypeArchive(
3535
postType,
@@ -40,7 +40,7 @@ export default async function getPostTypeArchive(
4040
perPage = 10
4141
) {
4242
// Retrieve post type query.
43-
const query = archiveQuerySeo?.[postType] ?? null
43+
const query = archiveQuerySeo?.[postType]?.query ?? null
4444

4545
// Get/create Apollo instance.
4646
const apolloClient = initializeWpApollo()

components/organisms/MediaText/MediaText.js

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,39 @@ import Button from '@/components/atoms/Button'
22
import Container from '@/components/atoms/Container'
33
import cn from 'classnames'
44
import PropTypes from 'prop-types'
5-
import React from 'react'
5+
import React, {useEffect} from 'react'
66
import styles from './MediaText.module.css'
77

88
/**
99
* Render the MediaText component.
1010
*
1111
* @param {object} props MediaText component props.
1212
* @param {string} props.body The body text.
13+
* @param {element} props.children The child elements.
1314
* @param {string} props.className The className.
1415
* @param {object} props.cta The cta object with text and url strings.
1516
* @param {object} props.image The image object with url and alt text.
1617
* @param {boolean} props.mediaLeft Whether to show media on the left of the text.
1718
* @param {string} props.title The title.
18-
* @return {Element} The MediaText component.
19+
* @return {Element} The MediaText component.
1920
*/
2021
export default function MediaText({
2122
body,
23+
children,
2224
className,
2325
cta,
2426
image,
2527
mediaLeft,
2628
title
2729
}) {
30+
useEffect(() => {
31+
if ((children && title) || (children && body) || (children && cta)) {
32+
console.warn(
33+
'The title, body and cta props are ignored when using children.'
34+
)
35+
}
36+
})
37+
2838
return (
2939
<Container>
3040
<section
@@ -35,17 +45,23 @@ export default function MediaText({
3545
)}
3646
>
3747
<div className={styles.text}>
38-
<h1 className={styles.title}>{title}</h1>
39-
{body && <p className={styles.body}>{body}</p>}
40-
{cta && (
41-
<Button
42-
className={styles.button}
43-
url={cta.url ? cta.url : null}
44-
text={cta.text ? cta.text : null}
45-
icon={cta.icon ? cta.icon : null}
46-
type="primary"
47-
size="md"
48-
/>
48+
{children ? (
49+
children
50+
) : (
51+
<>
52+
{title && <h1 className={styles.title}>{title}</h1>}
53+
{body && <p className={styles.body}>{body}</p>}
54+
{cta && (
55+
<Button
56+
className={styles.button}
57+
url={cta.url ? cta.url : null}
58+
text={cta.text ? cta.text : null}
59+
icon={cta.icon ? cta.icon : null}
60+
type="primary"
61+
size="md"
62+
/>
63+
)}
64+
</>
4965
)}
5066
</div>
5167
<div className={styles.media}>
@@ -63,6 +79,7 @@ export default function MediaText({
6379
MediaText.propTypes = {
6480
body: PropTypes.string,
6581
className: PropTypes.string,
82+
children: PropTypes.element,
6683
cta: PropTypes.shape({
6784
text: PropTypes.string,
6885
url: PropTypes.string,

components/organisms/MediaText/MediaText.stories.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,25 @@ Media will display on the right on large screens by default. Use the `mediaLeft`
4141
/>
4242
</Story>
4343
</Canvas>
44+
45+
## Children
46+
47+
You can display children as an element using the `children` prop. If used, the `title`, `body`, and `cta` will not display.
48+
49+
<Canvas>
50+
<Story name="Children">
51+
<MediaText
52+
children={
53+
<div>
54+
<p>Hi I'm a child element!</p>
55+
</div>
56+
}
57+
image={{
58+
url:
59+
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
60+
alt: 'Some alt text'
61+
}}
62+
mediaLeft
63+
/>
64+
</Story>
65+
</Canvas>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"eslint": "^7.18.0",
6060
"eslint-config-prettier": "^7.2.0",
6161
"eslint-plugin-import": "^2.22.1",
62-
"eslint-plugin-jsdoc": "^31.3.3",
62+
"eslint-plugin-jsdoc": "^31.4.0",
6363
"eslint-plugin-jsx-a11y": "^6.4.1",
6464
"eslint-plugin-prettier": "^3.3.1",
6565
"eslint-plugin-react": "^7.22.0",
@@ -68,7 +68,7 @@
6868
"husky": "^4.3.8",
6969
"lint-staged": "^10.5.3",
7070
"next-seo": "^4.17.0",
71-
"next-sitemap": "^1.4.13",
71+
"next-sitemap": "^1.4.15",
7272
"postcss-flexbugs-fixes": "^4.2.1",
7373
"postcss-preset-env": "^6.7.0",
7474
"prettier": "^2.2.1",

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5942,10 +5942,10 @@ eslint-plugin-import@^2.22.1:
59425942
resolve "^1.17.0"
59435943
tsconfig-paths "^3.9.0"
59445944

5945-
eslint-plugin-jsdoc@^31.3.3:
5946-
version "31.3.3"
5947-
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-31.3.3.tgz#e4ca6d37162f91b0430e4fe036dc096513dba99c"
5948-
integrity sha512-7kmYu7qQpwe4gCLTBGSpwkiCzmsDlQui7HNlEArUE6Jbqb6ddWpn4Q4X26bOpcByRsyAwm+0xwZtWmJVSue+kw==
5945+
eslint-plugin-jsdoc@^31.4.0:
5946+
version "31.4.0"
5947+
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-31.4.0.tgz#70e00f5f8f7cc695de36319d0e761e1a784ae10e"
5948+
integrity sha512-NX387IVQrA/ZE9F1tpeEFzZDsXb/BJS4HdT1ZH0RME3O/4DJF8GNQnjMSia8O3gFx/kjfASsdmK5LglVs+xGLA==
59495949
dependencies:
59505950
comment-parser "1.1.1"
59515951
debug "^4.3.1"
@@ -9263,10 +9263,10 @@ next-seo@^4.17.0:
92639263
resolved "https://registry.yarnpkg.com/next-seo/-/next-seo-4.17.0.tgz#fb3dbe0ed7414aa9d83872ef5d8510980a6dae7e"
92649264
integrity sha512-/hnb3oq7bhi8s7bup7+Lm6VzzgRucj+JrWtp+dJiYs/04H0N/NhmE9MpepixQ16fFj6G/39JLYxhzsO/QZG/Kw==
92659265

9266-
next-sitemap@^1.4.13:
9267-
version "1.4.13"
9268-
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-1.4.13.tgz#2c7638f1a48a43db8aa138e53cf9c857e540052f"
9269-
integrity sha512-jaf6VsYHU5zIJUYiciN6xSrGqrMoT3xwrmLvCk+//B9jxg+aXqTdl3jKH9QYcHSf5aHo/skAmqMbiXZqaEfwjg==
9266+
next-sitemap@^1.4.15:
9267+
version "1.4.15"
9268+
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-1.4.15.tgz#6c4529c5550d7051338010642e253323f5ddcf67"
9269+
integrity sha512-pkkfyZHKEVdgLf7t41uWbCbC0Wj/8m9+9COlV3QBWmbrTSlOZiiXj9zqrRjd3vKhvHOnEHvqIsOkWtxg5hnZgw==
92709270
dependencies:
92719271
"@corex/deepmerge" "^2.5.3"
92729272
matcher "^3.0.0"

0 commit comments

Comments
 (0)