Skip to content

Commit d0583ec

Browse files
committed
Add yarn lint, add props section to README
1 parent 3a2ca12 commit d0583ec

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
![GIF of the demo being used](./readme/demo.gif)
66

7-
This is a thin wrapper around the great [SortableJS](https://github.com/SortableJS/Sortable) library. I had many issues migrating from Vue.Draggable to vue.draggable.next, and after briefly investigating I decided that it was too complicated and a smaller solution was the answer. This wrapper tries to keep you as close to Sortable as possible (wrapper libaries seem to re-implement or unnecessarily wrap a lot of code).
8-
9-
Note that this library is small enough (see [Sortable.vue](https://github.com/MaxLeiter/sortablejs-vue3/blob/main/src/components/Sortable.vue) for what you really need) that I recommend including it in your project without using npm and importing it as a local component. All you need is the linked file.
7+
This is a thin wrapper around the great [SortableJS](https://github.com/SortableJS/Sortable) library. I had many issues migrating from Vue.Draggable to vue.draggable.next, and after briefly investigating I decided that it was too complicated and a smaller solution was the answer. This wrapper attempts to keep you as close to Sortable as possible.
108

119
### Why not use \<other library\>?
1210

@@ -60,6 +58,13 @@ import { Sortable } from "sortablejs-vue3";
6058

6159
5. The `tag` prop is an optional prop, it's the HTML node type of the element that creates an outer element for the included slot. the default value is `div`
6260

61+
### Props
62+
63+
- `list` (`Array<any>`, required): your data to list
64+
- `itemKey` (`string` | `(item) => (string | number | Symbol)`, required): The name of the key present in each item in the list that corresponds to a unique value (to use as the `key`)
65+
- `tag` (`string`, optional, default = `"div"`): The element type to render as
66+
- `options` (`Object`, false): the SortableJS options minus event handlers (see below)
67+
6368
### Events
6469

6570
You can listen to Sortable events by adding the listeners to the `Sortable` component. For example:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build": "vite build && vue-tsc --emitDeclarationOnly --project tsconfig.dist.json && mv dist/lib dist/types && rm -rf favicon.ico",
2121
"build:site": "vue-tsc --noEmit --project tsconfig.site.json && vite --config vite.site.config.ts build",
2222
"preview": "vite preview",
23-
"lint": "vite lint"
23+
"lint": "yarn prettier --write '**/*.{ts,vue,json}'"
2424
},
2525
"types": "./dist/types/main.d.ts",
2626
"files": [

src/components/HelloWorld.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ main {
115115
<Sortable
116116
v-if="element.children"
117117
:list="element.children"
118-
item-key="id"
118+
:item-key="(item) => item.id"
119119
:options="options"
120120
@change="logEvent"
121121
@choose="logEvent"

src/components/Sortable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const props = defineProps({
3939
default: "",
4040
required: true,
4141
},
42-
/** The element type to render as (string or function). */
42+
/** The element type to render as. */
4343
tag: {
4444
type: String as PropType<string>,
4545
default: "div",

0 commit comments

Comments
 (0)