diff --git a/src/app.tsx b/src/app.tsx new file mode 100644 index 0000000..e8fd1e5 --- /dev/null +++ b/src/app.tsx @@ -0,0 +1,40 @@ +import * as React from 'react'; +import {ChartView} from './chart_view'; +import {Route, RouteComponentProps, Switch} from 'react-router-dom'; +import {Intro} from './intro'; +import {TopBar} from './top_bar'; + +export class App extends React.Component<{}, {}> { + chartViewRef?: ChartView; + + render() { + return ( +
+ ( + this.chartViewRef && this.chartViewRef.print()} + onDownloadSvg={() => + this.chartViewRef && this.chartViewRef.downloadSvg() + } + onDownloadPng={() => + this.chartViewRef && this.chartViewRef.downloadPng() + } + /> + )} + /> + + + ( + (this.chartViewRef = ref!)} /> + )} + /> + +
+ ); + } +} diff --git a/src/index.tsx b/src/index.tsx index 1e1cb62..ff0a6ed 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,17 +4,10 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; import messages_pl from './translations/pl.json'; import {addLocaleData} from 'react-intl'; +import {App} from './app'; import {detect} from 'detect-browser'; -import {ChartView} from './chart_view'; -import { - HashRouter as Router, - Route, - RouteComponentProps, - Switch, -} from 'react-router-dom'; +import {HashRouter as Router} from 'react-router-dom'; import {IntlProvider} from 'react-intl'; -import {Intro} from './intro'; -import {TopBar} from './top_bar'; import './index.css'; import 'semantic-ui-css/semantic.min.css'; @@ -27,8 +20,6 @@ const language = navigator.language && navigator.language.split(/[-_]/)[0]; const browser = detect(); -let chartViewRef: ChartView | null = null; - if (browser && browser.name === 'ie') { ReactDOM.render(

@@ -41,28 +32,7 @@ if (browser && browser.name === 'ie') { ReactDOM.render( -

- ( - chartViewRef && chartViewRef.print()} - onDownloadSvg={() => chartViewRef && chartViewRef.downloadSvg()} - onDownloadPng={() => chartViewRef && chartViewRef.downloadPng()} - /> - )} - /> - - - ( - (chartViewRef = ref)} /> - )} - /> - -
+ , document.querySelector('#root'),