Skip to content

Commit

Permalink
feat: Allow creating multiple boards
Browse files Browse the repository at this point in the history
Each board gets its own redux store for isolation and performance reasons

#65
  • Loading branch information
rcdexta committed Mar 19, 2018
1 parent 15ec5a7 commit cf19f63
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import boardReducer from '../reducers/BoardReducer'
import logger from 'redux-logger'

const middlewares = process.env.NODE_ENV === 'development' ? [logger] : []
const store = createStore(boardReducer, applyMiddleware(...middlewares))

export default class Board extends Component {

getStore = () => {
//When you create multiple boards, unique stores are created for isolation
return createStore(boardReducer, applyMiddleware(...middlewares))
}

render() {
return (
<Provider store={store}>
<Provider store={this.getStore()}>
<BoardContainer {...this.props} />
</Provider>
)
Expand Down
29 changes: 29 additions & 0 deletions stories/MultipleBoards.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
import {withInfo} from '@storybook/addon-info'
import {storiesOf} from '@storybook/react'

import Board from '../src'

const data1 = require('./data/base.json')
const data2 = require('./data/other-board')

const containerStyles = {
height: 500,
padding: 20
}

storiesOf('Multiple Boards', module).add(
'Two Boards',
withInfo('Have two boards rendering their own data')(() => {
return (
<div style={{display: 'flex', flexDirection: 'column'}}>
<div style={containerStyles}>
<Board data={data1} />
</div>
<div style={containerStyles}>
<Board data={data2} />
</div>
</div>
)
})
)
55 changes: 55 additions & 0 deletions stories/data/other-board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"lanes": [
{
"id": "yesterday",
"title": "Yesterday",
"label": "20/70",
"cards": [
{
"id": "Wip1",
"title": "Clean House",
"label": "30 mins",
"description": "Soap wash and polish floor. Polish windows and doors. Scrap all broken glasses"
}
]
},
{
"id": "today",
"title": "Today",
"label": "10/20",
"droppable": false,
"cards": [
{
"id": "Milk",
"title": "Buy milk",
"label": "15 mins",
"description": "2 Gallons of milk at the Deli store"
},
{
"id": "Plan2",
"title": "Dispose Garbage",
"label": "10 mins",
"description": "Sort out recyclable and waste as needed"
},
{
"id": "Plan3",
"title": "Write Blog",
"label": "30 mins",
"description": "Can AI make memes?"
},
{
"id": "Plan4",
"title": "Pay Rent",
"label": "5 mins",
"description": "Transfer to bank account"
}
]
},
{
"id": "tomorrow",
"title": "Tomorrow",
"label": "0/0",
"cards": []
}
]
}
1 change: 1 addition & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ import './BoardStyling.story'
import './AsyncLoad.story'
import './RestrictedLanes.story'
import './EditableBoard.story'
import './MultipleBoards.story'

0 comments on commit cf19f63

Please sign in to comment.