Skip to content

Commit dfed6fe

Browse files
committed
OpenConceptLab/ocl_issues#2190 | draggable split view
1 parent 3fc3aaa commit dfed6fe

4 files changed

Lines changed: 73 additions & 14 deletions

File tree

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"react-hotjar": "^5.5.0",
2727
"react-i18next": "^12.1.5",
2828
"react-router-dom": "^5.3.4",
29+
"react-split": "^2.0.14",
2930
"stacktrace-js": "^2.0.2",
3031
"xlsx": "^0.18.5"
3132
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.gutter {
2+
background-color: rgba(0, 0, 0, 0.1);
3+
cursor: col-resize;
4+
position: relative;
5+
border-radius: 10px;
6+
margin: 8px 2px;
7+
}
8+
9+
.gutter::before {
10+
content: '';
11+
position: absolute;
12+
top: 50%;
13+
left: 50%;
14+
width: 4px;
15+
height: 30px;
16+
background-color: #888;
17+
border-radius: 2px;
18+
transform: translate(-50%, -50%);
19+
}

src/components/map-projects/MapProject.jsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react'
22
import * as XLSX from 'xlsx';
33
import moment from 'moment'
4+
import Split from 'react-split';
5+
46
import { useParams, useHistory } from 'react-router-dom'
57

68
import Paper from '@mui/material/Paper'
@@ -89,6 +91,7 @@ import Candidates from './Candidates'
8991
import SearchCandidates from './SearchCandidates'
9092

9193
import './MapProject.scss'
94+
import '../common/ResizablePanel.scss'
9295

9396
const MapProject = () => {
9497
const { toggles, setAlert: baseSetAlert } = React.useContext(OperationsContext);
@@ -1008,17 +1011,32 @@ const MapProject = () => {
10081011

10091012
return (
10101013
<div className='col-xs-12 padding-0' style={{borderRadius: '10px', width: 'calc(100vw - 32px)'}}>
1011-
<Paper component="div" className={isSplitView ? 'col-xs-6 split padding-0' : 'col-xs-12 split padding-0'} sx={{boxShadow: 'none', p: 0, backgroundColor: 'white', borderRadius: '10px', border: 'solid 0.3px', borderColor: 'surface.nv80', minHeight: 'calc(100vh - 100px) !important'}}>
1012-
<Paper component="div" className='col-xs-12' sx={{backgroundColor: 'surface.main', boxShadow: 'none', padding: '4px 16px 8px 16px', borderRadius: '10px 10px 0 0', ...((isConfigureInSplitView || !configure) ? {} : {height: 'calc(100vh - 125px) !important', overflow: 'auto'})}}>
1013-
{
1014-
configure && !file?.name &&
1015-
<div className='col-xs-8 padding-0'>
1016-
<ConfigurationForm
1017-
project={project}
1018-
handleFileUpload={handleFileUpload}
1019-
file={file}
1020-
owner={owner}
1021-
setOwner={setOwner}
1014+
<Split
1015+
sizes={isSplitView ? [50, 50] : [100, 0]} // initial % widths
1016+
minSize={isSplitView ? 200 : 1000}
1017+
expandToMin={false}
1018+
gutterSize={isSplitView ? 6 : 0}
1019+
snapOffset={0}
1020+
direction="horizontal"
1021+
cursor="col-resize"
1022+
style={{ display: 'flex', height: 'calc(100vh - 100px)' }}
1023+
gutter={() => {
1024+
const gutter = document.createElement('div');
1025+
gutter.className = 'gutter';
1026+
return gutter;
1027+
}}
1028+
>
1029+
<Paper component="div" className={isSplitView ? 'col-xs-6 split padding-0' : 'col-xs-12 split padding-0'} sx={{boxShadow: 'none', p: 0, backgroundColor: 'white', borderRadius: '10px', border: 'solid 0.3px', borderColor: 'surface.nv80', minHeight: 'calc(100vh - 100px) !important'}}>
1030+
<Paper component="div" className='col-xs-12' sx={{backgroundColor: 'surface.main', boxShadow: 'none', padding: '4px 16px 8px 16px', borderRadius: '10px 10px 0 0', minWidth: '665px', ...((isConfigureInSplitView || !configure) ? {} : {height: 'calc(100vh - 125px) !important', overflow: 'auto'})}}>
1031+
{
1032+
configure && !file?.name &&
1033+
<div className='col-xs-8 padding-0'>
1034+
<ConfigurationForm
1035+
project={project}
1036+
handleFileUpload={handleFileUpload}
1037+
file={file}
1038+
owner={owner}
1039+
setOwner={setOwner}
10221040
name={name}
10231041
setName={setName}
10241042
description={description}
@@ -1102,7 +1120,7 @@ const MapProject = () => {
11021120
</Paper>
11031121
{
11041122
(Boolean(rows?.length) || selectedMatchBucket || ROW_STATES.includes(selectedRowStatus) || searchText) &&
1105-
<div className='col-xs-12' style={{padding: '0', width: '100%', height: 'calc(100vh - 170px)'}}>
1123+
<div className='col-xs-12' style={{padding: '0', width: '100%', height: 'calc(100vh - 170px)', minWidth: '665px'}}>
11061124
<div className='col-xs-12' style={{padding: '0 12px', display: 'flex', backgroundColor: SURFACE_COLORS.main, overflowX: 'auto'}}>
11071125
{
11081126
map(VIEWS, (state, view) => {
@@ -1331,7 +1349,7 @@ const MapProject = () => {
13311349
</DialogActions>
13321350
</Dialog>
13331351
</Paper>
1334-
<Paper component="div" className={isSplitView ? 'col-xs-6 split padding-0 split-appear' : 'col-xs-6 padding-0'} sx={{width: isSplitView ? 'calc(50% - 16px) !important' : 0, marginLeft: '16px', boxShadow: 'none', p: 0, backgroundColor: WHITE, borderRadius: '10px', border: 'solid 0.3px', borderColor: 'surface.nv80', opacity: isSplitView ? 1 : 0, height: 'calc(100vh - 100px) !important', overflow: 'auto'}}>
1352+
<Paper component="div" className={isSplitView ? 'col-xs-6 split padding-0 split-appear' : 'col-xs-6 padding-0'} sx={{boxShadow: 'none', p: 0, backgroundColor: WHITE, borderRadius: '10px', border: 'solid 0.3px', borderColor: 'surface.nv80', opacity: isSplitView ? 1 : 0, height: 'calc(100vh - 100px) !important', overflow: 'auto'}}>
13351353
{
13361354
configure && file?.name ?
13371355
<div className='col-xs-12'>
@@ -1490,7 +1508,8 @@ const MapProject = () => {
14901508
</>
14911509
)
14921510
}
1493-
</Paper>
1511+
</Paper>
1512+
</Split>
14941513
<Menu
14951514
id="matching-algo"
14961515
anchorEl={algoMenuAnchorEl}

0 commit comments

Comments
 (0)