App.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* eslint-disable */
  2. const React = require('react')
  3. const Uppy = require('uppy/lib/core')
  4. const Tus10 = require('uppy/lib/plugins/Tus10')
  5. const { Dashboard, DashboardModal, DragDrop, ProgressBar } = require('uppy/lib/uppy-react')
  6. module.exports = class App extends React.Component {
  7. constructor (props) {
  8. super(props)
  9. this.state = {
  10. showInlineDashboard: false,
  11. open: false
  12. }
  13. this.handleModalClick = this.handleModalClick.bind(this)
  14. }
  15. componentWillMount () {
  16. this.uppy = new Uppy({ autoProceed: false })
  17. .use(Tus10, { endpoint: 'https://master.tus.io/files' })
  18. .run()
  19. }
  20. componentWillUnmount () {
  21. this.uppy.close()
  22. }
  23. handleModalClick () {
  24. this.setState({
  25. open: !this.state.open
  26. })
  27. }
  28. render () {
  29. const { showInlineDashboard } = this.state
  30. return (
  31. <div>
  32. <h1>React Examples</h1>
  33. <h2>Inline Dashboard</h2>
  34. <label>
  35. <input
  36. type="checkbox"
  37. checked={showInlineDashboard}
  38. onChange={(event) => {
  39. this.setState({
  40. showInlineDashboard: event.target.checked
  41. })
  42. }}
  43. />
  44. Show Dashboard
  45. </label>
  46. {showInlineDashboard && (
  47. <Dashboard uppy={this.uppy} />
  48. )}
  49. <h2>Modal Dashboard</h2>
  50. <div>
  51. <button onClick={this.handleModalClick}>
  52. {this.state.open ? 'Close dashboard' : 'Open dashboard'}
  53. </button>
  54. <DashboardModal
  55. uppy={this.uppy}
  56. open={this.state.open}
  57. onRequestClose={() => this.setState({ open: false })}
  58. />
  59. </div>
  60. <h2>Drag Drop Area</h2>
  61. <DragDrop
  62. uppy={this.uppy}
  63. locale={{
  64. strings: {
  65. chooseFile: 'Boop a file',
  66. orDragDrop: 'or yoink it here'
  67. }
  68. }}
  69. />
  70. <h2>Progress Bar</h2>
  71. <ProgressBar uppy={this.uppy} />
  72. </div>
  73. )
  74. }
  75. }