import * as React from 'react' import ChartPanel from '../ChartPanel' import ReactSplitPane from 'react-split-pane' import Tree from '../Tree/Tree' import { AppState } from '../../reducers' import { ChartParameters } from '../../reducers/Charts' import { connect } from 'react-redux' import { List } from 'immutable' import { Sidebar } from '../Sidebar' import ReactResizeDetector from 'react-resize-detector' interface Props { heightProperty: any paneDefaults: any connectionId?: string chartPanelItems: List } function ContentView(props: Props) { const [height, setHeight] = React.useState('100%') const [detectedHeight, setDetectedHeight] = React.useState(0) const [chatPanelItemCount, setChartPanelItemCount] = React.useState(props.chartPanelItems.count()) const detectSize = React.useCallback((width, height) => { console.log(width, height) setDetectedHeight(height) }, []) // Open chart panel on start and when a new chart is added but the panel is closed React.useEffect(() => { const almostAtFullHeight = !isNaN(height as any) && Math.abs(detectedHeight - (height as number)) < 20 if ((!height || height === '100%' || almostAtFullHeight) && props.chartPanelItems.count() > 0) { setHeight('calc(100% - 250px)') } if (props.chartPanelItems.count() === 0) { setHeight('100%') } setChartPanelItemCount(props.chartPanelItems.count()) }, [props.chartPanelItems]) return (
) } const mapStateToProps = (state: AppState) => { return { chartPanelItems: state.charts.get('charts'), } } export default connect(mapStateToProps)(ContentView)