Correctly apply react style object to the dom element renderer

This commit is contained in:
Paul Kaplan committed 2018-06-28 11:06:34 -04:00
1 parent bf025f53c8
commit eb2658e451
4 files changed
+19 -5

No files matched your search

+1
View File
@@ -110,6 +110,7 @@
"style-loader": "^0.21.0",
"svg-to-image": "1.1.3",
"text-encoding": "0.6.4",
"to-style": "1.3.3",
"uglifyjs-webpack-plugin": "^1.2.5",
"wav-encoder": "1.3.0",
"web-audio-test-api": "^0.5.2",
@@ -28,7 +28,6 @@ const StageWrapperComponent = function (props) {
{
isRendererSupported ?
<Stage
shrink={0}
stageSize={stageSize}
vm={vm}
/> :
+8 -2
View File
@@ -37,6 +37,10 @@ const StageComponent = props => {
[styles.stageWrapperOverlay]: isFullScreen,
[styles.withColorPicker]: !isFullScreen && isColorPicking
})}
style={{
minHeight: stageDimensions.height,
minWidth: stageDimensions.width
}}
onDoubleClick={onDoubleClick}
>
<DOMElementRenderer
@@ -45,8 +49,10 @@ const StageComponent = props => {
{[styles.stageOverlayContent]: isFullScreen}
)}
domElement={canvas}
height={stageDimensions.height}
width={stageDimensions.width}
style={{
height: stageDimensions.height,
width: stageDimensions.width
}}
{...boxProps}
/>
<Box className={styles.monitorWrapper}>
+10 -2
View File
@@ -1,6 +1,7 @@
import omit from 'lodash.omit';
import PropTypes from 'prop-types';
import React from 'react';
import Style from 'to-style';
/*
* DOMElementRenderer wraps a DOM element, allowing it to be
@@ -31,14 +32,21 @@ class DOMElementRenderer extends React.Component {
// Look at me, I'm the React now!
Object.assign(
this.props.domElement,
omit(this.props, ['domElement', 'children'])
omit(this.props, ['domElement', 'children', 'style'])
);
// Convert react style prop to dom element styling.
if (this.props.style) {
this.props.domElement.style = Style.string(this.props.style);
}
return <div ref={this.setContainer} />;
}
}
DOMElementRenderer.propTypes = {
domElement: PropTypes.instanceOf(Element).isRequired
domElement: PropTypes.instanceOf(Element).isRequired,
style: PropTypes.object // eslint-disable-line react/forbid-prop-types
};
export default DOMElementRenderer;