mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
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:
parent
5cdb9bd2ed
commit
dd993adc5c
15 changed files with 361 additions and 33 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue