This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 13 files changed +171
-17
lines changed Expand file tree Collapse file tree 13 files changed +171
-17
lines changed Original file line number Diff line number Diff line change
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 `<` encoded HTML.
23
+ const code = content . replace ( / & l t ; / g, '<' )
24
+
25
+ return (
26
+ < >
27
+ { ! ! content && (
28
+ < div id = { id ? id : null } className = { styles . code } >
29
+ < SyntaxHighlighter style = { tomorrow } language = { language } >
30
+ { code }
31
+ </ SyntaxHighlighter >
32
+ </ div >
33
+ ) }
34
+ </ >
35
+ )
36
+ }
37
+
38
+ Code . propTypes = {
39
+ id : PropTypes . string ,
40
+ content : PropTypes . string ,
41
+ className : PropTypes . string
42
+ }
Original file line number Diff line number Diff line change
1
+ .code {
2
+ @apply mb-40;
3
+
4
+ & > pre {
5
+ @apply rounded-larger;
6
+ }
7
+ }
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
1
+ export { default } from './Code'
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ Image.propTypes = {
75
75
anchor : PropTypes . string ,
76
76
caption : PropTypes . string ,
77
77
className : PropTypes . string ,
78
- id : PropTypes . number ,
78
+ id : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
79
79
href : PropTypes . string ,
80
80
linkClass : PropTypes . string ,
81
81
linkTarget : PropTypes . string ,
Original file line number Diff line number Diff line change @@ -7,14 +7,11 @@ import styles from './Separator.module.css'
7
7
* Render the Separator component.
8
8
*
9
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.
10
+ * @param {string } className Optional classname.
11
+ * @param {boolean } fullWidth Is this a fullwidth block.
12
+ * @return {Element } The Separator component.
14
13
*/
15
- export default function Separator ( props ) {
16
- const { className, fullWidth} = props
17
-
14
+ export default function Separator ( { className, fullWidth} ) {
18
15
return (
19
16
< >
20
17
{ fullWidth ? (
Original file line number Diff line number Diff line change @@ -6,14 +6,11 @@ import tailwindConfig from '../../../tailwind.config'
6
6
* Render the Spacer component.
7
7
*
8
8
* @author WebDevStudios
9
- * @param {object } props The component attributes as props.
10
- * @param {string } props.anchor Optional anchor/id.
11
- * @param {number } props.height The height of the spacer.
12
- * @return {Element } The Spacer component.
9
+ * @param {string } anchor Optional anchor/id.
10
+ * @param {number } height The height of the spacer.
11
+ * @return {Element } The Spacer component.
13
12
*/
14
- export default function Spacer ( props ) {
15
- const { height, anchor} = props
16
-
13
+ export default function Spacer ( { height, anchor} ) {
17
14
const rootEmVal = parseFloat ( tailwindConfig . theme . fontSize [ 'root-em' ] )
18
15
19
16
return (
Original file line number Diff line number Diff line change
1
+ import Code from '@/components/atoms/Code'
2
+ import PropTypes from 'prop-types'
3
+
4
+ /**
5
+ * Code Block
6
+ *
7
+ * The core Code block from Gutenberg.
8
+ *
9
+ * @author WebDevStudios
10
+ * @param {string } className Optional classnames.
11
+ * @param {string } anchor Optional anchor/id.
12
+ * @param {string } content The content of the block.
13
+ * @return {Element } The Code component.
14
+ */
15
+ export default function BlockCode ( { anchor, className, content} ) {
16
+ return < Code className = { className } id = { anchor } content = { content } />
17
+ }
18
+
19
+ BlockCode . propTypes = {
20
+ anchor : PropTypes . string ,
21
+ content : PropTypes . string ,
22
+ className : PropTypes . string
23
+ }
Original file line number Diff line number Diff line change
1
+ export { default } from './BlockCode'
Original file line number Diff line number Diff line change 1
1
// Create default exports for each Block.
2
2
export { default as BlockAccordions } from './BlockAccordions'
3
3
export { default as BlockQuote } from './BlockQuote'
4
- export { default as PullQuote } from './BlockPullQuote'
4
+ export { default as BlockPullQuote } from './BlockPullQuote'
5
5
export { default as BlockImage } from './BlockImage'
6
6
export { default as BlockImageGallery } from './BlockImageGallery'
7
7
export { default as BlockList } from './BlockList'
@@ -13,3 +13,4 @@ export {default as BlockShortcode} from './BlockShortcode'
13
13
export { default as BlockSpacer } from './BlockSpacer'
14
14
export { default as BlockVideoEmbed } from './BlockVideoEmbed'
15
15
export { default as BlockTable } from './BlockTable'
16
+ export { default as BlockCode } from './BlockCode'
You can’t perform that action at this time.
0 commit comments