-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathCodeExample.js
77 lines (66 loc) · 1.69 KB
/
CodeExample.js
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
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {colors, media} from 'theme';
import CodeEditor from '../CodeEditor/CodeEditor';
class CodeExample extends Component {
render() {
const {children, code, id, containerNodeID, loaded} = this.props;
return (
<div
id={id}
css={{
marginTop: 40,
'&:first-child': {
marginTop: 0,
},
'& .react-live': {
width: '100%',
},
[media.greaterThan('xlarge')]: {
display: 'flex',
flexDirection: 'row',
marginTop: 80,
},
[media.lessThan('large')]: {
display: 'block',
},
}}>
{children && (
<div
css={{
flex: '0 0 33%',
[media.lessThan('xlarge')]: {
marginBottom: 20,
},
'& h3': {
color: colors.dark,
maxWidth: '11em',
paddingTop: 0,
},
'& p': {
marginTop: 15,
marginRight: 40,
lineHeight: 1.7,
[media.greaterThan('xlarge')]: {
marginTop: 25,
},
},
}}>
{children}
</div>
)}
{loaded ? (
<CodeEditor code={code} containerNodeID={containerNodeID} />
) : (
<h4>Loading code example...</h4>
)}
</div>
);
}
}
CodeExample.propTypes = {
children: PropTypes.node,
code: PropTypes.string.isRequired,
loaded: PropTypes.bool.isRequired,
};
export default CodeExample;