mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-18 09:05:55 +00:00
react/drag-drop: add a type test and document shared props (#2003)
* Update react-dragdrop.md
DragDrop component only accept `uppy` and `locale` props according to the type declared.
```
import { Uppy, Locale } from './CommonTypes';
export interface DragDropProps {
uppy: Uppy;
locale?: Locale;
}
/**
* React component that renders an area in which files can be dropped to be
* uploaded.
*/
declare const DragDrop: React.ComponentType<DragDropProps>;
export default DragDrop;```
* drag-drop: accept a number for width/height
* docs: add back dragdrop props
* docs: use the same option style as previously [skip ci]
Co-authored-by: Renée Kooi <renee@kooi.me>
This commit is contained in:
parent
926cf8ee6d
commit
59bfaf0d20
3 changed files with 34 additions and 2 deletions
4
packages/@uppy/drag-drop/types/index.d.ts
vendored
4
packages/@uppy/drag-drop/types/index.d.ts
vendored
|
|
@ -7,8 +7,8 @@ declare module DragDrop {
|
|||
target?: Uppy.PluginTarget
|
||||
inputName?: string
|
||||
allowMultipleFiles?: boolean
|
||||
width?: string
|
||||
height?: string
|
||||
width?: string | number
|
||||
height?: string | number
|
||||
note?: string
|
||||
locale?: DragDropLocale
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,23 @@ function TestComponent() {
|
|||
// inline option should be removed from proptypes because it is always overridden
|
||||
// by the component
|
||||
expectError(<components.Dashboard inline />)
|
||||
|
||||
{
|
||||
const el = (
|
||||
<components.DragDrop
|
||||
width={200}
|
||||
height={200}
|
||||
note="Images up to 200×200px"
|
||||
uppy={uppy}
|
||||
locale={{
|
||||
strings: {
|
||||
// Text to show on the droppable area.
|
||||
// `%{browse}` is replaced with a link that opens the system file selection dialog.
|
||||
dropHereOr: "Drop here or %{browse}",
|
||||
// Used as the label for the link that opens the system file selection dialog.
|
||||
browse: "browse"
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,21 @@ class MyComponent extends React.Component {
|
|||
The `<DragDrop />` component supports all [DragDrop](/docs/drag-drop/) options as props.
|
||||
|
||||
```js
|
||||
// assuming `this.uppy` contains an Uppy instance:
|
||||
|
||||
<DragDrop
|
||||
width="100%"
|
||||
height="100%"
|
||||
note="Images up to 200×200px"
|
||||
uppy={this.uppy}
|
||||
locale={{
|
||||
strings: {
|
||||
// Text to show on the droppable area.
|
||||
// `%{browse}` is replaced with a link that opens the system file selection dialog.
|
||||
dropHereOr: "Drop here or %{browse}",
|
||||
// Used as the label for the link that opens the system file selection dialog.
|
||||
browse: "browse",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue