App.jsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* eslint-disable react/react-in-jsx-scope */
  2. import Uppy from '@uppy/core'
  3. /* eslint-disable-next-line no-unused-vars */
  4. import React, { useState } from 'react'
  5. import { Dashboard, DashboardModal, DragDrop } from '@uppy/react'
  6. import ThumbnailGenerator from '@uppy/thumbnail-generator'
  7. import RemoteSources from '@uppy/remote-sources'
  8. import '@uppy/core/dist/style.css'
  9. import '@uppy/dashboard/dist/style.css'
  10. import '@uppy/drag-drop/dist/style.css'
  11. const uppyDashboard = new Uppy({ id: 'dashboard' }).use(RemoteSources, {
  12. companionUrl: 'http://companion.uppy.io',
  13. sources: ['GoogleDrive', 'OneDrive', 'Unsplash', 'Zoom', 'Url'],
  14. })
  15. const uppyModal = new Uppy({ id: 'modal' })
  16. const uppyDragDrop = new Uppy({ id: 'drag-drop' }).use(ThumbnailGenerator)
  17. export default function App() {
  18. const [open, setOpen] = useState(false)
  19. // TODO: Parcel is having a bad time resolving React inside @uppy/react for some reason.
  20. // We are using Parcel in an odd way and I don't think there is an easy fix.
  21. // const files = useUppyState(uppyDashboard, (state) => state.files)
  22. // drag-drop has no visual output so we test it via the uppy instance
  23. window.uppy = uppyDragDrop
  24. return (
  25. <div
  26. style={{
  27. maxWidth: '30em',
  28. margin: '5em 0',
  29. display: 'grid',
  30. gridGap: '2em',
  31. }}
  32. >
  33. <button type="button" id="open" onClick={() => setOpen(!open)}>
  34. Open Modal
  35. </button>
  36. {/* <p>Dashboard file count: {Object.keys(files).length}</p> */}
  37. <Dashboard id="dashboard" uppy={uppyDashboard} />
  38. <DashboardModal id="modal" open={open} uppy={uppyModal} />
  39. <DragDrop id="drag-drop" uppy={uppyDragDrop} />
  40. </div>
  41. )
  42. }