import Path from '../path' import Point from '../point' import Snippet from '../snippet' import { getProps } from '../utils' const raiseEvent = (evt) => console.log('raiseEVent not implemtned', evt) const Part = props => { const { partName, part, app, gist, updateGist } = props const focusPoint = (point, i) => { const p = part.points[point] const pathString = `M ${p.x} ${part.topLeft.y} ` + `L ${p.x} ${part.bottomRight.y} ` + `M ${part.topLeft.x} ${p.y} ` + `L ${part.bottomRight.x} ${p.y} ` const classes = 'focus point c' + (i % 8) // Cycle through 8 colors return ( raiseEvent('clearFocus', { part: partName, type: 'points', name: point }) } /> ) } const focusCoords = (p, i) => { let pathString = `M ${p.x} ${part.topLeft.y} ` pathString += `L ${p.x} ${part.bottomRight.y} ` pathString += `M ${part.topLeft.x} ${p.y} ` pathString += `L ${part.bottomRight.x} ${p.y} ` let classes = 'focus coords c' + (i % 4) // Cycle through 4 CSS classes return ( raiseEvent('clearFocus', { partName: partName, type: 'coords', data: p }) } /> ) } let grid = gist.paperless ? ( ) : null let focus = [] //if (gist.debug) { // if (focus && typeof props.focus[props.name] !== 'undefined') { // for (let i in props.focus[props.name].points) // focus.push(focusPoint(props.focus[props.name].points[i], i)) // for (let i in props.focus[props.name].paths) { // let name = props.focus[props.name].paths[i] // focus.push( // // props.raiseEvent('clearFocus', { // part: props.name, // type: 'paths', // name // }) // } // /> // ) // } // for (let i in props.focus[props.name].coords) // focus.push(focusCoords(props.focus[props.name].coords[i], i)) // } //} return ( {grid} {Object.keys(part.paths).map((pathName) => ( ))} {Object.keys(props.part.points).map((name) => ( ))} {Object.keys(props.part.snippets).map((snippetName) => ( ))} {focus} ) } export default Part