-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReactComponent.jsx
80 lines (76 loc) · 1.72 KB
/
ReactComponent.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from 'react'
import PropTypes from 'prop-types'
import Pathline from 'rsg-components/Pathline'
import Styled from 'rsg-components/Styled'
const styles = ({ color, fontSize, space }) => ({
root: {
marginBottom: space[6],
},
header: {
marginBottom: space[3],
},
tabs: {
marginBottom: space[3],
},
tabButtons: {
marginBottom: space[1],
},
tabBody: {
overflowX: 'auto',
maxWidth: '100%',
WebkitOverflowScrolling: 'touch',
},
docs: {
color: color.base,
fontSize: fontSize.text,
},
})
export function ReactComponentRenderer({
classes,
name,
heading,
pathLine,
description,
docs,
examples,
tabButtons,
tabBody,
}) {
return (
<div className={classes.root} id={name + '-container'}>
<header className={classes.header}>
{heading}
{pathLine && <Pathline>{pathLine}</Pathline>}
</header>
{(description || docs) && (
<div className={classes.docs}>
{description}
{docs}
</div>
)}
<h3>Usage</h3>
{examples}
<h3>API</h3>
{tabButtons && (
<div className={classes.tabs}>
<div className={classes.tabButtons}>{tabButtons}</div>
<div className={classes.tabBody}>{tabBody}</div>
</div>
)}
</div>
)
}
ReactComponentRenderer.propTypes = {
classes: PropTypes.object.isRequired,
name: PropTypes.string.isRequired,
heading: PropTypes.node.isRequired,
filepath: PropTypes.string,
pathLine: PropTypes.string,
tabButtons: PropTypes.node,
tabBody: PropTypes.node,
description: PropTypes.node,
docs: PropTypes.node,
examples: PropTypes.node,
isolated: PropTypes.bool,
}
export default Styled(styles)(ReactComponentRenderer)