Move chart panel below tree

This commit is contained in:
Thomas Nordquist
2019-06-17 23:27:16 +02:00
parent e82c8c4eb0
commit 1d8900d6eb
5 changed files with 81 additions and 46 deletions

View File

@@ -114,15 +114,16 @@
.Resizer.vertical { .Resizer.vertical {
width: 2px; width: 2px;
margin: 0px -8px 0px 0px; margin: 0px -8px 0px 0px;
border-left: 4px solid rgba(128, 128, 128, 0); border-left: 0px solid rgba(128, 128, 128, 0);
border-right: 4px solid rgba(128, 128, 128, 0); border-right: 8px solid rgba(128, 128, 128, 0);
cursor: col-resize; cursor: col-resize;
} }
.Resizer.vertical::before { .Resizer.vertical::before {
content: '•••'; content: '•••';
margin-left: -6px; margin-left: -11px;
height: 100%; height: 3em;
margin-top: calc(50vh - 32px);
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
@@ -133,8 +134,8 @@
} }
.Resizer.vertical:hover { .Resizer.vertical:hover {
border-left: 4px solid rgba(130, 130, 130, 0.3); border-left: 0px solid rgba(130, 130, 130, 0.3);
border-right: 4px solid rgba(140, 140, 140, 0.3); border-right: 8px solid rgba(140, 140, 140, 0.3);
} }
.Resizer.disabled { .Resizer.disabled {

View File

@@ -11,7 +11,7 @@ function ChartTitle(props: { parameters: ChartParameters; classes: any }) {
</Typography> </Typography>
<br /> <br />
<Typography variant="caption" className={classes.topic}> <Typography variant="caption" className={classes.topic}>
{parameters.dotPath ? parameters.topic : ''} {parameters.dotPath ? parameters.topic : <span dangerouslySetInnerHTML={{ __html: '&nbsp;' }}></span>}
</Typography> </Typography>
</div> </div>
) )

View File

@@ -18,6 +18,7 @@ interface Props {
actions: { actions: {
chart: typeof chartActions chart: typeof chartActions
} }
classes: any
} }
function spacingForChartCount(count: number): 4 | 6 | 12 { function spacingForChartCount(count: number): 4 | 6 | 12 {
@@ -75,7 +76,7 @@ function ChartPanel(props: Props) {
)) ))
return ( return (
<div style={{ width: '100%', height: '100%', padding: '8px', flex: 1, overflow: 'hidden scroll' }}> <div className={props.classes.container}>
<Grid container spacing={1}> <Grid container spacing={1}>
<TransitionGroup component={null} className="example"> <TransitionGroup component={null} className="example">
{charts} {charts}
@@ -114,7 +115,16 @@ const mapDispatchToProps = (dispatch: any) => {
} }
} }
const styles = (theme: Theme) => ({}) const styles = (theme: Theme) => ({
container: {
backgroundColor: theme.palette.background.default,
width: '100%',
height: '100%',
padding: '8px',
flex: 1,
overflow: 'hidden scroll',
},
})
export default connect( export default connect(
mapStateToProps, mapStateToProps,

View File

@@ -18,17 +18,29 @@ interface Props {
function ContentView(props: Props) { function ContentView(props: Props) {
const [height, setHeight] = React.useState<string | number>('100%') const [height, setHeight] = React.useState<string | number>('100%')
const [sidebarWidth, setSidebarWidth] = React.useState<string | number>(500)
const [detectedHeight, setDetectedHeight] = React.useState(0) const [detectedHeight, setDetectedHeight] = React.useState(0)
const [detectedSidebarWidth, setDetectedSidebarWidth] = React.useState(0)
const detectSize = React.useCallback((width, newHeight) => { const detectSize = React.useCallback((width, newHeight) => {
setDetectedHeight(newHeight) setDetectedHeight(newHeight)
}, []) }, [])
const detectSidebarSize = React.useCallback(width => {
setDetectedSidebarWidth(width)
}, [])
const closeDrawerCompletelyIfItSitsOnTheEdge = React.useCallback(() => { const closeDrawerCompletelyIfItSitsOnTheEdge = React.useCallback(() => {
if (detectedHeight < 30) { if (detectedHeight < 30) {
setHeight('100%') setHeight('100%')
} }
}, [detectedHeight]) }, [detectedHeight])
const closeSidebarCompletelyIfItSitsOnTheEdge = React.useCallback(() => {
if (detectedSidebarWidth < 30) {
setSidebarWidth('0%')
}
}, [detectedSidebarWidth])
// Open chart panel on start and when a new chart is added but the panel is closed // Open chart panel on start and when a new chart is added but the panel is closed
React.useEffect(() => { React.useEffect(() => {
const almostClosed = !isNaN(height as any) && detectedHeight < 30 const almostClosed = !isNaN(height as any) && detectedHeight < 30
@@ -43,45 +55,56 @@ function ContentView(props: Props) {
return ( return (
<div className={props.paneDefaults}> <div className={props.paneDefaults}>
<ReactSplitPane <span>
step={10} <ReactSplitPane
split="horizontal" step={20}
minSize={0} primary="second"
size={height} className={props.heightProperty}
defaultSize={'100%'} split="vertical"
allowResize={true} minSize={0}
style={{ height: 'calc(100vh - 64px)' }} size={sidebarWidth}
pane1Style={{ maxHeight: '100%' }} onChange={setSidebarWidth}
pane2Style={{ borderTop: '1px solid #999', display: 'flex' }} onDragFinished={closeSidebarCompletelyIfItSitsOnTheEdge}
onChange={setHeight} defaultSize={500}
onDragFinished={closeDrawerCompletelyIfItSitsOnTheEdge} allowResize={true}
> style={{ height: '100%' }}
<span> pane1Style={{ overflowX: 'hidden' }}
<ReactSplitPane resizerStyle={{ height: '100%' }}
step={20} >
primary="second" <span>
className={props.heightProperty} <ReactSplitPane
split="vertical" step={10}
minSize={250} split="horizontal"
defaultSize={500} minSize={0}
allowResize={true} size={height}
style={{ height: '100%' }} defaultSize={'100%'}
pane1Style={{ overflowX: 'hidden' }} allowResize={true}
resizerStyle={{ height: '100%' }} style={{ height: 'calc(100vh - 64px)' }}
> pane1Style={{ maxHeight: '100%' }}
<Tree /> pane2Style={{ borderTop: '1px solid #999', display: 'flex' }}
<div className={props.paneDefaults} style={{ height: '100%', overflowY: 'auto', overflowX: 'hidden' }}> onChange={setHeight}
onDragFinished={closeDrawerCompletelyIfItSitsOnTheEdge}
>
<Tree />
{/** Passing height constraints via flex options down */}
<div style={{ flex: 1, display: 'flex', height: '100%', width: '100%' }}>
{/** Resize detector must not be in the scroll zone, it needs to detect actual available size */}
<ReactResizeDetector handleHeight={true} onResize={detectSize} />
<ChartPanel />
</div>
</ReactSplitPane>
</span>
<div>
<ReactResizeDetector handleWidth={true} onResize={detectSidebarSize} />
<div
className={props.paneDefaults}
style={{ minWidth: '250px', height: '100%', overflowY: 'auto', overflowX: 'hidden' }}
>
<Sidebar connectionId={props.connectionId} /> <Sidebar connectionId={props.connectionId} />
</div> </div>
</ReactSplitPane> </div>
</span> </ReactSplitPane>
{/** Passing height constraints via flex options down */} </span>
<div style={{ flex: 1, display: 'flex', height: '100%' }}>
{/** Resize detector must not be in the scroll zone, it needs to detect actual available size */}
<ReactResizeDetector handleHeight={true} onResize={detectSize} />
<ChartPanel />
</div>
</ReactSplitPane>
</div> </div>
) )
} }

View File

@@ -110,6 +110,7 @@ class TreeComponent extends React.PureComponent<Props, State> {
overflowY: 'scroll', overflowY: 'scroll',
overflowX: 'hidden', overflowX: 'hidden',
height: '100%', height: '100%',
width: '100%',
paddingBottom: '16px', // avoid conflict with chart panel Resizer paddingBottom: '16px', // avoid conflict with chart panel Resizer
} }