Gathering detailed insights and metrics for @caldwell619/react-kanban
Gathering detailed insights and metrics for @caldwell619/react-kanban
Gathering detailed insights and metrics for @caldwell619/react-kanban
Gathering detailed insights and metrics for @caldwell619/react-kanban
npm install @caldwell619/react-kanban
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
30 Stars
403 Commits
12 Forks
3 Watching
6 Branches
10 Contributors
Updated on 25 Nov 2024
Minified
Minified + Gzipped
TypeScript (96.2%)
JavaScript (2.36%)
SCSS (0.95%)
Shell (0.49%)
Cumulative downloads
Total Downloads
Last day
-32%
140
Compared to previous day
Last week
27.4%
813
Compared to previous week
Last month
39.6%
2,705
Compared to previous month
Last year
400.2%
14,475
Compared to previous year
3
45
Forked from asseinfo's React Kanban
Shout out to all the contributors.
Here is what's in the queue. If you want to see something, make an issue
1yarn add @caldwell619/react-kanban
You will also need to install the peer dependencies on your own:
1 "peerDependencies": { 2 "react": ">=16", 3 "react-dom": ">=16", 4 "@hello-pangea/dnd": ">=16" 5 },
These are listed as peer dependencies because I do not want to pin specific versions as dependencies if you are already using them.
There are 2 main boards, Controlled
and Uncontrolled
.
This is a deviation from the original, as there was only one board exported. In the original, there's an in-library determination on whether or not the board is controlled. That is not quite how this works, as you will know upfront whether or not your board is controlled.
With that in mind, you can import each of the boards like this:
1import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban' 2// import { ControlledBoard } from '@caldwell619/react-kanban' 3import '@caldwell619/react-kanban/dist/styles.css' // import here for "builtin" styles 4 5const board: KanbanBoard = { 6 columns: [ 7 { 8 id: 1, 9 title: 'Backlog', 10 cards: [ 11 { 12 id: 1, 13 title: 'Add card', 14 description: 'Add capability to add a card in a column' 15 }, 16 ] 17 }, 18 { ... } 19 ] 20} 21 22<UncontrolledBoard initialBoard={board} />
With an uncontrolled board, you pass an initialBoard
prop, which will be the basis of the internal state. When a user moves something, that is all controlled by internal state.
When you need a better control over the board, you should stick with the controlled board.
A controlled board means you need to deal with the board state yourself, you need to keep the state in your hands (component) and pass this state to the <Board />
, we just reflect this state.
If you go with the controlled one, you need to pass your board through the children
prop.
If you really want to use the one unified board, you can still do so with Board
. Whether or not you provide initialBoard
or children
will determine which board you're using. If you provide both, UncontrolledBoard
takes priority.
See an example, here.
Helpers are exposed to help with the management of your board state when using the ControlledBoard
. They are the same helpers used internally, so you can utilize them to assist in your controlled state.
1import { ControlledBoard, moveCard, KanbanBoard, OnDragEndNotification, Card } from '@caldwell619/react-kanban' 2 3const MyBoard = () => { 4 const [board, setBoard] = useState<KanbanBoard>(initialBoard) 5 6 const handleCardMove: OnDragEndNotification<Card> = (_card, source, destination) => { 7 setBoard((currentBoard) => { 8 return moveCard(currentBoard, source, destination) 9 }) 10 } 11 12 return <ControlledBoard onCardDragEnd={handleCardMove}>{board}</ControlledBoard> 13}
If you're using JS, this section doesn't have any effect on you.
The TypeScript type for the board is KanbanBoard
. It is a generic that accepts TCard extends Card
. Your data will undoubtedly need to be customized, so all the helpers and Board will accept your TCard
.
1import { Card } from '@caldwell619/react-kanban' 2 3interface CustomCard extends Card { 4 storyPoints: number 5} 6export const renderCard: UncontrolledBoardProps<CustomCard>['renderCard'] = (card) => { 7 // Can access with `card.storyPoints` 8 return <CardWithStoryPoints {...card} /> 9}
This behavior will applied throughout the render and confirm methods.
1import { ControlledBoard, KanbanBoard } from '@caldwell619/react-kanban' 2 3const CustomBoard = () => { 4 return ( 5 <ControlledBoard<CustomCard> 6 renderCard={(card) => { 7 // `card.storyPoints` 8 return <CardWithStoryPoints {...card} /> 9 }} 10 > 11 {board} 12 </ControlledBoard> 13 ) 14}
For an exhaustive ( yet still WIP ) list of props you can pass, refer to this page.
You can either style all the board or import our style and override it with the styles you want. Ideally you would render the column instead of overriding CSS, however this may be helpful for you if your use case needs it.
Class |
---|
react-kanban-board |
react-kanban-card |
react-kanban-card-skeleton |
react-kanban-card--dragging |
react-kanban-card__description |
react-kanban-card__title |
react-kanban-column |
react-kanban-card-adder-form |
react-kanban-card-adder-button |
react-kanban-card-adder-form__title |
react-kanban-card-adder-form__description |
react-kanban-card-adder-form__button |
react-kanban-column-header |
react-kanban-column-header__button |
react-kanban-column-adder-button |
Shout out to @vjanssens for discovering there are some extra steps for compatibility with Remix.
Add the following to your Vite config:
1export default defineConfig({ 2 // the rest of your config 3 ssr: { 4 noExternal: ["@caldwell619/react-kanban"] 5 }, 6});
PRs are welcome.
yarn
to install depsyarn all-contributors add
yarn all-contributors generate
christopher-caldwell:master
.No vulnerabilities found.
No security vulnerabilities found.