From ea3eb63971ca80634ed78436915b255d588c2623 Mon Sep 17 00:00:00 2001 From: "Carter J. Bastian" Date: Sat, 4 Mar 2017 12:18:19 -0500 Subject: [PATCH] Remove bootstrapped background colors --- app/components/Canvas.js | 2 +- app/components/Diagram.js | 61 +++++++++++++++++++++++++++++++++++++-- app/components/DotGrid.js | 4 +-- app/containers/App.js | 4 +-- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/app/components/Canvas.js b/app/components/Canvas.js index 7db8fbc..a5466fb 100644 --- a/app/components/Canvas.js +++ b/app/components/Canvas.js @@ -9,7 +9,7 @@ import Diagram from './Diagram' export default class Canvas extends Component { render() { return ( -
+
); diff --git a/app/components/Diagram.js b/app/components/Diagram.js index ffea242..3d2d9f2 100644 --- a/app/components/Diagram.js +++ b/app/components/Diagram.js @@ -1,14 +1,71 @@ // @flow import React, { Component } from 'react'; +import ReactDom from 'react-dom'; var ReactDOM = require('react-dom'); var electron = require('electron'); -// const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path,Line} = require('react-raphael'); +const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path,Line} = require('react-raphael'); export default class Diagram extends Component { + constructor(props) { + super (props); + + this.state = { + blocks: [], // Top-left (x,y) coordinates of each block in the diagram + connections: [], // Start and end IDs of connection points + }; + + this.handleClick = this.handleClick.bind(this); + }; + + handleClick(e) { + // On a click, add a block to the diagram on the click location + e.preventDefault(); + + // Find the location of the nearest click + const clickX = e.clientX; + const clickY = e.clientY; + + // Find the location of this click relative to the element itself + const topLeftX = clickX; + const topLeftY = clickY; + + console.log(topLeftX); + console.log(topLeftY); + // Add this (x,y) location as an object to the blocks list in state + let updatedBlocks = this.state.blocks.slice(); // immutable lists in state + updatedBlocks.push({x: topLeftX, y:topLeftY}); + + this.setState({ + blocks: updatedBlocks, + connections: this.state.connections, + }); + + console.log(updatedBlocks); // Debugging + }; + render() { return ( -
+
+ + + { + this.state.blocks.map(function(ele, pos) { + return ( + + ) + }) + } + +
); } diff --git a/app/components/DotGrid.js b/app/components/DotGrid.js index bc21768..8c44c2c 100644 --- a/app/components/DotGrid.js +++ b/app/components/DotGrid.js @@ -3,13 +3,11 @@ import React, { Component } from 'react'; var ReactDOM = require('react-dom'); var electron = require('electron'); -// const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path,Line} = require('react-raphael'); - export default class DotGrid extends Component { render() { // Use a SVG patter to create a DotGrid return ( -
+
diff --git a/app/containers/App.js b/app/containers/App.js index 2766fe2..6667d83 100644 --- a/app/containers/App.js +++ b/app/containers/App.js @@ -6,8 +6,6 @@ var electron = require('electron'); import Canvas from '../components/Canvas'; import ShapeBar from '../components/ShapeBar'; -// const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path,Line} = require('react-raphael'); - export default class App extends Component { props: { children: HTMLElement; @@ -19,7 +17,7 @@ export default class App extends Component { render() { return ( -
+
);