Pluggable components to add a trello like kanban board to your application
- responsive and extensible
 - easily pluggable into existing application
 - supports pagination on scrolling individual lanes
 - drag-and-drop within and across lanes
 - event bus for triggering external events (e.g.: adding or removing cards using realtime backend integration)
 
npm install --save react-trello
The Board component takes a prop called data that contains all the details related to rendering the board. A sample data json is given here to illustrate the contract:
const data = {
  lanes: [
    {
      id: 'lane1',
      title: 'Planned Tasks',
      label: '2/2',
      cards: [
        {id: 'Card1', title: 'Write Blog', description: 'Can AI make memes', label: '30 mins'},
	    {id: 'Card2', title: 'Pay Rent', description: 'Transfer via NEFT', label: '5 mins', metadata: {sha: 'be312a1'}}
      ]
    },
    {
      id: 'lane2',
      title: 'Completed',
      label: '0/0',
      cards: []
    }
  ]
}The data is fed to the board component and that's it.
 <Board data={data} />Refer to storybook for detailed examples: https://rcdexta.github.io/react-trello/
This is the container component that encapsulates the lanes and cards
| Name | Type | Description | 
|---|---|---|
| draggable | boolean | Makes all cards in the lanes draggable. Default: false | 
| handleDragStart | function | Callback function triggered when card drag is started: handleDragStart(cardId, laneId) | 
| handleDragEnd | function | Callback function triggered when card drag ends: handleDragEnd(cardId, sourceLaneId, targetLaneId) | 
| onLaneScroll | function | Called when a lane is scrolled to the end: onLaneScroll(requestedPage, laneId) | 
| onCardClick | function | Called when a card is clicked: onCardClick(cardId, metadata)  | 
| laneSortFunction | function | Used to specify the logic to sort cards on a lane: laneSortFunction(card1, card2) | 
| eventBushandle | function | This is a special function that providers a publishHook to pass new events to the board. See details in Publish Events section | 
| onDataChange | function | Called everytime the data changes due to user interaction or event bus: onDataChange(newData) | 
Refer to tests for more detailed info about the components
When defining the board, it is possible to obtain a event hook to the component to publish new events later after the board has been rendered. Refer the example below:
let eventBus = undefined
let setEventBus = (handle) => {
  eventBus = handle
}
//To add a card
eventBus.publish({type: 'ADD_CARD', laneId: 'COMPLETED', card: {id: "M1", title: "Buy Milk", label: "15 mins", description: "Also set reminder"}})
//To remove a card
eventBus.publish({type: 'REMOVE_CARD', laneId: 'PLANNED', cardId: "M1"})
  
<Board data={data}
       eventBushandle={setEventBus}/>The code will move the card Buy Milk from the planned lane to completed lane. We expect that this library can be wired to a backend push api that can alter the state of the board in realtime.
cd react-trello/
yarn install
yarn run storybook
npm run lint: Lint all js filesnpm run lintfix: fix linting errors of all js filesnpm run semantic-release: make a release. Leave it for CI to do.npm run storybook: Start developing by using storybooknpm run test: Run tests. tests file should be written as*.test.jsand using ES2015npm run test:watch: Watch tests while writingnpm run test:cover: Show coverage report of your testsnpm run test:report: Report test coverage to codecov.io. Leave this for CInpm run build: transpile all ES6 component files into ES5(commonjs) and put it indistdirectorynpm run docs: create static build of storybook indocsdirectory that can be used for github pages
Learn how to write stories here
MIT
