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

Commit 4286b4f

Browse files
author
Greg Rickaby
authored
Merge pull request #130 from WebDevStudios/feature/component-handling
Feature/component handling
2 parents 39fdc35 + c6c2afa commit 4286b4f

Some content is hidden

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

54 files changed

+914
-180
lines changed

api/wordpress/_global/getPostTypeArchive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const archiveSeo = {
5252
* @param {string} cursor Start/end cursor for pagination.
5353
* @param {boolean} getNext Whether to retrieve next set of posts (true) or previous set (false).
5454
* @param {number} perPage Number of posts per page.
55-
* @return {object} Object containing Apollo client instance and post archive data or error object.
55+
* @return {object} Object containing Apollo client instance and post archive data or error object.
5656
*/
5757
export default async function getPostTypeArchive(
5858
postType,

api/wordpress/_global/getPostTypeById.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import getMenus from '../menus/getMenus'
2020
* @param {number | string} id Post identifier.
2121
* @param {string} idType Type of ID.
2222
* @param {string} preview Whether query is for a regular post view (null), a preview check (basic), or full post preview (full).
23-
* @return {object} Object containing Apollo client instance and post data or error object.
23+
* @return {object} Object containing Apollo client instance and post data or error object.
2424
*/
2525
export default async function getPostTypeById(
2626
postType,

api/wordpress/_global/getPostTypeStaticPaths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {initializeWpApollo} from '../connector'
77
*
88
* @author WebDevStudios
99
* @param {string} postType WP post type.
10-
* @return {object} Post type paths.
10+
* @return {object} Post type paths.
1111
*/
1212
export default async function getPostTypeStaticPaths(postType) {
1313
if (!postType || !isValidPostType(postType)) {

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import getFrontendPage, {frontendPageSeo} from './getFrontendPage'
1212
* @param {string} postType Post Type.
1313
* @param {boolean} preview Whether requesting preview of post.
1414
* @param {object} previewData Post preview data.
15-
* @return {object} Object containing post props and revalidate setting.
15+
* @return {object} Object containing post props and revalidate setting.
1616
*/
1717
export default async function getPostTypeStaticProps(
1818
params,

api/wordpress/_global/postTypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const hierarchicalPostTypes = ['page']
5050
*
5151
* @author WebDevStudios
5252
* @param {string} postType WP post type.
53-
* @return {boolean} Whether provided post type is valid.
53+
* @return {boolean} Whether provided post type is valid.
5454
*/
5555
export function isValidPostType(postType) {
5656
return Object.keys(postTypes).includes(postType)
@@ -61,7 +61,7 @@ export function isValidPostType(postType) {
6161
*
6262
* @author WebDevStudios
6363
* @param {string} postType WP post type.
64-
* @return {boolean} Whether provided post type is hierarchical.
64+
* @return {boolean} Whether provided post type is hierarchical.
6565
*/
6666
export function isHierarchicalPostType(postType) {
6767
return hierarchicalPostTypes.includes(postType)

api/wordpress/connector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let wpApolloClient
3030
*
3131
* @author WebDevStudios
3232
* @param {boolean} auth Whether to include authentication via WP application password.
33-
* @return {object} Apollo client instance.
33+
* @return {object} Apollo client instance.
3434
*/
3535
export function createWpApolloClient(auth = false) {
3636
return new ApolloClient({
@@ -51,7 +51,7 @@ export function createWpApolloClient(auth = false) {
5151
*
5252
* @author WebDevStudios
5353
* @param {*} initialState Initial Apollo state.
54-
* @return {object} WP Apollo client instance.
54+
* @return {object} WP Apollo client instance.
5555
*/
5656
export function initializeWpApollo(initialState = null) {
5757
// Only run one instance of the Apollo client.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import cn from 'classnames'
2+
import PropTypes from 'prop-types'
3+
import RichText from '../RichText'
4+
import styles from './PullQuote.module.css'
5+
6+
/**
7+
* PullQuote Block
8+
*
9+
* @author WebDevStudios
10+
* @param {string} value The pull quote content of the block.
11+
* @param {string} citation The optional author citation.
12+
* @param {string} id Optional anchor/id.
13+
* @param {string} className Optional classnames.
14+
* @return {Element} The PullQuote component.
15+
*/
16+
export default function PullQuote({value, citation, id, className}) {
17+
return (
18+
<>
19+
{!!value && (
20+
<figure id={id ? id : null} className={cn(styles.pullquote, className)}>
21+
<blockquote>
22+
<div className={styles.content}>
23+
<RichText tag="div">{value}</RichText>
24+
</div>
25+
</blockquote>
26+
{!!citation && (
27+
<figcaption className={styles.cite}>~ {citation}</figcaption>
28+
)}
29+
</figure>
30+
)}
31+
</>
32+
)
33+
}
34+
35+
PullQuote.propTypes = {
36+
id: PropTypes.string,
37+
className: PropTypes.string,
38+
value: PropTypes.string,
39+
citation: PropTypes.string
40+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.pullquote {
2+
@apply mb-24 p-20 px-40 text-center;
3+
4+
& p {
5+
@apply font-secondary text-h5;
6+
}
7+
8+
& > figcaption {
9+
@apply font-secondary text-sm italic;
10+
}
11+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import PullQuote from '.'
4+
5+
<Meta title="Components/Atoms/Pullquote" component={PullQuote} />
6+
7+
# Pull Quote
8+
9+
Use this to display a pull quote.
10+
11+
<Canvas>
12+
<Story name="Component">
13+
<PullQuote
14+
quote="I have no other view than to promote the public good, and am unambitious of honors not founded in the approbation of my country."
15+
citation="George Washington"
16+
/>
17+
</Story>
18+
</Canvas>
19+
20+
## Controls
21+
22+
Play around with `<PullQuote />` props in the [Canvas tab of the Controls story](?path=/story/design-system-molecules-pullquote--controls).
23+
24+
export const Template = (args) => <PullQuote {...args} />
25+
26+
<Canvas>
27+
<Story
28+
name="Controls"
29+
args={{
30+
quote:
31+
'I have no other view than to promote the public good, and am unambitious of honors not founded in the approbation of my country.',
32+
citation: 'George Washington',
33+
image:
34+
'https://upload.wikimedia.org/wikipedia/commons/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg',
35+
imageAlt: "George Washington's official portrait"
36+
}}
37+
>
38+
{Template.bind({})}
39+
</Story>
40+
</Canvas>

components/atoms/PullQuote/index.js

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

0 commit comments

Comments
 (0)