summaryrefslogtreecommitdiffstats
path: root/examples/examples.js
blob: c79bf1179bc6f9757248d0b8ace11276907270e1 (plain)
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
import React from 'react';
import ReactDOM from 'react-dom';
import TextareaAutosize from '../src/TextareaAutosize';

class Example extends React.Component {

  textareaStyle = {
    width: 300,
    padding: '10px 8px',
    border: '1px solid rgba(39, 41, 43, .15)',
    borderRadius: 4,
    fontSize: 15
  }

  onResize = (event) => {
    console.log(event); // eslint-disable-line no-console
  }

  render() {
    return (
      <div style={{ fontFamily: 'sans-serif', margin: 15 }}>
        <h2>{'Plain "<TextareaAutosize />"'}</h2>
        <TextareaAutosize
          style={this.textareaStyle}
          placeholder='try writing some lines'
          onResize={this.onResize}
        />

        <h2>Minimum height is 3 "rows"</h2>
        <TextareaAutosize
          rows={3}
          style={this.textareaStyle}
          placeholder='minimun height is 3 rows'
        />

        <h2>Maximum height is 3 "rows"</h2>
        <TextareaAutosize
          maxRows={3}
          style={this.textareaStyle}
          placeholder='maximum height is 5 rows'
          defaultValue={'this\nis\na\nlong\ninitial\ntext'}
        />

        <h2>Prefilled with initial value</h2>
        <TextareaAutosize
          style={this.textareaStyle}
          defaultValue={'this\nis\na\nlong\ninitial\ntext'}
        />

        <h2>{'You can compare with this normal react "<textarea />""'}</h2>
        <textarea
          style={this.textareaStyle}
          defaultValue={'this\nis\na\nlong\ninitial\ntext'}
        />
      </div>
    );
  }

}

ReactDOM.render(<Example />, document.getElementById('container'));