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

feature/410-expand-block-attrs #472

Merged
merged 16 commits into from
Jun 1, 2021
Merged
12 changes: 9 additions & 3 deletions components/atoms/Code/Code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cn from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
Expand All @@ -15,8 +16,10 @@ import styles from './Code.module.css'
* @return {Element} The Code component.
*/
export default function Code({id, className, content}) {
// Use the className to pass the langauge.
const language = className ? className : 'javascript'
const classNames = className?.length ? className.split(' ') : []

// Use the first entry in className to pass the langauge.
const language = classNames?.length ? classNames.shift() : 'javascript'

/**
* Replace any `<` and `> encoded HTML.
Expand All @@ -36,7 +39,10 @@ export default function Code({id, className, content}) {
return (
<>
{!!content && (
<div id={id ? id : null} className={styles.code}>
<div
id={id ? id : null}
className={cn(styles.code, classNames.join(' '))}
>
<SyntaxHighlighter style={tomorrow} language={language}>
{codeFormatter(content)}
</SyntaxHighlighter>
Expand Down
7 changes: 5 additions & 2 deletions components/atoms/Code/Code.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Use this component to display a code block.

<Canvas>
<Story name="Component">
<Code content="<p>this is a code block!</p>" />
<Code
content="<p>this is a code block!</p>"
className="html custom-class"
/>
</Story>
</Canvas>

Expand All @@ -25,7 +28,7 @@ export const Template = (args) => <Code {...args} />
name="Controls"
args={{
content: '<p>this is a code block!</p>',
className: 'html'
className: 'html custom-class'
}}
>
{Template.bind({})}
Expand Down
8 changes: 5 additions & 3 deletions components/atoms/Separator/Separator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ import styles from './Separator.module.css'
*
* @author WebDevStudios
* @param {object} props The component properties.
* @param {string} props.anchor Optional anchor/id.
* @param {string} props.className Optional classname.
* @param {boolean} props.fullWidth Is this a fullwidth block.
* @return {Element} The Separator component.
*/
export default function Separator({className, fullWidth}) {
export default function Separator({anchor, className, fullWidth}) {
return (
<>
{fullWidth ? (
<hr className={cn(styles.separator, className)} />
<hr id={anchor} className={cn(styles.separator, className)} />
) : (
<hr className={cn(styles.separator, className)} />
<hr id={anchor} className={cn(styles.separator, className)} />
)}
</>
)
}

Separator.propTypes = {
anchor: PropTypes.string,
className: PropTypes.string,
fullWidth: PropTypes.bool.isRequired
}
Expand Down
16 changes: 10 additions & 6 deletions components/blocks/Gutenberg/BlockColumns/BlockColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ import PropTypes from 'prop-types'
*
* @author WebDevStudios
* @param {object} props The component properties.
* @param {object} props.options Option props object.
* @param {object} props.columns Option props object.
* @param {object} props.innerBlocks The array of inner blocks to display.
* @return {Element} The Columns component.
*/
export default function BlockColumns({options, innerBlocks}) {
export default function BlockColumns({columns, innerBlocks}) {
return (
<>
{!!innerBlocks?.length && (
<Columns
id={options?.anchor}
className={options?.className}
id={columns?.anchor}
className={columns?.className}
columnCount={innerBlocks?.length}
>
{innerBlocks.map((block, index) => {
return (
<div key={`column-${index}`}>
<div
key={`column-${index}`}
id={block?.attributes?.anchor}
className={block?.attributes?.className}
>
{!!block?.innerBlocks?.length && (
<Blocks blocks={block.innerBlocks} />
)}
Expand All @@ -38,7 +42,7 @@ export default function BlockColumns({options, innerBlocks}) {
}

BlockColumns.propTypes = {
options: PropTypes.shape({
columns: PropTypes.shape({
anchor: PropTypes.string,
className: PropTypes.string
}),
Expand Down
7 changes: 6 additions & 1 deletion components/blocks/Gutenberg/BlockCover/BlockCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default function BlockCover({media, innerBlocks}) {
return (
<>
{!!media?.url && (
<Hero backgroundImage={media} id={media?.anchor}>
<Hero
backgroundImage={media}
id={media?.anchor}
className={media?.className}
>
{!!innerBlocks?.length && <Blocks blocks={innerBlocks} />}
</Hero>
)}
Expand All @@ -28,6 +32,7 @@ export default function BlockCover({media, innerBlocks}) {
BlockCover.propTypes = {
media: PropTypes.shape({
anchor: PropTypes.string,
className: PropTypes.string,
url: PropTypes.string
}),
innerBlocks: PropTypes.arrayOf(
Expand Down
2 changes: 2 additions & 0 deletions components/blocks/Gutenberg/BlockMediaText/BlockMediaText.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default function BlockMediaText({media, innerBlocks}) {
<>
{!!media && innerBlocks?.length && (
<MediaText
id={media?.anchor}
className={media?.className}
mediaLeft={media?.mediaPosition === 'left' ? true : false}
image={{url: media?.mediaUrl, alt: media?.mediaAlt}}
>
Expand Down
4 changes: 4 additions & 0 deletions components/organisms/Hero/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import styles from './Hero.module.css'
* @param {any} props.children InnerBlocks.
* @param {object} props.ctaText The cta text.
* @param {object} props.ctaUrl The cta url.
* @param {string} props.id Optional element ID.
* @param {string} props.subtitle Text for the subtitle.
* @param {string} props.title Text for the title.
* @return {Element} The Hero component.
Expand All @@ -25,11 +26,13 @@ export default function Hero({
children,
ctaText,
ctaUrl,
id,
subtitle,
title
}) {
return (
<section
id={id}
className={cn(styles.hero, className)}
style={{
// These css custom properties are used inside the css module file to set the card's background image, tint overlay, and fallback bg color.
Expand Down Expand Up @@ -65,6 +68,7 @@ Hero.propTypes = {
children: PropTypes.any,
ctaText: PropTypes.string,
ctaUrl: PropTypes.string,
id: PropTypes.string,
subtitle: PropTypes.string,
title: PropTypes.string
}
3 changes: 1 addition & 2 deletions components/organisms/Hero/Hero.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Use this to display a large CTA, usually at the top of a page.
title="New Designs"
body="Our amazing new design is here! Get it while it's hot, it won't be hot for long... uh oh, already cooling."
backgroundImage={{
url:
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60'
url: 'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60'
}}
cta={{icon: 'arrowRight', text: 'Take a look'}}
/>
Expand Down
4 changes: 4 additions & 0 deletions components/organisms/MediaText/MediaText.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import styles from './MediaText.module.css'
* @param {Element} props.children The child elements.
* @param {string} props.className The className.
* @param {object} props.cta The cta object with text and url strings.
* @param {string} props.id Optional element ID.
* @param {object} props.image The image object with url and alt text.
* @param {boolean} props.mediaLeft Whether to show media on the left of the text.
* @param {string} props.title The title.
Expand All @@ -23,6 +24,7 @@ export default function MediaText({
children,
className,
cta,
id,
image,
mediaLeft,
title
Expand All @@ -37,6 +39,7 @@ export default function MediaText({

return (
<section
id={id}
className={cn(
styles.mediaText,
mediaLeft ? styles.mediaLeft : null,
Expand Down Expand Up @@ -86,6 +89,7 @@ MediaText.propTypes = {
url: PropTypes.string,
icon: PropTypes.string
}),
id: PropTypes.string,
image: PropTypes.shape({
url: PropTypes.string,
alt: PropTypes.string
Expand Down
9 changes: 3 additions & 6 deletions components/organisms/MediaText/MediaText.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Use this to display media and text in a 50/50 layout.
title="New Designs"
body="Our amazing new design is here! Get it while it's hot, it won't be hot for long... uh oh, already cooling."
image={{
url:
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
url: 'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
alt: 'Some alt text'
}}
cta={{icon: 'arrowRight', text: 'Take a look'}}
Expand All @@ -32,8 +31,7 @@ Media will display on the right on large screens by default. Use the `mediaLeft`
title="New Designs"
body="Our amazing new design is here! Get it while it's hot, it won't be hot for long... uh oh, already cooling."
image={{
url:
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
url: 'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
alt: 'Some alt text'
}}
cta={{icon: 'arrowRight', text: 'Take a look'}}
Expand All @@ -55,8 +53,7 @@ You can display children as an element using the `children` prop. If used, the `
</div>
}
image={{
url:
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
url: 'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
alt: 'Some alt text'
}}
mediaLeft
Expand Down