UNPKG

kitchen-simulator

Version:

It is a kitchen simulator (self-contained micro-frontend).

61 lines 2.45 kB
import React from 'react'; import { MODE_BACK_ELEVATION_VIEW, MODE_FRONT_ELEVATION_VIEW, MODE_LEFT_ELEVATION_VIEW, MODE_RIGHT_ELEVATION_VIEW } from "../../../constants"; import { convert } from "../../../utils/convert-units-lite"; export default function ItemRect(_ref) { var scene = _ref.scene, layer = _ref.layer, calcrect = _ref.calcrect, v0 = _ref.v0, v1 = _ref.v1, mode = _ref.mode, frontRect = _ref.frontRect, scale = _ref.scale, sideFlag = _ref.sideFlag; var rect = calcrect.rect; var x0 = v0.x, y0 = v0.y; var x1 = v1.x, y1 = v1.y; var translateY = frontRect.height / 2 - convert(Math.abs(calcrect.itemInfo.properties.altitude._length)).from(calcrect.itemInfo.properties.altitude._unit).to(layer.unit) * scale; var translateX = -frontRect.width / 2; var itemWidth = convert(calcrect.size.width).from(scene.unit).to(layer.unit) * scale; var itemDepth = convert(calcrect.size.depth).from(scene.unit).to(layer.unit) * scale; var itemHeight = convert(calcrect.size.height).from(scene.unit).to(layer.unit) * scale; switch (mode) { case MODE_FRONT_ELEVATION_VIEW: case MODE_BACK_ELEVATION_VIEW: translateX += convert(Math.abs(rect[3].x - x0)).from(scene.unit).to(layer.unit) * scale; break; case MODE_RIGHT_ELEVATION_VIEW: case MODE_LEFT_ELEVATION_VIEW: translateX += convert(Math.abs(rect[3].y - y1)).from(scene.unit).to(layer.unit) * scale; break; } var dimension; switch (sideFlag) { case 0: dimension = /*#__PURE__*/React.createElement("polygon", { points: "0,0 0,-".concat(itemHeight, " ").concat(itemWidth, ",-").concat(itemHeight, " ").concat(itemWidth, ",0"), fill: "none", stroke: "black" }); break; case 1: dimension = /*#__PURE__*/React.createElement("polygon", { points: "0,0 0,-".concat(itemHeight, " ").concat(itemDepth, ",-").concat(itemHeight, " ").concat(itemDepth, ",0"), fill: "none", stroke: "black" }); break; case 2: dimension = /*#__PURE__*/React.createElement("polygon", { points: "0,0 0,-".concat(itemHeight, " -").concat(itemDepth, ",-").concat(itemHeight, " -").concat(itemDepth, ",0"), fill: "none", stroke: "black" }); break; } return /*#__PURE__*/React.createElement("g", { transform: "translate(".concat(translateX, ", ").concat(translateY, ")") }, dimension); }