forked from agilgur5/react-signature-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (37 loc) · 1.07 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
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import SignaturePad from '../src/index.js'
import styles from './styles.cssm'
class App extends Component {
state = { trimmedDataURL: null }
sigPad = {}
clear = () => {
this.sigPad.clear()
}
trim = () => {
this.setState({ trimmedDataURL: this.sigPad.getTrimmedCanvas()
.toDataURL('image/png') })
}
render () {
const { trimmedDataURL } = this.state
return <div className={styles.container}>
<div className={styles.sigContainer}>
<SignaturePad canvasProps={{ className: styles.sigPad }}
ref={(ref) => { this.sigPad = ref }} />
</div>
<div>
<button className={styles.buttons} onClick={this.clear}>
Clear
</button>
<button className={styles.buttons} onClick={this.trim}>
Trim
</button>
</div>
{trimmedDataURL
? <img className={styles.sigImage}
src={trimmedDataURL} />
: null}
</div>
}
}
ReactDOM.render(<App />, document.getElementById('container'))