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

Commit 4e7845b

Browse files
committed
Merge branch 'staging' of github.com:WebDevStudios/nextjs-wordpress-starter into staging
2 parents 45f869a + 06b46a2 commit 4e7845b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+919
-129
lines changed

components/atoms/Code/Code.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import PropTypes from 'prop-types'
2+
import React from 'react'
3+
import styles from './Code.module.css'
4+
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
5+
import {tomorrow} from 'react-syntax-highlighter/dist/cjs/styles/prism'
6+
7+
/**
8+
* Render the Code component.
9+
*
10+
* @author WebDevStudios
11+
* @param {object} props The component attributes as props.
12+
* @param {string} props.className Optional classname.
13+
* @param props.id
14+
* @param props.content
15+
* @param {boolean} props.fullWidth Is this a fullwidth block.
16+
* @return {Element} The Code component.
17+
*/
18+
export default function Code({id, className, content}) {
19+
// Use the className to pass the langauge.
20+
const language = className ? className : 'javascript'
21+
22+
// Replace any `<` and `> encoded HTML.
23+
let code = content.replace(/&lt;/g, '<')
24+
code = code.replace(/&gt;/g, '>')
25+
26+
return (
27+
<>
28+
{!!content && (
29+
<div id={id ? id : null} className={styles.code}>
30+
<SyntaxHighlighter style={tomorrow} language={language}>
31+
{code}
32+
</SyntaxHighlighter>
33+
</div>
34+
)}
35+
</>
36+
)
37+
}
38+
39+
Code.propTypes = {
40+
id: PropTypes.string,
41+
content: PropTypes.string,
42+
className: PropTypes.string
43+
}

components/atoms/Code/Code.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.code {
2+
@apply mb-40;
3+
4+
& > pre {
5+
@apply rounded-larger;
6+
}
7+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import Separator from '.'
4+
5+
<Meta title="Components/Atoms/Separator" component={Separator} />
6+
7+
# Separator
8+
9+
Use this component to display a page separator with top and bottom margins. Use it anywhere you would use an `<hr>` element.
10+
11+
<Canvas>
12+
<Story name="Component">
13+
<Separator />
14+
</Story>
15+
</Canvas>
16+
17+
## Full Width
18+
19+
The default separator is equal to the container width. To get a full width separator, set the `fullWidth` prop to true.
20+
21+
<Canvas>
22+
<Story name="Full Width">
23+
<Separator fullWidth />
24+
</Story>
25+
</Canvas>
26+
27+
## Controls
28+
29+
Play around with `<Separator />` props in the [Canvas tab of the Controls story](?path=/story/design-system-atoms-separator--controls).
30+
31+
export const Template = (args) => <Separator {...args} />
32+
33+
<Canvas>
34+
<Story
35+
name="Controls"
36+
args={{
37+
fullWidth: false
38+
}}
39+
>
40+
{Template.bind({})}
41+
</Story>
42+
</Canvas>

components/atoms/Code/index.js

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

components/atoms/Image/Image.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import Link from 'next/link'
2+
import PropTypes from 'prop-types'
3+
import React from 'react'
4+
import RichText from '@/components/atoms/RichText'
5+
import styles from './Image.module.css'
6+
import cn from 'classnames'
7+
8+
/**
9+
* Render the Image component.
10+
*
11+
* @author WebDevStudios
12+
* @param {string} anchor The anchor/id of the block.
13+
* @param {string} alt The image alt text.
14+
* @param {string} caption The image caption.
15+
* @param {string} className The image class.
16+
* @param {string} id The image ID.
17+
* @param {string} href The URL of the link.
18+
* @param {string} linkTarget Target for the link.
19+
* @param {string} linkClass Class for the link.
20+
* @param {string} rel The rel attribute for the link.
21+
* @param {string} sizeSlug The WP image size.
22+
* @param {string} url The full URL path of the image.
23+
* @return {Element} The Image component.
24+
*/
25+
export default function Image({
26+
alt,
27+
anchor,
28+
caption,
29+
className,
30+
id,
31+
href,
32+
linkTarget,
33+
linkClass,
34+
rel,
35+
url
36+
}) {
37+
return (
38+
<>
39+
{!!url && (
40+
<div id={anchor || null} className={styles.image}>
41+
{href ? (
42+
<Link href={href}>
43+
<a
44+
target={linkTarget || null}
45+
rel={rel || null}
46+
className={linkClass || null}
47+
>
48+
<img
49+
src={url}
50+
alt={alt}
51+
className={cn(className, `image-${id}`)}
52+
/>
53+
</a>
54+
</Link>
55+
) : (
56+
<img
57+
src={url}
58+
alt={alt}
59+
className={cn(className, id && `image-${id}`)}
60+
/>
61+
)}
62+
{!!caption && (
63+
<div className={styles.caption}>
64+
<RichText tag="span">{caption}</RichText>
65+
</div>
66+
)}
67+
</div>
68+
)}
69+
</>
70+
)
71+
}
72+
73+
Image.propTypes = {
74+
alt: PropTypes.string,
75+
anchor: PropTypes.string,
76+
caption: PropTypes.string,
77+
className: PropTypes.string,
78+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
79+
href: PropTypes.string,
80+
linkClass: PropTypes.string,
81+
linkTarget: PropTypes.string,
82+
rel: PropTypes.string,
83+
sizeSlug: PropTypes.string,
84+
url: PropTypes.string
85+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.image {
2+
@apply mb-20;
3+
4+
& img {
5+
@apply block rounded;
6+
}
7+
8+
& .caption {
9+
@apply text-center font-secondary text-xs pt-12;
10+
}
11+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import Image from '.'
4+
5+
<Meta title="Components/Atoms/Image" component={Image} />
6+
7+
# Image
8+
9+
Use this component to display a image.
10+
11+
<Canvas>
12+
<Story name="Component">
13+
<Image
14+
url="https://images.unsplash.com/photo-1611149469739-cf4647d61f07?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80"
15+
alt="Image alt text"
16+
caption="This is the image caption"
17+
/>
18+
</Story>
19+
</Canvas>
20+
21+
## Image + Link
22+
23+
Add a link to the image using the `href` prop.
24+
25+
<Canvas>
26+
<Story name="Image + Link">
27+
<Image
28+
url="https://images.unsplash.com/photo-1611149469739-cf4647d61f07?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80"
29+
alt="Image alt text"
30+
caption="This is the image caption"
31+
href="https://google.com"
32+
/>
33+
</Story>
34+
</Canvas>
35+
36+
## Controls
37+
38+
Play around with `<Image />` props in the [Canvas tab of the Controls story](?path=/story/components-atoms-image--controls).
39+
40+
export const Template = (args) => <Image {...args} />
41+
42+
<Canvas>
43+
<Story
44+
name="Controls"
45+
args={{
46+
url:
47+
'https://images.unsplash.com/photo-1611149469739-cf4647d61f07?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80',
48+
caption: 'Jeffery Smith, 28'
49+
}}
50+
>
51+
{Template.bind({})}
52+
</Story>
53+
</Canvas>

components/atoms/Image/index.js

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

components/atoms/PullQuote/PullQuote.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import styles from './PullQuote.module.css'
1111
* @param {string} citation The optional author citation.
1212
* @param {string} id Optional anchor/id.
1313
* @param {string} className Optional classnames.
14-
* @return {Element} The PullQuote component.
14+
* @return {Element} The PullQuote component.
1515
*/
1616
export default function PullQuote({value, citation, id, className}) {
1717
return (
@@ -24,7 +24,9 @@ export default function PullQuote({value, citation, id, className}) {
2424
</div>
2525
</blockquote>
2626
{!!citation && (
27-
<figcaption className={styles.cite}>~ {citation}</figcaption>
27+
<figcaption className={styles.cite}>
28+
~ <RichText tag="span">{citation}</RichText>
29+
</figcaption>
2830
)}
2931
</figure>
3032
)}

components/atoms/PullQuote/PullQuote.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
}
77

88
& > figcaption {
9-
@apply font-secondary text-sm italic;
9+
@apply font-secondary text-xs pt-12;
1010
}
1111
}

0 commit comments

Comments
 (0)