blob: f026ef98acc7dc0882f718d214bd972d1af45d6f (
plain) (
blame)
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
|
import React from 'react';
import { TitleInput, PasteInput } from './Inputs'
class PasteArea extends React.Component {
constructor(props) {
super(props);
this.state = {
title: '',
content: '',
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidUpdate() {
if (this.state.title === "") {
document.title = `ctrl-v`;
} else {
document.title = `ctrl-v | ${this.state.title}`;
}
}
handleChange(event) {
const target = event.target;
const name = target.name;
this.setState({
[name]: target.value
});
}
handleSubmit(event) {
console.log(`title: ${this.state.title}`)
console.log(`content: ${this.state.content}`)
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<TitleInput
onChange={this.handleChange}
value={this.state.title}
maxLength="100" />
<PasteInput
onChange={this.handleChange}
content={this.state.content}
maxLength="100000" />
<br />
<input className="lt-button lt-shadow lt-hover" type="submit" value="new paste" />
</form>
);
}
}
export default PasteArea
|