1 import PropTypes from 'prop-types';
2 import React from 'react';
4 const hasCorner = (a, b) =>
5 (hasWall(a) && hasWall(b)) || a === 'door' || b == 'door';
7 const hasWall = side => side && side !== 'open';
9 const wallType = side => side || 'open';
11 const Cell = ({ bottom, left, right, top, x, y }) =>
12 <g className="cell" transform={`translate(${x || 0}, ${y || 0})`}>
13 <rect className="background" x="-0.03125" y="-0.03125" width="1.03125" height="1.03125" />
15 <line className={`wall ${wallType(top)}`} x1="-0.03125" y1="0" x2="1.03125" y2="0" />
18 <line className={`wall ${wallType(right)}`} x1="1" y1="-0.03125" x2="1" y2="1.03125" />
21 <line className={`wall ${wallType(bottom)}`} x1="-0.03125" y1="1" x2="1.03125" y2="1" />
24 <line className={`wall ${wallType(left)}`} x1="0" y1="-0.03125" x2="0" y2="1.03125" />
26 {hasCorner(top, left) ?
27 <rect className="corner" x="-0.0625" y="-0.0625" width="0.125" height="0.125" />
29 {hasCorner(top, right) ?
30 <rect className="corner" x="0.9375" y="-0.0625" width="0.125" height="0.125" />
32 {hasCorner(bottom, left) ?
33 <rect className="corner" x="-0.0625" y="0.9375" width="0.125" height="0.125" />
35 {hasCorner(bottom, right) ?
36 <rect className="corner" x="0.9375" y="0.9375" width="0.125" height="0.125" />
41 bottom: PropTypes.string,
42 left: PropTypes.string,
43 right: PropTypes.string,
44 top: PropTypes.string,