Add stats for nerds (#2453)

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Lipis 2020-12-07 18:35:16 +02:00 committed by GitHub
parent 5cdb9bd2ed
commit dd993adc5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 361 additions and 33 deletions

View file

@ -175,6 +175,7 @@ import {
EVENT_SHAPE,
trackEvent,
} from "../analytics";
import { Stats } from "./Stats";
const { history } = createHistory();
@ -377,6 +378,13 @@ class App extends React.Component<ExcalidrawProps, AppState> {
lng={getLanguage().lng}
isCollaborating={this.props.isCollaborating || false}
/>
{this.state.showStats && (
<Stats
appState={this.state}
elements={this.scene.getElements()}
onClose={this.toggleStats}
/>
)}
<main>
<canvas
id="canvas"
@ -1133,6 +1141,15 @@ class App extends React.Component<ExcalidrawProps, AppState> {
});
};
toggleStats = () => {
if (!this.state.showStats) {
trackEvent(EVENT_DIALOG, "stats");
}
this.setState({
showStats: !this.state.showStats,
});
};
setScrollToCenter = (remoteElements: readonly ExcalidrawElement[]) => {
this.setState({
...calculateScrollCenter(
@ -3564,6 +3581,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
label: t("labels.toggleGridMode"),
action: this.toggleGridMode,
},
{
label: t("labels.toggleStats"),
action: this.toggleStats,
},
],
top: clientY,
left: clientX,