From b85c61a60b4866b12bc01eafd380ac2a3ea97b3a Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 20 Dec 2016 16:49:43 -0500 Subject: [PATCH] YAGNI: Remove clutter from GUI component --- src/components/gui/gui.jsx | 47 +++++++------------------------- src/lib/shape-from-prop-types.js | 13 --------- 2 files changed, 10 insertions(+), 50 deletions(-) delete mode 100644 src/lib/shape-from-prop-types.js diff --git a/src/components/gui/gui.jsx b/src/components/gui/gui.jsx index c929d9b4ee..77cc6b8d33 100644 --- a/src/components/gui/gui.jsx +++ b/src/components/gui/gui.jsx @@ -1,9 +1,6 @@ -const defaultsDeep = require('lodash.defaultsdeep'); const React = require('react'); const VM = require('scratch-vm'); -const shapeFromPropTypes = require('../../lib/shape-from-prop-types'); - const Blocks = require('../../containers/blocks.jsx'); const GreenFlag = require('../../containers/green-flag.jsx'); const TargetPane = require('../../containers/target-pane.jsx'); @@ -13,24 +10,15 @@ const StopAll = require('../../containers/stop-all.jsx'); const Box = require('../box/box.jsx'); const GUIComponent = props => { - let { + const { basePath, - blocksProps, children, - greenFlagProps, - targetPaneProps, - stageProps, - stopAllProps, - vm + vm, + ...componentProps } = props; - blocksProps = defaultsDeep({}, blocksProps, { - options: { - media: `${basePath}static/blocks-media/` - } - }); if (children) { return ( - + {children} ); @@ -40,6 +28,7 @@ const GUIComponent = props => { grow={1} height="100%" style={{overflow: 'hidden'}} + {...componentProps} > { /> { marginTop: 8 }} > - - + + @@ -97,21 +80,11 @@ const GUIComponent = props => { }; GUIComponent.propTypes = { basePath: React.PropTypes.string, - blocksProps: shapeFromPropTypes(Blocks.propTypes, {omit: ['vm']}), children: React.PropTypes.node, - greenFlagProps: shapeFromPropTypes(GreenFlag.propTypes, {omit: ['vm']}), - stageProps: shapeFromPropTypes(Stage.propTypes, {omit: ['vm']}), - stopAllProps: shapeFromPropTypes(StopAll.propTypes, {omit: ['vm']}), - targetPaneProps: shapeFromPropTypes(TargetPane.propTypes, {omit: ['vm']}), vm: React.PropTypes.instanceOf(VM) }; GUIComponent.defaultProps = { basePath: '/', - blocksProps: {}, - greenFlagProps: {}, - targetPaneProps: {}, - stageProps: {}, - stopAllProps: {}, vm: new VM() }; module.exports = GUIComponent; diff --git a/src/lib/shape-from-prop-types.js b/src/lib/shape-from-prop-types.js deleted file mode 100644 index 2d2415e1c8..0000000000 --- a/src/lib/shape-from-prop-types.js +++ /dev/null @@ -1,13 +0,0 @@ -const React = require('react'); - -module.exports = function shapeFromPropTypes (propTypes, opts) { - opts = Object.assign({}, opts, {omit: []}); - const shape = Object - .keys(propTypes) - .filter(key => opts.omit.indexOf(key) !== -1) - .reduce((newPropTypes, key) => { - newPropTypes[key] = propTypes[key]; - return newPropTypes; - }, {}); - return React.PropTypes.shape(shape); -};