kitchen-simulator
Version:
It is a kitchen simulator (self-contained micro-frontend).
73 lines (72 loc) • 2.33 kB
JavaScript
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React from 'react';
import PropTypes from 'prop-types';
import Scene from "./scene";
import Snap from "./snap";
import * as SharedStyle from "../../shared-style";
var guideStyle = {
stroke: SharedStyle.SECONDARY_COLOR.main,
strokewidth: '2.5px'
};
export default function State(_ref) {
var state = _ref.state,
catalog = _ref.catalog,
relatedLines = _ref.relatedLines;
var activeSnapElement = state.activeSnapElement,
snapElements = state.snapElements,
scene = state.scene;
var width = scene.width,
height = scene.height;
activeSnapElement = activeSnapElement ? /*#__PURE__*/React.createElement(Snap, {
snap: activeSnapElement,
width: scene.width,
height: scene.height
}) : null;
// snapElements = snapElements.map((snap,id) => <Snap key={id} snap={snap} width={scene.width} height={scene.height}/>);
snapElements = null; //only for debug purpose
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("rect", {
x: "0",
y: "0",
width: width,
height: height,
fill: SharedStyle.COLORS.white
}), /*#__PURE__*/React.createElement("g", {
transform: "translate(0, ".concat(scene.height, ") scale(1, -1)"),
id: "svg-drawing-paper"
}, /*#__PURE__*/React.createElement(Scene, {
scene: scene,
state: state,
catalog: catalog,
relatedLines: relatedLines
}), scene.getIn(['guides', 'horizontal']).entrySeq().map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
hgKey = _ref3[0],
hgVal = _ref3[1];
return /*#__PURE__*/React.createElement("line", {
id: 'hGuide' + hgKey,
key: hgKey,
x1: 0,
y1: hgVal,
x2: width,
y2: hgVal,
style: guideStyle
});
}), scene.getIn(['guides', 'vertical']).entrySeq().map(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
vgKey = _ref5[0],
vgVal = _ref5[1];
return /*#__PURE__*/React.createElement("line", {
key: vgKey,
x1: vgVal,
y1: 0,
x2: vgVal,
y2: height,
style: guideStyle
});
}), activeSnapElement, snapElements));
}
State.propTypes = {
state: PropTypes.object.isRequired,
catalog: PropTypes.object.isRequired,
relatedLines: PropTypes.object.isRequired
};