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

Commit 4441daf

Browse files
committed
Adding separator block and docblocks
1 parent 1da1c38 commit 4441daf

File tree

7 files changed

+111
-13
lines changed

7 files changed

+111
-13
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import cn from 'classnames'
2+
import PropTypes from 'prop-types'
3+
import React from 'react'
4+
import styles from './Separator.module.css'
5+
6+
/**
7+
* Render the Separator component.
8+
*
9+
* @author WebDevStudios
10+
* @param {object} props The component attributes as props.
11+
* @param {string} props.className Optional classname.
12+
* @param {boolean} props.fullWidth Is this a fullwidth block.
13+
* @return {Element} The Separator component.
14+
*/
15+
export default function Separator(props) {
16+
const {className, fullWidth} = props
17+
18+
return (
19+
<>
20+
{fullWidth ? (
21+
<hr className={cn(styles.separator, className)} />
22+
) : (
23+
<div>
24+
<hr className={cn(styles.separator, className)} />
25+
</div>
26+
)}
27+
</>
28+
)
29+
}
30+
31+
Separator.propTypes = {
32+
className: PropTypes.string,
33+
fullWidth: PropTypes.bool.isRequired
34+
}
35+
36+
Separator.defaultProps = {
37+
fullWidth: false
38+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.separator {
2+
@apply w-full bg-tertiary-lightest border-none my-40;
3+
4+
height: 1px;
5+
}
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/Separator/index.js

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

components/blocks/BlockHeadings/BlockHeadings.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ import React from 'react'
99
* The core Headings block from Gutenberg.
1010
*
1111
* @author WebDevStudios
12-
* @param {object} props The component attributes as props.
12+
* @param props.props
13+
* @param {object} props The component attributes as props.
14+
* @param {string} props.className Optional classnames.
15+
* @param {string} props.align Optional alignment style.
16+
* @param {string} props.anchor Optional anchor/id.
17+
* @param {string} props.content The content of the block.
18+
* @param {string} props.level The heading level.
19+
* @return {Element} The RichText component.
1320
*/
1421
export default function BlockHeadings({props}) {
15-
const {anchor, align, className, content, level} = props
22+
const {className, align, anchor, content, level} = props
1623
const alignment = !align ? 'left' : align
1724

1825
return (

components/blocks/BlockParagraph/BlockParagraph.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import PropTypes from 'prop-types'
88
* The core Paragraph block from Gutenberg.
99
*
1010
* @author WebDevStudios
11-
* @param {object} props The component attributes as props.
11+
* @param props.props
12+
* @param {object} props The component attributes as props.
13+
* @param {string} props.className Optional classnames.
14+
* @param {string} props.align Optional alignment style.
15+
* @param {string} props.anchor Optional anchor/id.
16+
* @param {string} props.content The content of the block.
17+
* @return {Element} The RichText component.
1218
*/
1319
export default function BlockParagraph({props}) {
1420
const {className, align, anchor, content} = props
@@ -29,9 +35,6 @@ BlockParagraph.propTypes = {
2935
props: PropTypes.object.isRequired,
3036
align: PropTypes.string,
3137
anchor: PropTypes.string,
32-
backgroundColor: PropTypes.string,
3338
className: PropTypes.string,
34-
content: PropTypes.string,
35-
fontSize: PropTypes.string,
36-
textColor: PropTypes.string
39+
content: PropTypes.string
3740
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Separator from '@/components/atoms/Separator'
12
import PropTypes from 'prop-types'
23

34
/**
@@ -6,24 +7,25 @@ import PropTypes from 'prop-types'
67
* The core Separator block from Gutenberg.
78
*
89
* @author WebDevStudios
9-
* @param {object} props The component attributes as props.
10+
* @param props.props
11+
* @param {object} props The component attributes as props.
12+
* @param {string} props.className Optional classnames.
13+
* @param {string} props.anchor Optional anchor/id.
14+
* @return {Element} The Separator component.
1015
*/
1116
export default function BlockSeparator({props}) {
12-
const {className, color, anchor} = props
17+
const {className, anchor} = props
1318

1419
const isFullWidth =
1520
(className && className.includes('is-style-full-width')) > 0 ? true : false
1621

1722
return (
18-
<pre>
19-
{JSON.stringify(isFullWidth, {className, color, anchor}, null, 2)}
20-
</pre>
23+
<Separator className={className} anchor={anchor} fullWidth={isFullWidth} />
2124
)
2225
}
2326

2427
BlockSeparator.propTypes = {
2528
props: PropTypes.object.isRequired,
2629
className: PropTypes.string,
27-
color: PropTypes.string,
2830
anchor: PropTypes.string
2931
}

0 commit comments

Comments
 (0)