|
| 1 | +# react-draggable-playground |
| 2 | + |
| 3 | +> Reusable React-draggable components with render props. |
| 4 | +
|
| 5 | +[![Travis][build-badge]][build] |
| 6 | +[![Codecov Status][codecov-badge]][codecov] |
| 7 | +[![npm package][npm-badge]][npm] |
| 8 | +[![npm downloads][npm-downloads]][npm] |
| 9 | + |
| 10 | +[![Dependency Status][dependency-badge]][dependency] |
| 11 | +[![devDependency Status][devdependency-badge]][devdependency] |
| 12 | +[![peerDependency Status][peerdependency-badge]][peerdependency] |
| 13 | + |
| 14 | +[![prettier][prettier-badge]][prettier] |
| 15 | +[![license][license-badge]][license] |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +```sh |
| 20 | +$ yarn add react-draggable-playground |
| 21 | +``` |
| 22 | + |
| 23 | +## Demo |
| 24 | + |
| 25 | +* https://react-draggable-playground.netlify.com/ |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```js |
| 30 | +import { DraggableParent, DraggableItem } from 'react-draggable-playground'; |
| 31 | + |
| 32 | +<DraggableParent height={300} width={300}> |
| 33 | + <DraggableItem |
| 34 | + defaultPosition={{ x: 100, y: 100 }} |
| 35 | + onPositionChange={(position: Position) => {}} |
| 36 | + > |
| 37 | + {({ isDragging }) => <div>item</div>} |
| 38 | + </DraggableItem> |
| 39 | +</DraggableParent>; |
| 40 | +``` |
| 41 | + |
| 42 | +## API |
| 43 | + |
| 44 | +```js |
| 45 | +type Position = { |
| 46 | + x: number, |
| 47 | + y: number, |
| 48 | +}; |
| 49 | + |
| 50 | +// DraggableItem |
| 51 | +type Props = { |
| 52 | + children: ({ isDragging: boolean, disabled: boolean }) => React.Node, |
| 53 | + disabled: boolean, |
| 54 | + onPositionChange?: Position => Promise<void> | void, |
| 55 | + defaultPosition?: Position, |
| 56 | +}; |
| 57 | + |
| 58 | +// DraggableParent |
| 59 | +type Props = { |
| 60 | + height: number, |
| 61 | + width: number, |
| 62 | + children?: React.Node, |
| 63 | + style?: Object, |
| 64 | +}; |
| 65 | +``` |
| 66 | + |
| 67 | +## Development |
| 68 | + |
| 69 | +### Requirements |
| 70 | + |
| 71 | +* node >= 9.8.0 |
| 72 | +* yarn >= 1.5.1 |
| 73 | + |
| 74 | +```sh |
| 75 | +$ yarn install --pure-lockfile |
| 76 | +$ yarn start |
| 77 | +``` |
| 78 | + |
| 79 | +## Test |
| 80 | + |
| 81 | +```sh |
| 82 | +$ yarn run format |
| 83 | +$ yarn run eslint |
| 84 | +$ yarn run flow |
| 85 | +$ yarn run test:watch |
| 86 | +$ yarn run build |
| 87 | +``` |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## CONTRIBUTING |
| 92 | + |
| 93 | +* ⇄ Pull requests and ★ Stars are always welcome. |
| 94 | +* For bugs and feature requests, please create an issue. |
| 95 | +* Pull requests must be accompanied by passing automated tests. |
| 96 | + |
| 97 | +## [CHANGELOG](CHANGELOG.md) |
| 98 | + |
| 99 | +## [LICENSE](LICENSE) |
| 100 | + |
| 101 | +MIT: [http://michaelhsu.mit-license.org](http://michaelhsu.mit-license.org) |
| 102 | + |
| 103 | +[build-badge]: https://img.shields.io/travis/evenchange4/react-draggable-playground/master.svg?style=flat-square |
| 104 | +[build]: https://travis-ci.org/evenchange4/react-draggable-playground |
| 105 | +[npm-badge]: https://img.shields.io/npm/v/react-draggable-playground.svg?style=flat-square |
| 106 | +[npm]: https://www.npmjs.org/package/react-draggable-playground |
| 107 | +[codecov-badge]: https://img.shields.io/codecov/c/github/evenchange4/react-draggable-playground.svg?style=flat-square |
| 108 | +[codecov]: https://codecov.io/github/evenchange4/react-draggable-playground?branch=master |
| 109 | +[npm-downloads]: https://img.shields.io/npm/dt/react-draggable-playground.svg?style=flat-square |
| 110 | +[license-badge]: https://img.shields.io/npm/l/react-draggable-playground.svg?style=flat-square |
| 111 | +[license]: http://michaelhsu.mit-license.org/ |
| 112 | +[dependency-badge]: https://david-dm.org/evenchange4/react-draggable-playground.svg?style=flat-square |
| 113 | +[dependency]: https://david-dm.org/evenchange4/react-draggable-playground |
| 114 | +[devdependency-badge]: https://david-dm.org/evenchange4/react-draggable-playground/dev-status.svg?style=flat-square |
| 115 | +[devdependency]: https://david-dm.org/evenchange4/react-draggable-playground#info=devDependencies |
| 116 | +[peerdependency-badge]: https://david-dm.org/evenchange4/react-draggable-playground/peer-status.svg?style=flat-square |
| 117 | +[peerdependency]: https://david-dm.org/evenchange4/react-draggable-playground#info=peerDependencies |
| 118 | +[prettier-badge]: https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square |
| 119 | +[prettier]: https://github.com/prettier/prettier |
0 commit comments