Skip to content

Commit 180726c

Browse files
author
Clauderic Demers
committed
Fix storybook for grid handle usage
1 parent 5fd0a03 commit 180726c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/.stories/index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const Item = SortableElement((props) => {
2727
<div className={props.className} style={{
2828
height: props.height
2929
}}>
30+
{props.shouldUseDragHandle && <Handle/>}
3031
<div className={style.wrapper}>
31-
{props.useDragHandle && <Handle/>}
3232
<span>Item</span> {props.value}
3333
</div>
3434
</div>
@@ -50,7 +50,8 @@ class ListWrapper extends Component {
5050
height: PropTypes.number,
5151
onSortStart: PropTypes.func,
5252
onSortEnd: PropTypes.func,
53-
component: PropTypes.func
53+
component: PropTypes.func,
54+
shouldUseDragHandle: PropTypes.bool
5455
}
5556
static defaultProps = {
5657
className: classNames(style.list, style.stylizedList),
@@ -80,10 +81,12 @@ class ListWrapper extends Component {
8081
const Component = this.props.component;
8182
const {items, isSorting} = this.state;
8283
const props = {
83-
isSorting, items,
84+
isSorting,
85+
items,
8486
onSortEnd: this.onSortEnd,
8587
onSortStart: this.onSortStart,
86-
ref: "component"
88+
ref: "component",
89+
useDragHandle: this.props.shouldUseDragHandle
8790
}
8891

8992
return <Component {...this.props} {...props} />
@@ -200,7 +203,7 @@ const SortableInfiniteList = SortableContainer(({className, items, itemClass, so
200203
)
201204
});
202205

203-
const SortableList = SortableContainer(({className, items, itemClass, sortingIndex, useDragHandle, sortableHandlers}) => {
206+
const SortableList = SortableContainer(({className, items, itemClass, sortingIndex, shouldUseDragHandle, sortableHandlers}) => {
204207
return (
205208
<div className={className} {...sortableHandlers}>
206209
{items.map(({value, height}, index) =>
@@ -211,14 +214,14 @@ const SortableList = SortableContainer(({className, items, itemClass, sortingInd
211214
index={index}
212215
value={value}
213216
height={height}
214-
useDragHandle={useDragHandle}
217+
shouldUseDragHandle={shouldUseDragHandle}
215218
/>
216219
)}
217220
</div>
218221
);
219222
});
220223

221-
const ShrinkingSortableList = SortableContainer(({className, isSorting, items, itemClass, sortingIndex, useDragHandle, sortableHandlers}) => {
224+
const ShrinkingSortableList = SortableContainer(({className, isSorting, items, itemClass, sortingIndex, shouldUseDragHandle, sortableHandlers}) => {
222225
return (
223226
<div className={className} {...sortableHandlers}>
224227
{items.map(({value, height}, index) =>
@@ -229,8 +232,8 @@ const ShrinkingSortableList = SortableContainer(({className, isSorting, items, i
229232
index={index}
230233
value={value}
231234
height={isSorting ? 20 : height}
232-
useDragHandle={useDragHandle}
233-
/>
235+
shouldUseDragHandle={shouldUseDragHandle}
236+
/>
234237
)}
235238
</div>
236239
);
@@ -247,7 +250,7 @@ storiesOf('Basic Configuration', module)
247250
.add('Drag handle', () => {
248251
return (
249252
<div className={style.root}>
250-
<ListWrapper component={SortableList} useDragHandle={true} items={getItems(50, 59)} helperClass={style.stylizedHelper} />
253+
<ListWrapper component={SortableList} shouldUseDragHandle={true} items={getItems(50, 59)} helperClass={style.stylizedHelper} />
251254
</div>
252255
);
253256
})

0 commit comments

Comments
 (0)