|
1 | 1 | import React from 'react'
|
2 | 2 | import R from 'ramda'
|
3 |
| -import { Waypoint } from 'react-waypoint' |
4 |
| -import { SortableContainer, SortableElement } from 'react-sortable-hoc' |
5 |
| -import { OverlayScrollbarsComponent } from 'overlayscrollbars-react' |
6 | 3 |
|
7 | 4 | import MenuBar from './MenuBar'
|
8 |
| -import { anchorTop, anchorOffTop, anchorBottom, anchorOffBottom } from './logic' |
9 |
| -import { Wrapper, ScrollWrapper } from './styles/menu_list' |
| 5 | +import NormalMenuList from './NormalMenuList' |
| 6 | +import SortableMenuList from './SortableMenuList' |
10 | 7 |
|
11 |
| -const SortableMenuBar = SortableElement( |
12 |
| - ({ pin, item, activeRaw, forceRerender }) => ( |
13 |
| - <MenuBar |
14 |
| - pin={pin} |
15 |
| - item={item} |
16 |
| - activeRaw={activeRaw} |
17 |
| - forceRerender={forceRerender} |
18 |
| - /> |
19 |
| - ) |
20 |
| -) |
| 8 | +import { Wrapper } from './styles/menu_list' |
| 9 | +import { onSortMenuEnd } from './logic' |
21 | 10 |
|
22 |
| -const MenuList = SortableContainer( |
23 |
| - ({ items, pin, activeRaw, forceRerender, showHeaderShadow }) => { |
24 |
| - const homeCommunities = R.filter(R.propEq('raw', 'home'), items) |
25 |
| - const sortableCommunities = R.reject(R.propEq('raw', 'home'), items) |
| 11 | +const MenuList = ({ |
| 12 | + items, |
| 13 | + pin, |
| 14 | + sortOptActive, |
| 15 | + activeRaw, |
| 16 | + forceRerender, |
| 17 | + showHeaderShadow, |
| 18 | +}) => { |
| 19 | + const pinedCommunities = R.filter(R.propEq('raw', 'home'), items) |
| 20 | + const sortableCommunities = R.reject(R.propEq('raw', 'home'), items) |
26 | 21 |
|
27 |
| - return ( |
28 |
| - <Wrapper> |
29 |
| - {homeCommunities.map(item => ( |
30 |
| - <MenuBar |
31 |
| - key={item.raw} |
32 |
| - pin={pin} |
33 |
| - item={item} |
34 |
| - activeRaw={activeRaw} |
35 |
| - dropShadow={showHeaderShadow} |
36 |
| - /> |
37 |
| - ))} |
38 |
| - <OverlayScrollbarsComponent |
39 |
| - options={{ scrollbars: { autoHide: 'scroll', autoHideDelay: 200 } }} |
40 |
| - className="os-theme-light" |
41 |
| - > |
42 |
| - <ScrollWrapper> |
43 |
| - <React.Fragment> |
44 |
| - <Waypoint onEnter={anchorTop} onLeave={anchorOffTop} /> |
45 |
| - {sortableCommunities.map((item, index) => ( |
46 |
| - <SortableMenuBar |
47 |
| - index={index} |
48 |
| - key={item.raw} |
49 |
| - pin={pin} |
50 |
| - item={item} |
51 |
| - activeRaw={activeRaw} |
52 |
| - forceRerender={forceRerender} |
53 |
| - /> |
54 |
| - ))} |
55 |
| - <Waypoint onEnter={anchorBottom} onLeave={anchorOffBottom} /> |
56 |
| - </React.Fragment> |
57 |
| - </ScrollWrapper> |
58 |
| - </OverlayScrollbarsComponent> |
59 |
| - </Wrapper> |
60 |
| - ) |
61 |
| - } |
62 |
| -) |
| 22 | + return ( |
| 23 | + <Wrapper> |
| 24 | + {pinedCommunities.map(item => ( |
| 25 | + <MenuBar |
| 26 | + key={item.raw} |
| 27 | + pin={pin} |
| 28 | + item={item} |
| 29 | + activeRaw={activeRaw} |
| 30 | + dropShadow={showHeaderShadow} |
| 31 | + /> |
| 32 | + ))} |
| 33 | + {!sortOptActive ? ( |
| 34 | + <NormalMenuList |
| 35 | + communities={sortableCommunities} |
| 36 | + pin={pin} |
| 37 | + activeRaw={activeRaw} |
| 38 | + forceRerender={forceRerender} |
| 39 | + /> |
| 40 | + ) : ( |
| 41 | + <SortableMenuList |
| 42 | + communities={sortableCommunities} |
| 43 | + sortOptActive={sortOptActive} |
| 44 | + pin={pin} |
| 45 | + activeRaw={activeRaw} |
| 46 | + forceRerender={forceRerender} |
| 47 | + onSortEnd={onSortMenuEnd} |
| 48 | + /> |
| 49 | + )} |
| 50 | + </Wrapper> |
| 51 | + ) |
| 52 | +} |
63 | 53 |
|
64 | 54 | export default MenuList
|
0 commit comments