-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port @uppy/drop-target
docs
#59
Changes from all commits
550bc6f
8d18343
6f8d23d
88bae48
bdbe5ce
36f4c80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,112 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
import UppyCdnExample from '/src/components/UppyCdnExample'; | ||
|
||
# Drop target | ||
|
||
The `@uppy/drop-target` plugin lets your users drag-and-drop files on any | ||
element on the page, for example the whole page, `document.body`. | ||
|
||
Can be used together with Uppy Dashboard or Drag & Drop plugins, or your custom | ||
solution targeting any DOM element. | ||
|
||
:::tip | ||
|
||
[Try out the live example](/examples) or take it for a spin in | ||
[CodeSandbox](https://codesandbox.io/s/uppy-drag-drop-gyewzx?file=/src/index.js). | ||
|
||
::: | ||
|
||
## When should I use this? | ||
|
||
When you want to allow users to drag and drop files in your own UI, rather than | ||
in the [`Dashboard`](../dashboard) UI, or catch dropped files from anywhere on | ||
the page. | ||
|
||
## Install | ||
|
||
<Tabs> | ||
<TabItem value="npm" label="NPM" default> | ||
|
||
```shell | ||
npm install @uppy/drop-target | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="yarn" label="Yarn"> | ||
|
||
```shell | ||
yarn add @uppy/drop-target | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="cdn" label="CDN"> | ||
<UppyCdnExample> | ||
{` | ||
import { DropTarget } from "{{UPPY_JS_URL}}" | ||
const DropTarget = new Uppy().use(DropTarget) | ||
`} | ||
</UppyCdnExample> | ||
</TabItem> | ||
</Tabs> | ||
|
||
## Use | ||
|
||
This module has one default export: the `DropTarget` plugin class. | ||
|
||
```js {8-10} showLineNumbers | ||
import Uppy from '@uppy/core'; | ||
import DropTarget from '@uppy/drop-target'; | ||
|
||
import '@uppy/core/dist/style.css'; | ||
import '@uppy/drop-target/dist/style.css'; | ||
|
||
const uppy = new Uppy(); | ||
uppy.use(DropTarget, { | ||
target: document.body, | ||
}); | ||
``` | ||
|
||
## API | ||
|
||
### Options | ||
|
||
#### `onDragLeave` | ||
|
||
Event listener for the [`dragleave` event][]. | ||
|
||
```js {3-5} showLineNumbers | ||
uppy.use(DropTarget, { | ||
target: document.body, | ||
onDragLeave: (event) => { | ||
event.stopPropagation(); | ||
}, | ||
}); | ||
``` | ||
|
||
#### `onDragOver` | ||
|
||
Event listener for the [`dragover` event][]. | ||
|
||
#### `onDrop` | ||
|
||
Event listener for the [`drop` event][]. | ||
|
||
#### `target` | ||
|
||
DOM element, CSS selector, or plugin to place the drag and drop area into | ||
(`string`, `Element`, `Function`, or `UIPlugin`, default: `null`). | ||
Comment on lines
+102
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we always put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we list the option in alphabetical order instead? That seems easier to enforce. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit all over the place currently. I can make sorting part of #45 (automate it with remark). So indeed doesn't matter that much for now |
||
|
||
[`dragover` event]: | ||
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragover_event | ||
[`dragleave` event]: | ||
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragleave_event | ||
[`drop` event]: | ||
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drop_event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/examples doesn't exit. We should also create a codesandbox for this plugin and link it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We plan to have something at
/examples
don't we?uppy.io/docusaurus.config.js
Line 58 in 0f9e149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No as discussed we will go live without it and potentially never have it as we emphasize our existing examples repo and codesandboxes. So at least for now we need to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what's needed for this. We should probably document some guidelines around it.
There are 12 other pages linking to
/examples
, plus the main nav menu cited above. I don't think it makes sense to remove it from this PR. If we plan to remove them before going live, it can be done in a follow-up PR and doesn't have to block this one.