-
Notifications
You must be signed in to change notification settings - Fork 12
/
ComparisonAttributes.jsx
70 lines (67 loc) · 2.44 KB
/
ComparisonAttributes.jsx
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
69
70
import React from 'react';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import {
Drawer, Checkbox,
} from '@mui/material';
import { DragIndicator } from '@mui/icons-material';
import { map, keys } from 'lodash';
const getItemStyle = draggableStyle => ({
// some basic styles to make the items look a bit nicer
userSelect: 'none',
// styles we need to apply on draggables
...draggableStyle,
});
const getListStyle = () => ({
overflow: 'hidden',
});
const ComparisonAttributes = ({attributes, open, onClose, onCheckboxClick, onDragEnd}) => {
return (
<Drawer anchor='left' open={open} onClose={onClose} classes={{paper: 'custom-drawer'}}>
<div className='col-md-4' style={{width: '300px'}}>
<h3>
Toggle Attributes:
</h3>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="comparison-attrs-droppable">
{
(provided, snapshot) => (
<div
ref={provided.innerRef}
style={getListStyle(snapshot.isDraggingOver)}
{...provided.droppableProps}
>
{
map(keys(attributes), (attr, index) => (
<Draggable key={attr} draggableId={attr} index={index}>
{
provided => (
<div>
<div
className='col-md-12 flex-vertical-center'
ref={provided.innerRef}
{...provided.dragHandleProps}
{...provided.draggableProps}
style={getItemStyle(provided.draggableProps.style)}
>
<DragIndicator />
<Checkbox checked={attributes[attr].show} onChange={() => onCheckboxClick(attr)} />
{attr}
</div>
{provided.placeholder}
</div>
)
}
</Draggable>
))
}
{provided.placeholder}
</div>
)
}
</Droppable>
</DragDropContext>
</div>
</Drawer>
)
}
export default ComparisonAttributes;