kitchen-simulator
Version:
It is a kitchen simulator (self-contained micro-frontend).
126 lines (122 loc) • 4.03 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import Viewer2D from "./viewer2d/viewer2d";
import Viewer3D from "./viewer3d/viewer3d";
import Viewer3DFirstPerson from "./viewer3d/viewer3d-first-person";
// import CatalogList from './catalog-view/catalog-list';
// import ProjectConfigurator from './configurator/project-configurator';
import * as constants from "../constants";
import Front3D from "./viewer3d/front3D";
export default function Content(_ref, _ref2) {
var width = _ref.width,
height = _ref.height,
state = _ref.state,
customContents = _ref.customContents,
match = _ref.match,
setToolbar = _ref.setToolbar,
replaceCabinet = _ref.replaceCabinet,
keyDownEnable = _ref.keyDownEnable,
catalog = _ref.catalog;
var projectActions = _ref2.projectActions;
var mode = state.get('mode');
switch (mode) {
// this mode is when view elevation
case constants.MODE_ELEVATION_VIEW:
return /*#__PURE__*/React.createElement(Front3D, {
state: state,
width: width,
height: height,
setToolbar: setToolbar,
replaceCabinet: replaceCabinet,
keyDownEnable: keyDownEnable,
catalog: catalog
});
case constants.MODE_3D_VIEW:
return /*#__PURE__*/React.createElement(Viewer3D, {
id: "viewer3D",
state: state,
width: width,
height: height,
setToolbar: setToolbar,
replaceCabinet: replaceCabinet,
keyDownEnable: keyDownEnable,
downloadFlag: false
});
case constants.MODE_3D_FIRST_PERSON:
return /*#__PURE__*/React.createElement(Viewer3DFirstPerson, {
state: state,
width: width,
height: height
});
// case constants.MODE_VIEWING_CATALOG:
// return (
// <CatalogList
// state={state}
// param={match}
// width={width}
// height={height}
// categoryData={this.props.categoryData}
// />
// );
case constants.MODE_IDLE:
case constants.MODE_2D_ZOOM_IN:
case constants.MODE_2D_ZOOM_OUT:
case constants.MODE_2D_PAN:
case constants.MODE_WAITING_DRAWING_LINE:
case constants.MODE_DRAGGING_LINE:
case constants.MODE_DRAGGING_VERTEX:
case constants.MODE_DRAGGING_ITEM:
case constants.MODE_DRAWING_LINE:
case constants.MODE_DRAWING_HOLE:
case constants.MODE_DRAWING_ITEM:
case constants.MODE_DRAGGING_HOLE:
case constants.MODE_ROTATING_ITEM:
return /*#__PURE__*/React.createElement(Viewer2D, {
state: state,
width: width,
height: height,
setToolbar: setToolbar,
replaceCabinet: replaceCabinet
});
case constants.MODE_ROTATING_ITEM_3D:
case constants.MODE_DRAGGING_ITEM_3D:
case constants.MODE_IDLE_3D:
case constants.MODE_DRAWING_ITEM_3D:
case constants.MODE_DRAWING_HOLE_3D:
case constants.MODE_DRAGGING_HOLE_3D:
return /*#__PURE__*/React.createElement(Viewer3D, {
id: "viewer3D",
state: state,
width: width,
height: height,
setToolbar: setToolbar,
replaceCabinet: replaceCabinet,
keyDownEnable: keyDownEnable,
downloadFlag: false
});
// case constants.MODE_CONFIGURING_PROJECT:
// return (
// <ProjectConfigurator width={width} height={height} state={state} />
// );
default:
if (customContents.hasOwnProperty(mode)) {
var CustomContent = customContents[mode];
return /*#__PURE__*/React.createElement(CustomContent, {
width: width,
height: height,
state: state
});
} else {
throw new Error("Mode ".concat(mode, " doesn't have a mapped content"));
}
}
}
Content.propTypes = {
state: PropTypes.object.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
replaceCabinet: PropTypes.func.isRequired
};
Content.contextTypes = {
projectActions: PropTypes.object.isRequired
};