Skip to content

Commit f71c32c

Browse files
committed
retrying from scratch
1 parent b192642 commit f71c32c

File tree

4 files changed

+1394
-1164
lines changed

4 files changed

+1394
-1164
lines changed

dev/App.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import Sortable, { SortableOnEndEvent } from "../src";
1+
import Sortable from "../src";
22
import {createStore} from 'solid-js/store'
3+
import { JSX } from "solid-js";
34

45
const App = () => {
56

6-
const itemStyles = {background: 'green', padding: "10px", minWidth: "100px", margin: "5px", "border-radius": "4px", color: "white"};
7+
const itemStyles: JSX.CSSProperties = {"user-select": "none", background: 'green', padding: "10px", "min-width": "100px", margin: "5px", "border-radius": "4px", color: "white"};
78
const containerStyles = {display: "inline-block", background: 'gray', padding: "10px", "border-radius": "4px"};
89

910
const [items, setItems] = createStore([
@@ -12,19 +13,19 @@ const App = () => {
1213
{ id: 2, name: 2 },
1314
{ id: 3, name: 3 },
1415
])
15-
16-
const onEnd = (event: SortableOnEndEvent<typeof items[0]>) => {
17-
// event.movedItem -> the item that was moved
18-
// event.newList -> the new list of items
19-
// event.oldIndex -> the index of the item that was moved
20-
// event.newIndex -> the index of the item that was moved to
21-
22-
setItems(event.newList);
23-
}
16+
const [items2, setItems2] = createStore([
17+
{ id: 4, name: 4 },
18+
{ id: 5, name: 5 },
19+
{ id: 6, name: 6 },
20+
{ id: 7, name: 7 },
21+
])
2422

2523
return (
2624
<div style={containerStyles}>
27-
<Sortable items={items} onEnd={onEnd}>
25+
<Sortable idField="id" style={{ background: "darkgray"}} items={items} setItems={setItems} >
26+
{item => <div style={itemStyles}>{item.name} {Math.random()}</div>}
27+
</Sortable>
28+
<Sortable idField="id" style={{ background: "darkgray", "margin-top": "102px"}} items={items2} setItems={setItems2} >
2829
{item => <div style={itemStyles}>{item.name} {Math.random()}</div>}
2930
</Sortable>
3031
</div>

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@
5050
"solid-js": ">=1.0.0"
5151
},
5252
"devDependencies": {
53-
"@types/sortablejs": "^1.13.0",
54-
"prettier": "2.7.1",
55-
"rollup": "^2.77.2",
56-
"rollup-preset-solid": "^1.4.0",
57-
"solid-js": "^1.4.8",
58-
"taze": "^0.7.6",
59-
"typescript": "^4.7.4",
60-
"vite": "^3.0.4",
61-
"vite-plugin-solid": "^2.3.0"
53+
"@types/sortablejs": "^1.15.0",
54+
"prettier": "2.8.3",
55+
"rollup": "^3.10.1",
56+
"rollup-preset-solid": "^2.0.1",
57+
"solid-js": "^1.6.9",
58+
"taze": "^0.8.5",
59+
"typescript": "^4.9.4",
60+
"vite": "^4.0.4",
61+
"vite-plugin-solid": "^2.5.0"
6262
},
6363
"keywords": [
6464
"solid"

0 commit comments

Comments
 (0)