Skip to content

Commit d47791f

Browse files
committed
feat: Enable drag-n-drop to work for lanes and cards. Rewrite dnd library
#30
1 parent 953c9ac commit d47791f

File tree

5 files changed

+22
-73
lines changed

5 files changed

+22
-73
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"immutability-helper": "^2.4.0",
4343
"lodash": "^4.17.4",
4444
"prop-types": "^15.6.0",
45-
"react-beautiful-dnd": "^7.1.0",
4645
"react-redux": "^5.0.3",
4746
"react-smooth-dnd": "^0.3.6",
4847
"redux": "^3.6.0",

src/components/BoardContainer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ class BoardContainer extends Component {
7171
handleLaneDragEnd(payload.id, addedIndex)
7272
}
7373

74-
getLaneDetails = (index) => {
74+
getLaneDetails = index => {
7575
return this.props.reducerData.lanes[index]
7676
}
7777

7878
render() {
79-
const {reducerData, style, ...otherProps} = this.props
79+
const {reducerData, draggable, style, ...otherProps} = this.props
8080
// Stick to whitelisting attributes to segregate board and lane props
8181
const passthroughProps = pick(this.props, [
8282
'onLaneScroll',
@@ -105,23 +105,23 @@ class BoardContainer extends Component {
105105
orientation="horizontal"
106106
onDragStart={this.onDragStart}
107107
onDrop={this.onLaneDrop}
108+
lockAxis={'x'}
108109
getChildPayload={index => this.getLaneDetails(index)}
109110
groupName="TrelloBoard">
110111
{reducerData.lanes.map((lane, index) => {
111112
const {id, droppable, ...otherProps} = lane
112-
return (
113-
<Draggable key={lane.id}>
114-
<Lane
115-
key={id}
116-
id={id}
117-
getCardDetails={this.getCardDetails}
118-
index={index}
119-
droppable={droppable === undefined ? true : droppable}
120-
{...otherProps}
121-
{...passthroughProps}
122-
/>
123-
</Draggable>
113+
const laneToRender = (
114+
<Lane
115+
key={id}
116+
id={id}
117+
getCardDetails={this.getCardDetails}
118+
index={index}
119+
droppable={droppable === undefined ? true : droppable}
120+
{...otherProps}
121+
{...passthroughProps}
122+
/>
124123
)
124+
return draggable ? <Draggable key={lane.id}>{laneToRender}</Draggable> : <span>{laneToRender}</span>
125125
})}
126126
</Container>
127127
</BoardDiv>

src/components/Lane.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class Lane extends Component {
1919
loading: false,
2020
currentPage: this.props.currentPage,
2121
addCardMode: false,
22-
collapsed: false
22+
collapsed: false,
23+
isDraggingOver: false
2324
}
2425

2526
handleScroll = evt => {
@@ -183,6 +184,8 @@ class Lane extends Component {
183184
groupName="TrelloLane"
184185
onDragStart={this.onDragStart}
185186
onDrop={e => this.onDragEnd(id, e)}
187+
onDragEnter={() => this.setState({isDraggingOver: true})}
188+
onDragLeave={() => this.setState({isDraggingOver: false})}
186189
shouldAcceptDrop={() => droppable}
187190
getChildPayload={index => this.props.getCardDetails(id, index)}>
188191
{cardList}
@@ -226,12 +229,12 @@ class Lane extends Component {
226229
}
227230

228231
render() {
229-
const {loading} = this.state
232+
const {loading, isDraggingOver} = this.state
230233
const {id, onLaneClick, ...otherProps} = this.props
231234
return (
232235
<Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false}>
233236
{this.renderHeader()}
234-
{this.renderDragContainer(false)}
237+
{this.renderDragContainer(isDraggingOver)}
235238
{loading && <Loader />}
236239
{this.renderFooter()}
237240
</Section>

src/styles/Base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const ScrollableLane = styled.div`
6565
min-width: 250px;
6666
overflow-x: hidden;
6767
align-self: center;
68-
height: 100%;
68+
max-height: 90vh;
6969
padding-bottom: ${props => (props.isDraggingOver ? '130px' : '30px')};
7070
margin-top: 10px;
7171
flex-direction: column;

yarn.lock

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,10 +5746,6 @@ mem@^1.1.0:
57465746
dependencies:
57475747
mimic-fn "^1.0.0"
57485748

5749-
memoize-one@^3.1.1:
5750-
version "3.1.1"
5751-
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-3.1.1.tgz#ef609811e3bc28970eac2884eece64d167830d17"
5752-
57535749
memory-fs@^0.4.0, memory-fs@~0.4.1:
57545750
version "0.4.1"
57555751
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552"
@@ -6540,10 +6536,6 @@ pbkdf2@^3.0.3:
65406536
safe-buffer "^5.0.1"
65416537
sha.js "^2.4.8"
65426538

6543-
performance-now@^0.2.0:
6544-
version "0.2.0"
6545-
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"
6546-
65476539
performance-now@^2.1.0:
65486540
version "2.1.0"
65496541
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
@@ -7047,16 +7039,6 @@ radium@^0.19.0:
70477039
inline-style-prefixer "^2.0.5"
70487040
prop-types "^15.5.8"
70497041

7050-
raf-schd@^2.1.1:
7051-
version "2.1.1"
7052-
resolved "https://registry.yarnpkg.com/raf-schd/-/raf-schd-2.1.1.tgz#0b59964cee2e96b7dd46ffaeb5c08740f3a5e7ab"
7053-
7054-
raf@^3.1.0:
7055-
version "3.4.0"
7056-
resolved "https://registry.yarnpkg.com/raf/-/raf-3.4.0.tgz#a28876881b4bc2ca9117d4138163ddb80f781575"
7057-
dependencies:
7058-
performance-now "^2.1.0"
7059-
70607042
randomatic@^1.1.3:
70617043
version "1.1.7"
70627044
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c"
@@ -7104,21 +7086,6 @@ react-addons-test-utils@^15.5.1:
71047086
version "15.6.0"
71057087
resolved "https://registry.yarnpkg.com/react-addons-test-utils/-/react-addons-test-utils-15.6.0.tgz#062d36117fe8d18f3ba5e06eb33383b0b85ea5b9"
71067088

7107-
react-beautiful-dnd@^7.1.0:
7108-
version "7.1.0"
7109-
resolved "https://registry.yarnpkg.com/react-beautiful-dnd/-/react-beautiful-dnd-7.1.0.tgz#f78b4b47c557fba7ca3c4ae399c3b9621c92dc50"
7110-
dependencies:
7111-
babel-runtime "^6.26.0"
7112-
memoize-one "^3.1.1"
7113-
prop-types "^15.6.0"
7114-
raf-schd "^2.1.1"
7115-
react-motion "^0.5.2"
7116-
react-redux "^5.0.6"
7117-
redux "^3.7.2"
7118-
redux-thunk "^2.2.0"
7119-
reselect "^3.0.1"
7120-
tiny-invariant "^0.0.3"
7121-
71227089
react-docgen@^2.15.0:
71237090
version "2.17.0"
71247091
resolved "https://registry.yarnpkg.com/react-docgen/-/react-docgen-2.17.0.tgz#b0f3e85af955714e1067593c1043cb82611a93d1"
@@ -7203,15 +7170,7 @@ react-modal@^2.3.2:
72037170
exenv "^1.2.0"
72047171
prop-types "^15.5.10"
72057172

7206-
react-motion@^0.5.2:
7207-
version "0.5.2"
7208-
resolved "https://registry.yarnpkg.com/react-motion/-/react-motion-0.5.2.tgz#0dd3a69e411316567927917c6626551ba0607316"
7209-
dependencies:
7210-
performance-now "^0.2.0"
7211-
prop-types "^15.5.8"
7212-
raf "^3.1.0"
7213-
7214-
react-redux@^5.0.3, react-redux@^5.0.6:
7173+
react-redux@^5.0.3:
72157174
version "5.0.6"
72167175
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.6.tgz#23ed3a4f986359d68b5212eaaa681e60d6574946"
72177176
dependencies:
@@ -7444,10 +7403,6 @@ redux-logger@^3.0.6:
74447403
dependencies:
74457404
deep-diff "^0.3.5"
74467405

7447-
redux-thunk@^2.2.0:
7448-
version "2.2.0"
7449-
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.2.0.tgz#e615a16e16b47a19a515766133d1e3e99b7852e5"
7450-
74517406
redux@^3.6.0, redux@^3.7.2:
74527407
version "3.7.2"
74537408
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
@@ -7688,10 +7643,6 @@ require-uncached@^1.0.3:
76887643
caller-path "^0.1.0"
76897644
resolve-from "^1.0.0"
76907645

7691-
reselect@^3.0.1:
7692-
version "3.0.1"
7693-
resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147"
7694-
76957646
resolve-dir@^0.1.0:
76967647
version "0.1.1"
76977648
resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-0.1.1.tgz#b219259a5602fac5c5c496ad894a6e8cc430261e"
@@ -8503,10 +8454,6 @@ timers-browserify@^2.0.2:
85038454
dependencies:
85048455
setimmediate "^1.0.4"
85058456

8506-
tiny-invariant@^0.0.3:
8507-
version "0.0.3"
8508-
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-0.0.3.tgz#4c7283c950e290889e9e94f64d3586ec9156cf44"
8509-
85108457
tmp@^0.0.29:
85118458
version "0.0.29"
85128459
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0"

0 commit comments

Comments
 (0)