2018-04-26 01:58:53 +03:00
|
|
|
# <task-lists> element
|
|
|
|
|
|
|
|
Drag and drop task list items.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```
|
|
|
|
$ npm install --save @github/task-lists-element
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2020-05-22 00:10:17 +03:00
|
|
|
### Script
|
|
|
|
|
2020-06-04 20:07:15 +03:00
|
|
|
Import as a module:
|
2020-05-22 00:10:17 +03:00
|
|
|
|
2018-04-26 01:58:53 +03:00
|
|
|
```js
|
|
|
|
import '@github/task-lists-element'
|
|
|
|
```
|
|
|
|
|
2020-05-22 00:10:17 +03:00
|
|
|
With a script tag:
|
|
|
|
|
|
|
|
```html
|
2021-04-30 17:27:28 +03:00
|
|
|
<script type="module" src="./node_modules/@github/task-lists-element/dist/task-lists-element.js">
|
2020-05-22 00:10:17 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### Markup
|
|
|
|
|
2018-04-26 01:58:53 +03:00
|
|
|
```html
|
|
|
|
<task-lists sortable>
|
|
|
|
<ul class="contains-task-list">
|
|
|
|
<li class="task-list-item">
|
|
|
|
<input type="checkbox" class="task-list-item-checkbox">
|
|
|
|
Hubot
|
|
|
|
</li>
|
|
|
|
<li class="task-list-item">
|
|
|
|
<input type="checkbox" class="task-list-item-checkbox">
|
|
|
|
Bender
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul class="contains-task-list">
|
|
|
|
<li class="task-list-item">
|
|
|
|
<input type="checkbox" class="task-list-item-checkbox">
|
|
|
|
BB-8
|
|
|
|
</li>
|
|
|
|
<li class="task-list-item">
|
|
|
|
<input type="checkbox" class="task-list-item-checkbox">
|
|
|
|
WALL-E
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</task-lists>
|
|
|
|
```
|
|
|
|
|
|
|
|
## Events
|
|
|
|
|
|
|
|
```js
|
|
|
|
const list = document.querySelector('task-lists')
|
|
|
|
|
2019-03-15 00:31:29 +03:00
|
|
|
list.addEventListener('task-lists-check', function(event) {
|
2018-04-26 01:58:53 +03:00
|
|
|
const {position, checked} = event.detail
|
|
|
|
console.log(position, checked)
|
|
|
|
})
|
|
|
|
|
2019-03-15 00:31:29 +03:00
|
|
|
list.addEventListener('task-lists-move', function(event) {
|
2018-04-26 01:58:53 +03:00
|
|
|
const {src, dst} = event.detail
|
|
|
|
console.log(src, dst)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
## Browser support
|
|
|
|
|
2018-06-29 02:17:49 +03:00
|
|
|
Browsers without native [custom element support][support] require a [polyfill][].
|
|
|
|
|
2018-04-26 01:58:53 +03:00
|
|
|
- Chrome
|
|
|
|
- Firefox
|
2018-06-29 02:17:49 +03:00
|
|
|
- Safari
|
2018-04-26 01:58:53 +03:00
|
|
|
- Microsoft Edge
|
|
|
|
|
2018-06-29 02:17:49 +03:00
|
|
|
[support]: https://caniuse.com/#feat=custom-elementsv1
|
|
|
|
[polyfill]: https://github.com/webcomponents/custom-elements
|
|
|
|
|
2018-04-26 01:58:53 +03:00
|
|
|
## Development
|
|
|
|
|
|
|
|
```
|
|
|
|
npm install
|
|
|
|
npm test
|
|
|
|
```
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
Distributed under the MIT license. See LICENSE for details.
|