forked from storybookjs/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
70 lines (59 loc) 路 1.51 KB
/
code.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
import React from 'react';
export class Code extends React.Component {
componentDidMount() {
this.highlight();
}
componentDidUpdate() {
this.highlight();
}
highlight() {
if (typeof Prism !== 'undefined') {
Prism.highlightAll();
}
}
render() {
const codeStyle = {
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
};
const preStyle = {
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
padding: '.5rem',
lineHeight: 1.5,
overflowX: 'scroll',
};
const className = this.props.language ? `language-${this.props.language}` : '';
return (
<pre style={preStyle} className={className}>
<code style={codeStyle} className={className}>
{this.props.code}
</code>
</pre>
);
}
}
export class Pre extends React.Component {
render() {
const style = {
fontSize: '.88em',
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
backgroundColor: '#fafafa',
padding: '.5rem',
lineHeight: 1.5,
overflowX: 'scroll',
};
return <pre style={style}>{this.props.children}</pre>;
}
}
export class Blockquote extends React.Component {
render() {
const style = {
fontSize: '1.88em',
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
borderLeft: '8px solid #fafafa',
padding: '1rem',
};
return <blockquote style={style}>{this.props.children}</blockquote>;
}
}