From 4626d0d21d265be14b5a43b739955a84ca126af8 Mon Sep 17 00:00:00 2001 From: Alex Bratsos Date: Sat, 4 Jan 2020 00:18:22 +0200 Subject: [PATCH] Extract available shapes to one place --- src/index.tsx | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 9837a1e30..bdce49c91 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -479,6 +479,29 @@ const KEYS = { BACKSPACE: "Backspace" }; +const SHAPES = [ + { + label: "Rectange", + value: "rectangle" + }, + { + label: "Ellipse", + value: "ellipse" + }, + { + label: "Arrow", + value: "arrow" + }, + { + label: "Text", + value: "text" + }, + { + label: "Selection", + value: "selection" + } +]; + function isArrowKey(keyCode: string) { return ( keyCode === KEYS.ARROW_LEFT || @@ -619,11 +642,9 @@ class App extends React.Component<{}, AppState> { >
Shapes - {this.renderOption({ type: "rectangle", children: "Rectangle" })} - {this.renderOption({ type: "ellipse", children: "Ellipse" })} - {this.renderOption({ type: "arrow", children: "Arrow" })} - {this.renderOption({ type: "text", children: "Text" })} - {this.renderOption({ type: "selection", children: "Selection" })} + {SHAPES.map(shape => + this.renderOption({ type: shape.value, children: shape.label }) + )}