-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathApp.js
71 lines (64 loc) · 2.09 KB
/
App.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
import React from 'react';
import Editor from '../../src'
import { themes } from '../../src/utils/themes'
import { languages } from '../../src/utils/languages'
class App extends React.Component {
constructor(props) {
super(props)
const { lineNumber, readOnly, code, theme, language, showLanguage, clipboard } = this.props
this.state = {
language,
theme,
lineNumber,
readOnly,
showLanguage,
clipboard,
code
}
}
render() {
const { lineNumber, readOnly, code, theme, language, showLanguage, clipboard } = this.state
return <div style={{ padding: 20 }}>
<div style={{ marginBottom: 10 }}>
<span style={{ marginRight: 10 }} onClick={e => this.setState({ lineNumber: !lineNumber })} >
Line Numbers
<input type="checkbox" name="ln" checked={lineNumber} onChange={() => { }} />
</span>
<span style={{ marginRight: 10 }} onClick={e => this.setState({ readOnly: !readOnly })}>
Readonly
<input type="checkbox" name="ln" checked={readOnly} onChange={() => { }} />
</span>
<span style={{ marginRight: 10 }}>
Theme
<select style={{ marginLeft: 5 }} value={theme} onChange={e => this.setState({ theme: e.target.value })}>
{themes.map(({ title }, i) =>
<option key={i} value={title}>{title}</option>
)}
</select>
</span>
<span>
Language
<select style={{ marginLeft: 5 }} value={language} onChange={e => this.setState({ language: e.target.value })}>
{languages.map(({ title, value }, i) =>
<option key={i} value={value}>{title}</option>
)}
</select>
</span>
</div>
<Editor
language={language}
theme={theme}
code={code}
lineNumber={lineNumber}
readOnly={readOnly}
clipboard={clipboard}
showLanguage={showLanguage}
changeCode={code => {
this.code = code
console.log(code)
}}
/>
</div >
}
}
export default App;