Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@thaddeusjiang/react-sortable-list
Advanced tools
Readme
You should focus the features
of your app, not DnD boilerplate.
yarn add @thaddeusjiang/react-sortable-list
if you don't use Tailwind CSS
import { SortableList } from '@thaddeusjiang/react-sortable-list';
import '@thaddeusjiang/react-sortable-list/dist/index.css';
<SortableList ... />
if you use Tailwind CSS
import { SortableList } from '@thaddeusjiang/react-sortable-list';
<SortableList ...>
modify tailwind.config.js
// tailwind.config.js
+ const path = require("path");
module.exports = {
content: [
"./src/**/*{js,ts,jsx,tsx}",
+ path.join(
+ require.resolve("@thaddeusjiang/react-sortable-list"),
+ "../**/*.{js,ts,jsx,tsx}"
+ ),
],
theme: {},
plugins: [],
};
export const ItemRenderExample: React.VFC = () => {
const [items, setItems] = useState<SortableItemProps[]>([
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
{ id: '3', name: 'Item 3' },
]);
return (
<SortableList
items={items}
setItems={setItems}
itemRender={({ item }: ItemRenderProps) => (
<div className="w-1/2 h-10 m-8 bg-blue-400 text-center">
{item.name}
</div>
)}
/>
);
};
export const ChildrenExample: React.VFC = () => {
const [items, setItems] = useState<SortableItemProps[]>([
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
]);
return (
<SortableList items={items} setItems={setItems}>
{({ items }: { items: SortableItemProps[] }) => (
<>
{items.map((item: SortableItemProps) => (
<SortableItem key={item.id} id={item.id}>
{item.name}
</SortableItem>
))}
</>
)}
</SortableList>
);
};
const DragHandler = (props) => (
<div
{...props}
className=" flex justify-center items-center h-8 w-8 rounded border m-4 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 hover:bg-blue-500 hover:text-white duration-300"
>
<div className="" title="drag handler">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="w-6 h-6"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3 7.5L7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5"
/>
</svg>
</div>
</div>
);
export const DragHandleExample: React.VFC = () => {
const [items, setItems] = useState<SortableItemProps[]>([
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
{ id: '3', name: 'Item 3' },
]);
return (
<SortableList items={items} setItems={setItems}>
{({ items }: { items: SortableItemProps[] }) => (
<div className="space-y-4">
{items.map((item: SortableItemProps) => (
<SortableItem
key={item.id}
id={item.id}
DragHandler={DragHandler}
className="flex border items-center w-40"
>
<div>{item.name}</div>
</SortableItem>
))}
</div>
)}
</SortableList>
);
};
export const HorizontalExample: React.VFC = () => {
const [items, setItems] = useState<SortableItemProps[]>([
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
{ id: '3', name: 'Item 3' },
]);
return (
<div className="flex space-x-4">
<SortableList
items={items}
setItems={setItems}
itemRender={({ item }: ItemRenderProps) => <Item name={item.name} />}
horizontal
/>
</div>
);
};
export const ItemRenderExample: React.VFC = () => {
const [items, setItems] = useState<SortableItemProps[]>([
{ id: '1', name: 'Item 1' },
{ id: '2', name: 'Item 2' },
{ id: '3', name: 'Item 3' },
]);
return (
<SortableList
+ disabled
items={items}
setItems={setItems}
itemRender={({ item }: ItemRenderProps) => (
<div className="w-1/2 h-10 m-8 bg-blue-400 text-center">
{item.name}
</div>
)}
/>
);
};
Run inside another terminal:
yarn storybook
Then run the example inside another:
yarn link
cd example
yarn link "@thaddeusjiang/react-sortable-list"
yarn # or yarn to install dependencies
yarn start
yarn run test
👤 Thaddeus Jiang
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️ if this project helped you!
Copyright © 2022 Thaddeus Jiang.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator
FAQs
You should focus the `features` of your app, not DnD boilerplate.
The npm package @thaddeusjiang/react-sortable-list receives a total of 678 weekly downloads. As such, @thaddeusjiang/react-sortable-list popularity was classified as not popular.
We found that @thaddeusjiang/react-sortable-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.