-
Notifications
You must be signed in to change notification settings - Fork 486
/
Copy pathDragDrop.story.js
68 lines (59 loc) · 1.99 KB
/
DragDrop.story.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React from 'react'
import {storiesOf} from '@storybook/react'
import debug from './helpers/debug'
import Board from '../src'
const data = require('./data/base.json')
storiesOf('Drag-n-Drop', module)
.add(
'Basic',
() => {
const handleDragStart = (cardId, laneId) => {
debug('drag started')
debug(`cardId: ${cardId}`)
debug(`laneId: ${laneId}`)
}
const handleDragEnd = (cardId, sourceLaneId, targetLaneId, position, card) => {
debug('drag ended')
debug(`cardId: ${cardId}`)
debug(`sourceLaneId: ${sourceLaneId}`)
debug(`targetLaneId: ${targetLaneId}`)
debug(`newPosition: ${position}`)
debug(`cardDetails:`)
debug(card)
}
const handleLaneDragStart = laneId => {
debug(`lane drag started for ${laneId}`)
}
const handleLaneDragEnd = (removedIndex, addedIndex, {id}) => {
debug(`lane drag ended from position ${removedIndex} for laneId=${id}`)
debug(`New lane position: ${addedIndex}`)
}
const shouldReceiveNewData = nextData => {
debug('data has changed')
debug(nextData)
}
const onCardMoveAcrossLanes = (fromLaneId, toLaneId, cardId, addedIndex) => {
debug(`onCardMoveAcrossLanes: ${fromLaneId}, ${toLaneId}, ${cardId}, ${addedIndex}`)
}
return (
<Board
data={data}
draggable
onCardMoveAcrossLanes={onCardMoveAcrossLanes}
onDataChange={shouldReceiveNewData}
handleDragStart={handleDragStart}
handleDragEnd={handleDragEnd}
handleLaneDragStart={handleLaneDragStart}
handleLaneDragEnd={handleLaneDragEnd}
/>
)
},
{info: 'A demonstration of onDragStart and onDragEnd hooks for card and lanes'}
)
.add(
'Drag Styling',
() => {
return <Board data={data} cardDragClass="draggingCard" laneDragClass="draggingLane" draggable />
},
{info: 'Modifying appearance of dragged card'}
)