mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-03-17 21:13:44 +00:00
Refactored App component from index.tsx
This commit is contained in:
40
src/app.tsx
Normal file
40
src/app.tsx
Normal file
@@ -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 (
|
||||
<div className="root">
|
||||
<Route
|
||||
component={(props: RouteComponentProps) => (
|
||||
<TopBar
|
||||
{...props}
|
||||
onPrint={() => this.chartViewRef && this.chartViewRef.print()}
|
||||
onDownloadSvg={() =>
|
||||
this.chartViewRef && this.chartViewRef.downloadSvg()
|
||||
}
|
||||
onDownloadPng={() =>
|
||||
this.chartViewRef && this.chartViewRef.downloadPng()
|
||||
}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Intro} />
|
||||
<Route
|
||||
exact
|
||||
path="/view"
|
||||
component={(props: RouteComponentProps) => (
|
||||
<ChartView {...props} ref={(ref) => (this.chartViewRef = ref!)} />
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user