-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liningzhu
committed
Nov 10, 2023
1 parent
50ae374
commit f8d690d
Showing
6 changed files
with
187 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FC } from 'react' | ||
import { | ||
DragDropContext, | ||
Droppable, | ||
Draggable, | ||
type DragDropContextProps, | ||
type DroppableProps, | ||
} from 'react-beautiful-dnd' | ||
|
||
export type DragableListProps = { | ||
list: any[] | ||
className?: string | ||
} & Pick<DroppableProps, 'direction'> & | ||
Pick<DragDropContextProps, 'onDragEnd'> | ||
|
||
export const DragableList: FC<DragableListProps> = ({ | ||
list, | ||
onDragEnd, | ||
className, | ||
direction = 'horizontal', | ||
}) => { | ||
return ( | ||
<DragDropContext onDragEnd={onDragEnd}> | ||
<Droppable droppableId="droppable" direction={direction}> | ||
{(provided) => ( | ||
<div {...provided.droppableProps} ref={provided.innerRef} className={className}> | ||
{list.map((item, index) => ( | ||
<Draggable key={index} draggableId={index.toString()} index={index}> | ||
{(provided) => ( | ||
<div | ||
{...provided.draggableProps} | ||
{...provided.dragHandleProps} | ||
ref={provided.innerRef} | ||
> | ||
{item} | ||
</div> | ||
)} | ||
</Draggable> | ||
))} | ||
{provided.placeholder} | ||
</div> | ||
)} | ||
</Droppable> | ||
</DragDropContext> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './collection-selecter' | ||
export * from './drag-list' | ||
export * from './text-input' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.