From 1d8900d6eb8e23a2bfd33ed0510c71e13c3cac71 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Mon, 17 Jun 2019 23:27:16 +0200 Subject: [PATCH] Move chart panel below tree --- app/index.html | 13 +-- app/src/components/ChartPanel/ChartTitle.tsx | 2 +- app/src/components/ChartPanel/index.tsx | 14 ++- app/src/components/Layout/ContentView.tsx | 97 ++++++++++++-------- app/src/components/Tree/Tree.tsx | 1 + 5 files changed, 81 insertions(+), 46 deletions(-) diff --git a/app/index.html b/app/index.html index 128906a..fc57f92 100644 --- a/app/index.html +++ b/app/index.html @@ -114,15 +114,16 @@ .Resizer.vertical { width: 2px; margin: 0px -8px 0px 0px; - border-left: 4px solid rgba(128, 128, 128, 0); - border-right: 4px solid rgba(128, 128, 128, 0); + border-left: 0px solid rgba(128, 128, 128, 0); + border-right: 8px solid rgba(128, 128, 128, 0); cursor: col-resize; } .Resizer.vertical::before { content: '•••'; - margin-left: -6px; - height: 100%; + margin-left: -11px; + height: 3em; + margin-top: calc(50vh - 32px); display: inline-block; vertical-align: middle; text-align: center; @@ -133,8 +134,8 @@ } .Resizer.vertical:hover { - border-left: 4px solid rgba(130, 130, 130, 0.3); - border-right: 4px solid rgba(140, 140, 140, 0.3); + border-left: 0px solid rgba(130, 130, 130, 0.3); + border-right: 8px solid rgba(140, 140, 140, 0.3); } .Resizer.disabled { diff --git a/app/src/components/ChartPanel/ChartTitle.tsx b/app/src/components/ChartPanel/ChartTitle.tsx index 63cbc2b..ca42cf3 100644 --- a/app/src/components/ChartPanel/ChartTitle.tsx +++ b/app/src/components/ChartPanel/ChartTitle.tsx @@ -11,7 +11,7 @@ function ChartTitle(props: { parameters: ChartParameters; classes: any }) {
- {parameters.dotPath ? parameters.topic : ''} + {parameters.dotPath ? parameters.topic : } ) diff --git a/app/src/components/ChartPanel/index.tsx b/app/src/components/ChartPanel/index.tsx index 9b65479..49b6204 100644 --- a/app/src/components/ChartPanel/index.tsx +++ b/app/src/components/ChartPanel/index.tsx @@ -18,6 +18,7 @@ interface Props { actions: { chart: typeof chartActions } + classes: any } function spacingForChartCount(count: number): 4 | 6 | 12 { @@ -75,7 +76,7 @@ function ChartPanel(props: Props) { )) return ( -
+
{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( mapStateToProps, diff --git a/app/src/components/Layout/ContentView.tsx b/app/src/components/Layout/ContentView.tsx index 6383502..acec129 100644 --- a/app/src/components/Layout/ContentView.tsx +++ b/app/src/components/Layout/ContentView.tsx @@ -18,17 +18,29 @@ interface Props { function ContentView(props: Props) { const [height, setHeight] = React.useState('100%') + const [sidebarWidth, setSidebarWidth] = React.useState(500) const [detectedHeight, setDetectedHeight] = React.useState(0) + const [detectedSidebarWidth, setDetectedSidebarWidth] = React.useState(0) const detectSize = React.useCallback((width, newHeight) => { setDetectedHeight(newHeight) }, []) + const detectSidebarSize = React.useCallback(width => { + setDetectedSidebarWidth(width) + }, []) + const closeDrawerCompletelyIfItSitsOnTheEdge = React.useCallback(() => { if (detectedHeight < 30) { setHeight('100%') } }, [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 React.useEffect(() => { const almostClosed = !isNaN(height as any) && detectedHeight < 30 @@ -43,45 +55,56 @@ function ContentView(props: Props) { return (
- - - - -
+ + + + + + {/** Passing height constraints via flex options down */} +
+ {/** Resize detector must not be in the scroll zone, it needs to detect actual available size */} + + +
+
+
+
+ +
- - - {/** Passing height constraints via flex options down */} -
- {/** Resize detector must not be in the scroll zone, it needs to detect actual available size */} - - -
- +
+
+
) } diff --git a/app/src/components/Tree/Tree.tsx b/app/src/components/Tree/Tree.tsx index e4c7055..5037339 100644 --- a/app/src/components/Tree/Tree.tsx +++ b/app/src/components/Tree/Tree.tsx @@ -110,6 +110,7 @@ class TreeComponent extends React.PureComponent { overflowY: 'scroll', overflowX: 'hidden', height: '100%', + width: '100%', paddingBottom: '16px', // avoid conflict with chart panel Resizer }