forked from christopher-caldwell/react-kanban
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2 merge types (christopher-caldwell#15)
* fix: Consolidating types and adding a one board * feat: Adding the unified board
- Loading branch information
1 parent
fda579d
commit c8cd185
Showing
9 changed files
with
175 additions
and
95 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
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,52 @@ | ||
import { FC, useState } from 'react' | ||
import { Board, OnDragEndNotification, Card, moveCard, KanbanBoard } from '@caldwell619/react-kanban' | ||
|
||
import { board } from '@/data' | ||
import { Source } from '@/components' | ||
|
||
// If you want to use the library like the old one, you can do so by determining which board you want to use | ||
export const UncontrolledBoardDemo: FC = () => { | ||
return ( | ||
<> | ||
<Source | ||
title='Uncontrolled' | ||
url='https://github.com/christopher-caldwell/react-kanban/blob/main/demo/src/features/on-board/index.tsx' | ||
/> | ||
<Board | ||
initialBoard={board} | ||
onCardRemove={({ board, card, column }) => { | ||
console.log({ board, card, column }) | ||
}} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export const ControlledBoardDemo: FC = () => { | ||
// You need to control the state yourself. | ||
const [controlledBoard, setBoard] = useState<KanbanBoard<Card>>({ ...board }) | ||
|
||
const handleCardMove: OnDragEndNotification<Card> = (_card, source, destination) => { | ||
setBoard(currentBoard => { | ||
return moveCard(currentBoard, source, destination) | ||
}) | ||
} | ||
|
||
return ( | ||
<> | ||
<Source | ||
title='Controlled' | ||
url='https://github.com/christopher-caldwell/react-kanban/blob/main/demo/src/features/controlled/index.tsx' | ||
/> | ||
<Board | ||
onCardDragEnd={handleCardMove} | ||
disableColumnDrag | ||
onCardRemove={({ board, card, column }) => { | ||
console.log({ board, card, column }) | ||
}} | ||
> | ||
{controlledBoard} | ||
</Board> | ||
</> | ||
) | ||
} |
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
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
Oops, something went wrong.