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

Commit 5d53868

Browse files
committed
Merge branch 'staging' into feature/60-finish-comments
2 parents 558b917 + 08d35fc commit 5d53868

37 files changed

+782
-275
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Link from 'next/link'
2+
import PropTypes from 'prop-types'
3+
import styles from './Breadcrumbs.module.css'
4+
5+
/**
6+
* Render the Breadcrumbs component.
7+
*
8+
* @author WebDevStudios
9+
* @param {object} props The component attributes as props.
10+
* @param {Array} props.breadcrumbs The breadcrumb array.
11+
* @return {Element} The Breadcrumbs component.
12+
*/
13+
export default function Breadcrumbs({breadcrumbs}) {
14+
return (
15+
<>
16+
{!!breadcrumbs?.length && (
17+
<ul className={styles.breadcrumbs}>
18+
{breadcrumbs.map((breadcrumb, index) => (
19+
<li key={index}>
20+
<Link href={breadcrumb?.url}>
21+
<a>{breadcrumb?.text}</a>
22+
</Link>
23+
{index < breadcrumbs.length - 1 && (
24+
<span className={styles.sep}> &raquo; </span>
25+
)}
26+
</li>
27+
))}
28+
</ul>
29+
)}
30+
</>
31+
)
32+
}
33+
34+
Breadcrumbs.propTypes = {
35+
breadcrumbs: PropTypes.array.isRequired
36+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ul.breadcrumbs {
2+
@apply mb-8 flex;
3+
4+
& li {
5+
@apply text-sm font-semibold;
6+
7+
& .sep {
8+
@apply px-2 opacity-50 font-normal;
9+
}
10+
}
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import Breadcrumbs from '.'
4+
5+
export const crumbs = [
6+
{
7+
text: 'Home',
8+
url: '/'
9+
},
10+
{
11+
text: 'About',
12+
url: '/about'
13+
},
14+
{
15+
text: 'Our Team',
16+
url: '/about/team'
17+
}
18+
]
19+
20+
<Meta title="Components/Atoms/Breadcrumbs" component={Breadcrumbs} />
21+
22+
# Breadcrumbs
23+
24+
Use this component to display site breadcrumbs.
25+
26+
<Canvas>
27+
<Story name="Component">
28+
<Breadcrumbs breadcrumbs={crumbs} />
29+
</Story>
30+
</Canvas>

components/atoms/Breadcrumbs/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './Breadcrumbs'
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
33
import styles from './Container.module.css'
4+
import cn from 'classnames'
45

56
/**
67
* Render the Container component.
78
*
8-
* @param {object} props Container component props.
9-
* @param {Element} props.children Container children.
10-
* @return {Element} The Container component.
9+
* @param {object} props Container component props.
10+
* @param {object} props.children Container children.
11+
* @param {boolean} props.paddingTop Should container render top padding.
12+
* @param {boolean} props.paddingBtm Should container render bottom padding.
13+
* @return {Element} The Container component.
1114
*/
12-
export default function Container({children}) {
13-
return <div className={styles.containerW}>{children && children}</div>
15+
export default function Container({children, paddingTop, paddingBtm}) {
16+
return (
17+
<div
18+
className={cn(
19+
styles.containerW,
20+
paddingTop && styles.paddingTop,
21+
paddingBtm && styles.paddingBtm
22+
)}
23+
>
24+
{children && children}
25+
</div>
26+
)
1427
}
1528

1629
Container.propTypes = {
17-
children: PropTypes.element
30+
children: PropTypes.node,
31+
paddingTop: PropTypes.bool,
32+
paddingBtm: PropTypes.bool
33+
}
34+
35+
Container.defaultProps = {
36+
paddingTop: true,
37+
paddingBtm: true
1838
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
.containerW {
22
@apply container;
3+
4+
&.paddingTop {
5+
@apply pt-12;
6+
}
7+
8+
&.paddingBtm {
9+
@apply pb-12;
10+
}
311
}

components/atoms/Heading/Heading.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import createMarkup from '@/functions/createMarkup'
2+
import PropTypes from 'prop-types'
3+
import React from 'react'
4+
5+
/**
6+
* Render the Heading component.
7+
*
8+
* @param {object} props The props object.
9+
* @param {string} props.children The elements or text you'd like to render inside the heading.
10+
* @param {string} props.className The optional classname.
11+
* @param {string} props.id The optional ID.
12+
* @param {string} props.tag The tag name you'd like the heading to render as.
13+
* @return {Element} The Heading element.
14+
*/
15+
export default function Heading({children, className, id, tag}) {
16+
if (typeof children === 'string') {
17+
return React.createElement(tag, {
18+
className,
19+
id,
20+
dangerouslySetInnerHTML: createMarkup(children)
21+
})
22+
} else {
23+
return React.createElement(
24+
tag,
25+
{
26+
className,
27+
id
28+
},
29+
children
30+
)
31+
}
32+
}
33+
34+
Heading.propTypes = {
35+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
36+
className: PropTypes.string,
37+
id: PropTypes.string,
38+
tag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
39+
}
40+
41+
Heading.defaultProps = {
42+
tag: 'h1'
43+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import {Meta, Story, Canvas} from '@storybook/addon-docs/blocks'
2+
3+
import Heading from '.'
4+
5+
<Meta title="Components/Atoms/Heading" component={Heading} />
6+
7+
# Heading
8+
9+
Use this component inside other components when you need to dynamically set the heading tag that's used.
10+
For example, a card's heading might need to be `<h2>` in one place but an `<h3>` when used somewhere else.
11+
12+
This component is deliberatley unstyled. Pass down class names with the `className` prop.
13+
14+
<Canvas>
15+
<Story name="Component">
16+
<Heading>This is a heading</Heading>
17+
</Story>
18+
</Canvas>
19+
20+
# Tag
21+
22+
`<h1>` through `<h6>` tags are supported.
23+
24+
<Canvas>
25+
<Story name="Tag">
26+
<Heading tag="h1">This is an h1</Heading>
27+
<Heading tag="h2">This is an h2</Heading>
28+
<Heading tag="h3">This is an h3</Heading>
29+
<Heading tag="h4">This is an h4</Heading>
30+
<Heading tag="h5">This is an h5</Heading>
31+
<Heading tag="h6">This is an h6</Heading>
32+
</Story>
33+
</Canvas>
34+
35+
# Markup Support
36+
37+
This component supports various types of children content including strings of HTML and standard JSX. The following shows both content types being passed in as children.
38+
39+
<Canvas>
40+
<Story name="Markup Support">
41+
<Heading tag="h1">{'<strong>String</strong> of HTML Example'}</Heading>
42+
<Heading tag="h1">
43+
<strong>Object</strong> of JSX Example
44+
</Heading>
45+
</Story>
46+
</Canvas>
47+
48+
## Controls
49+
50+
export const Template = (args) => <Heading {...args}>{args.children}</Heading>
51+
52+
<Canvas>
53+
<Story
54+
name="Controls"
55+
args={{
56+
tag: 'h1',
57+
children: 'This is a heading'
58+
}}
59+
>
60+
{Template.bind({})}
61+
</Story>
62+
</Canvas>

components/atoms/Heading/index.js

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

components/atoms/Separator/Separator.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import cn from 'classnames'
22
import PropTypes from 'prop-types'
33
import React from 'react'
4-
import Container from '../Container'
54
import styles from './Separator.module.css'
65

76
/**
@@ -19,9 +18,7 @@ export default function Separator({className, fullWidth}) {
1918
{fullWidth ? (
2019
<hr className={cn(styles.separator, className)} />
2120
) : (
22-
<Container>
23-
<hr className={cn(styles.separator, className)} />
24-
</Container>
21+
<hr className={cn(styles.separator, className)} />
2522
)}
2623
</>
2724
)

0 commit comments

Comments
 (0)