|
1 | 1 | import React from 'react'; |
2 | | -import { Scrollbars } from 'react-custom-scrollbars'; |
3 | 2 | import { Controlled as CodeMirror } from 'react-codemirror2'; |
4 | 3 |
|
5 | 4 | import 'codemirror/lib/codemirror.css'; |
6 | 5 |
|
7 | 6 | import Title from './common/Title'; |
8 | 7 | import Input from './common/Input'; |
| 8 | +import Syntaxes from './Syntaxes'; |
9 | 9 |
|
10 | 10 | import '../styles/NewSnippet.styl'; |
11 | 11 |
|
12 | | -const NewSnippet = () => ( |
13 | | - [ |
14 | | - <Title title="New snippet" key="title" />, |
15 | | - <div className="new-snippet" key="new-snippet"> |
16 | | - <div className="new-snippet-code-wrapper"> |
17 | | - <div className="new-snippet-code-header"> |
18 | | - <Input placeholder="Title" /> |
19 | | - <Input placeholder="Tags (separate tags by comma)" /> |
20 | | - </div> |
21 | | - <div className="new-snippet-code"> |
22 | | - <CodeMirror |
23 | | - value="console.log('All hail XSnippet')" |
24 | | - options={{ lineNumbers: false }} |
25 | | - /> |
26 | | - <div className="new-snippet-code-bottom-bar"> |
27 | | - <button>POST</button> |
| 12 | +class NewSnippet extends React.Component { |
| 13 | + constructor() { |
| 14 | + super(); |
| 15 | + this.state = { code: '' }; |
| 16 | + } |
| 17 | + render() { |
| 18 | + return ( |
| 19 | + [ |
| 20 | + <Title title="New snippet" key="New Snippet Title" />, |
| 21 | + <div className="new-snippet" key="New Snippet"> |
| 22 | + <div className="new-snippet-code-wrapper"> |
| 23 | + <div className="new-snippet-code-header"> |
| 24 | + <Input placeholder="Title" /> |
| 25 | + <Input placeholder="Tags (separate tags by comma)" /> |
| 26 | + </div> |
| 27 | + <div className="new-snippet-code"> |
| 28 | + <CodeMirror |
| 29 | + value={this.state.code} |
| 30 | + options={{ lineNumbers: false }} |
| 31 | + onBeforeChange={(editor, data, code) => { |
| 32 | + this.setState({ code }); |
| 33 | + }} |
| 34 | + /> |
| 35 | + <div className="new-snippet-code-bottom-bar"> |
| 36 | + <button>POST</button> |
| 37 | + </div> |
| 38 | + </div> |
28 | 39 | </div> |
29 | | - </div> |
30 | | - </div> |
31 | | - <div className="new-snippet-lang-wrapper"> |
32 | | - <div className="new-snippet-lang-header"> |
33 | | - <Input placeholder="Type to search..." /> |
34 | | - </div> |
35 | | - <div className="new-snippet-lang-list-wrapper"> |
36 | | - <Scrollbars> |
37 | | - <ul className="new-snippet-lang-list"> |
38 | | - <li className="new-snippet-lang-item">Text1</li> |
39 | | - <li className="new-snippet-lang-item">Text2</li> |
40 | | - <li className="new-snippet-lang-item">Text3</li> |
41 | | - <li className="new-snippet-lang-item">Text4</li> |
42 | | - <li className="new-snippet-lang-item">Text5</li> |
43 | | - <li className="new-snippet-lang-item">Text6</li> |
44 | | - <li className="new-snippet-lang-item">Text7</li> |
45 | | - <li className="new-snippet-lang-item">Text8</li> |
46 | | - <li className="new-snippet-lang-item">Text9</li> |
47 | | - <li className="new-snippet-lang-item">Text10</li> |
48 | | - <li className="new-snippet-lang-item">Text11</li> |
49 | | - <li className="new-snippet-lang-item">Text12</li> |
50 | | - <li className="new-snippet-lang-item">Text13</li> |
51 | | - <li className="new-snippet-lang-item">Text14</li> |
52 | | - </ul> |
53 | | - </Scrollbars> |
54 | | - </div> |
55 | | - </div> |
56 | | - </div>, |
57 | | - ] |
58 | | -); |
| 40 | + <div className="new-snippet-lang-wrapper"> |
| 41 | + <Syntaxes /> |
| 42 | + </div> |
| 43 | + </div>, |
| 44 | + ] |
| 45 | + ); |
| 46 | + } |
| 47 | +} |
59 | 48 |
|
60 | 49 | export default NewSnippet; |
0 commit comments