Skip to content

Commit cf19f63

Browse files
committed
feat: Allow creating multiple boards
Each board gets its own redux store for isolation and performance reasons #65
1 parent 15ec5a7 commit cf19f63

4 files changed

Lines changed: 92 additions & 2 deletions

File tree

src/components/Board.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import boardReducer from '../reducers/BoardReducer'
66
import logger from 'redux-logger'
77

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

1110
export default class Board extends Component {
11+
12+
getStore = () => {
13+
//When you create multiple boards, unique stores are created for isolation
14+
return createStore(boardReducer, applyMiddleware(...middlewares))
15+
}
16+
1217
render() {
1318
return (
14-
<Provider store={store}>
19+
<Provider store={this.getStore()}>
1520
<BoardContainer {...this.props} />
1621
</Provider>
1722
)

stories/MultipleBoards.story.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import {withInfo} from '@storybook/addon-info'
3+
import {storiesOf} from '@storybook/react'
4+
5+
import Board from '../src'
6+
7+
const data1 = require('./data/base.json')
8+
const data2 = require('./data/other-board')
9+
10+
const containerStyles = {
11+
height: 500,
12+
padding: 20
13+
}
14+
15+
storiesOf('Multiple Boards', module).add(
16+
'Two Boards',
17+
withInfo('Have two boards rendering their own data')(() => {
18+
return (
19+
<div style={{display: 'flex', flexDirection: 'column'}}>
20+
<div style={containerStyles}>
21+
<Board data={data1} />
22+
</div>
23+
<div style={containerStyles}>
24+
<Board data={data2} />
25+
</div>
26+
</div>
27+
)
28+
})
29+
)

stories/data/other-board.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"lanes": [
3+
{
4+
"id": "yesterday",
5+
"title": "Yesterday",
6+
"label": "20/70",
7+
"cards": [
8+
{
9+
"id": "Wip1",
10+
"title": "Clean House",
11+
"label": "30 mins",
12+
"description": "Soap wash and polish floor. Polish windows and doors. Scrap all broken glasses"
13+
}
14+
]
15+
},
16+
{
17+
"id": "today",
18+
"title": "Today",
19+
"label": "10/20",
20+
"droppable": false,
21+
"cards": [
22+
{
23+
"id": "Milk",
24+
"title": "Buy milk",
25+
"label": "15 mins",
26+
"description": "2 Gallons of milk at the Deli store"
27+
},
28+
{
29+
"id": "Plan2",
30+
"title": "Dispose Garbage",
31+
"label": "10 mins",
32+
"description": "Sort out recyclable and waste as needed"
33+
},
34+
{
35+
"id": "Plan3",
36+
"title": "Write Blog",
37+
"label": "30 mins",
38+
"description": "Can AI make memes?"
39+
},
40+
{
41+
"id": "Plan4",
42+
"title": "Pay Rent",
43+
"label": "5 mins",
44+
"description": "Transfer to bank account"
45+
}
46+
]
47+
},
48+
{
49+
"id": "tomorrow",
50+
"title": "Tomorrow",
51+
"label": "0/0",
52+
"cards": []
53+
}
54+
]
55+
}

stories/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ import './BoardStyling.story'
1313
import './AsyncLoad.story'
1414
import './RestrictedLanes.story'
1515
import './EditableBoard.story'
16+
import './MultipleBoards.story'

0 commit comments

Comments
 (0)