From 045daa83f6abdf687f8da2863cda7067bd0c2528 Mon Sep 17 00:00:00 2001 From: "Carter J. Bastian" Date: Sun, 5 Mar 2017 13:17:18 -0500 Subject: [PATCH] Add size as App state and Diagram props --- app/components/Canvas.js | 2 +- app/components/Diagram.js | 9 +++++---- app/containers/App.js | 13 ++++++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/components/Canvas.js b/app/components/Canvas.js index c52d3d3..0b4aee4 100644 --- a/app/components/Canvas.js +++ b/app/components/Canvas.js @@ -15,7 +15,7 @@ export default class Canvas extends Component { return (
- +
); } } diff --git a/app/components/Diagram.js b/app/components/Diagram.js index 249c8f1..0c3ed87 100644 --- a/app/components/Diagram.js +++ b/app/components/Diagram.js @@ -69,7 +69,7 @@ export default class Diagram extends Component { // Add this (x,y) location as an object to the blocks list in state let updatedBlocks = this.state.squares.slice(); // immutable lists in state - updatedBlocks.push({x: topLeftX, y:topLeftY}); + updatedBlocks.push({x: topLeftX, y:topLeftY, size:this.props.size}); this.setState({ circles: this.state.circles, @@ -81,7 +81,8 @@ export default class Diagram extends Component { if (this.props.shape == 'Circle') { // Add this (x,y) location as an object to the blocks list in state let updatedBlocks = this.state.circles.slice(); // immutable lists in state - updatedBlocks.push({x: topLeftX, y:topLeftY}); + // Circle size is measured in radius: divide by two + updatedBlocks.push({x: topLeftX, y:topLeftY, size:(this.props.size / 2)}); this.setState({ circles: updatedBlocks, @@ -103,7 +104,7 @@ export default class Diagram extends Component { this.state.squares.map(function(ele, pos) { return ( - + ); } }