From fd6b5024c7b00d5534fe1c1ab61dff32b2b2aea8 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Sun, 5 Jan 2020 14:45:16 -0800 Subject: [PATCH] Reorganize menu (#178) --- src/components/EditableText.tsx | 7 ++- src/index.tsx | 87 ++++++++++++++++++--------------- src/utils/index.ts | 11 ----- 3 files changed, 53 insertions(+), 52 deletions(-) delete mode 100644 src/utils/index.ts diff --git a/src/components/EditableText.tsx b/src/components/EditableText.tsx index cf32d6de..0f767726 100644 --- a/src/components/EditableText.tsx +++ b/src/components/EditableText.tsx @@ -20,7 +20,7 @@ export default class EditableText extends Component { }; } - componentWillReceiveProps(props: Props) { + UNSAFE_componentWillReceiveProps(props: Props) { this.setState({ value: props.value }); } @@ -52,6 +52,11 @@ export default class EditableText extends Component { value={value} onChange={e => this.handleEdit(e)} onBlur={() => this.handleBlur()} + onKeyDown={e => { + if (e.key === "Enter") { + this.handleBlur(); + } + }} autoFocus /> ) : ( diff --git a/src/index.tsx b/src/index.tsx index 5fa3060f..8aeac933 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,7 +7,6 @@ import { SketchPicker } from "react-color"; import { moveOneLeft, moveAllLeft, moveOneRight, moveAllRight } from "./zindex"; import { roundRect } from "./roundRect"; import EditableText from "./components/EditableText"; -import { getDateTime } from "./utils"; import "./styles.scss"; @@ -655,6 +654,18 @@ function rotate(x1: number, y1: number, x2: number, y2: number, angle: number) { ]; } +function getDateTime() { + const date = new Date(); + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); + const hr = date.getHours(); + const min = date.getMinutes(); + const secs = date.getSeconds(); + + return `${year}${month}${day}${hr}${min}${secs}`; +} + // Casting second argument (DrawingSurface) to any, // because it is requred by TS definitions and not required at runtime const generator = rough.generator(null, null as any); @@ -1211,9 +1222,21 @@ class App extends React.Component<{}, AppState> { ))} -

Colors

+ {someElementIsSelected() && ( + <> +

Selected Shapes

+
+ + + + + +
+ + )} +

Canvas

-
Canvas Background
+
Canvas Background Color
- {this.state.currentColorPicker === ColorPicker.CANVAS_BACKGROUND ? ( + /> + {this.state.currentColorPicker === + ColorPicker.CANVAS_BACKGROUND ? (
this.setState({ currentColorPicker: null })} - >
+ /> { @@ -1252,7 +1276,7 @@ class App extends React.Component<{}, AppState> { } />
-
Shape Stroke
+
Shape Stroke Color
+ /> {this.state.currentColorPicker === ColorPicker.SHAPE_STROKE ? (
this.setState({ currentColorPicker: null })} - >
+ /> { @@ -1291,7 +1315,7 @@ class App extends React.Component<{}, AppState> { }} />
-
Shape Background
+
Shape Background Color
- {this.state.currentColorPicker === ColorPicker.SHAPE_BACKGROUND ? ( + /> + {this.state.currentColorPicker === + ColorPicker.SHAPE_BACKGROUND ? (
this.setState({ currentColorPicker: null })} - >
+ /> { @@ -1330,9 +1355,6 @@ class App extends React.Component<{}, AppState> { }} />
-
-

Canvas

-

Export

+
Name
+ {this.state.name && ( + this.updateProjectName(name)} + /> + )} +
Image
-

Project name

-
- {this.state.name && ( - this.updateProjectName(name)} - /> - )} -
-

Save/Load

-
+
Scene
- {someElementIsSelected() && ( - <> -

Shape options

-
- - - - - -
- - )}
{ - const date = new Date(); - const year = date.getFullYear(); - const month = date.getMonth() + 1; - const day = date.getDate(); - const hr = date.getHours(); - const min = date.getMinutes(); - const secs = date.getSeconds(); - - return `${year}${month}${day}${hr}${min}${secs}`; -};