Commit graph

28 commits

Author SHA1 Message Date
Renée Kooi
d330c26813
react: Different way to do React components
This is a different approach to React components suggested by @arturi.
Instead of the components adding and removing plugins when mounting and
unmounting, plugins are configured at the start, and the components act
as slots for the plugins to actually mount in. Because all plugins are
still being configured up front here, we don't have to change how the
provider `target:` options work, they can install themselves into eg.
the Dashboard plugin immediately.

The core of this approach is the `UppyWrapper` component, which takes an
Uppy instance and a plugin ID, and mounts the plugin inside itself. The
other components only provide a default plugin ID.

The one change required in Uppy itself for this to work is to the
`mount()` functions: now, `mount()` configures `this.target` on the
plugins. If plugins do not have a `target:` option, they do not mount on
install. Some DOM code also had to be moved into the `mount()` function
for the DragDrop component instead of staying in `install()`, but I
think it makes sense.

(Still have to work out how to make the `DashboardModal` component's
`onRequestClose` option work.)
2017-09-18 14:40:32 +02:00
Artur Paikin
4e808ca3d2 add aria-hidden to all icons for accessibility, remove console.log 2017-09-14 12:01:19 -04:00
Artur Paikin
c9077582b8 merge Some refactoring: emitter, informer 2017-07-24 18:25:57 +02:00
Artur Paikin
cf6e75522b cleanup, getMetaFromForm: true by default 2017-06-30 12:05:57 -04:00
Artur Paikin
047e51b77b add get-form-data, move things around 2017-06-29 19:06:04 -04:00
Artur Paikin
6f80ea709c Extract metadata from form, closes #153
This PR adds support for extracting metadata from `<form>` elements.
This was asked #153 and came up elsewhere too, I believe. You can use
it like this:

```html
<form class="MyForm" action="/">
  <input type="file" />
  <input type="hidden" name="bla" value="12333">
  <input type="text" name="yo" value="1">
  <button type="submit">Upload</button>
</form>
```

```js
uppy.use(DragDrop, {
    target: '.MyForm',
    locale: {
      strings: {chooseFile: 'Выберите файл'}
    },
    setMetaFromTargetForm: true
  })
```

Then UI acquire type plugins, like Dashboard, FileInput and DragDrop,
before mounting themselves or doing anything else, extract FormData
from the `target` `<form>` element (it must be a form currently), and
merge the object with the global `state.meta`. This is done via
`setMeta` method on core. Then, when a file is added, `state.meta` is
merged to that file’s meta right away. The ability to add more fields
via UI plugin MetaData is also still there, though probably needs an
update.

In addition a new `meta` option is added in core:

```js
const uppy = Uppy({
  debug: true,
  autoProceed: true,
  meta: {
    username: 'Artur'
  }
})
```

This way some data can be set right away, it becomes the initial
`state.meta` object.
2017-06-28 20:21:23 -04:00
Artur Paikin
b25b64c6a8 dnd cleanup 2017-06-16 19:52:31 -04:00
Renée Kooi
a5dc7d8a0e
Revert "space"
This reverts commit f74151659b.
2017-05-17 15:38:59 +02:00
Artur Paikin
f74151659b space 2017-05-13 00:17:23 -04:00
Artur Paikin
0b2ceabc44 Revert "fix that space"
This reverts commit f468cbb869.
2017-05-12 23:18:46 -04:00
Artur Paikin
fda551d26e Merge pull request #182 from goto-bus-stop/feature/dispose
Add `Uppy#close` for tearing down an Uppy instance.
2017-05-12 18:21:54 -04:00
Artur Paikin
f468cbb869 fix that space 2017-05-12 15:21:20 -04:00
Renée Kooi
dd01841232
Remove the last few potentially buggy uses of document.querySelector 2017-05-04 16:25:20 +02:00
René Kooi
b3c62b686a
Add uninstall method, to Dashboard, DragDrop plugins. 2017-05-02 10:14:17 +02:00
René Kooi
1173ae7e0b
Use direct <input/> references to trigger file selection in Dashboard.
Every element that was opening a file selection dialog by simulating a
`.UppyDashboard-input` click, was also already rendering one of those
input elements. This patch first creates the `input` elements, and
saves them so their variables can be used to simulate a click event
directly.

This way the `container` prop no longer has to be passed down through
every layer, and we can turn the `.target` property in plugins into
a DOM element because it isn't used in `querySelector` anymore.
2017-03-09 20:29:57 +01:00
Artur Paikin
31b751aedb remove debug console.log 2017-01-09 17:28:06 -05:00
Artur Paikin
f9094129a1 Merge branch 'master' into yoyoify 2016-12-20 19:59:52 -05:00
Artur Paikin
4061d717d0 fix i18n 2016-12-20 19:37:28 -05:00
Artur Paikin
92b1df54b5 Merge branch 'master' into yoyoify 2016-12-20 18:27:23 -05:00
Artur Paikin
db647f7c14 convert everything to const/require and module.exports 🙀 2016-12-19 23:23:33 -05:00
Artur Paikin
7975bbf3fc refactor DragDrop, add selectedFiles counter, remove upload button 2016-12-19 15:53:23 -05:00
Artur Paikin
fe3783c553 ES6 modules (import) to CJS (require), so that yo-yoify will work 2016-12-18 14:10:04 -05:00
Artur Paikin
78e2ede443 don’t use onload for now
https://github.com/shama/bel/issues/44 :(
2016-12-15 20:54:54 -05:00
Artur Paikin
8fdca40cb8 try out i18n for each plugin instead of in core 2016-12-13 00:21:37 -05:00
Artur Paikin
f20064b9ed fix DragDrop, remove props 2016-11-25 17:55:53 -06:00
Artur Paikin
7296d49a6c dragdrop styles cleanup 2016-11-08 09:50:56 -05:00
Artur Paikin
daba330da7 add core: prefix to events 2016-09-20 02:27:06 -04:00
Artur Paikin
7408155b6b more import refactors 2016-09-06 10:07:58 -04:00