Skip to content

Commit 0fde68a

Browse files
committed
merge main
2 parents 9661134 + 162db98 commit 0fde68a

9 files changed

Lines changed: 13941 additions & 9435 deletions

File tree

.eslintrc.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
},
7+
extends: [
8+
"standard-with-typescript",
9+
"plugin:react/recommended",
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
],
13+
overrides: [
14+
{
15+
env: {
16+
node: true,
17+
},
18+
files: [".eslintrc.{js,cjs}"],
19+
parserOptions: {
20+
sourceType: "script",
21+
},
22+
},
23+
],
24+
parserOptions: {
25+
ecmaVersion: "latest",
26+
sourceType: "module",
27+
},
28+
plugins: ["react"],
29+
settings: {
30+
react: {
31+
version: "detect",
32+
},
33+
},
34+
rules: {},
35+
};

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx eslint 'src/**/*.{js,ts,tsx}'

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,48 @@ Tiny sortable list
33

44
![Build](https://github.com/ufocoder/tiny-sortable-list/actions/workflows/build.yml/badge.svg)
55

6-
Example of sortable list on React based on HTML [Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
6+
React component for sortable list based on HTML [Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
7+
78

89
## Features
910

11+
- No dependencies
1012
- Horizonal and vertical lists
1113

1214
## Usage
1315

16+
Minimal working example
17+
1418
```typescript
19+
import { useState } from 'react'
20+
import { SortableList, SortableItemProps } from 'tiny-sortable-list'
21+
1522
interface Item {
1623
title: string
1724
}
1825

26+
const itemStyle = {
27+
padding: '20px 10px',
28+
background: 'white',
29+
border: '2px black solid'
30+
};
31+
32+
function ItemVerticalComponent(props: SortableItemProps<Item>) {
33+
const { item, isDragged, isDragItemInsertAfter, isDragItemInsertBefore } = props
34+
35+
return (
36+
<div
37+
style={{
38+
...itemStyle,
39+
opacity: isDragged ? '0.3' : undefined,
40+
borderTopColor: isDragItemInsertBefore ? 'yellow' : 'black',
41+
borderBottomColor: isDragItemInsertAfter ? 'yellow' : 'black',
42+
}}>
43+
{item.title}
44+
</div>
45+
)
46+
}
47+
1948
function App() {
2049
const [items, setItems] = useState<Item[]>([
2150
{ title: 'item #1'},

0 commit comments

Comments
 (0)