Skip to content

Commit

Permalink
fix(Base): Allow width and height to be added to element for canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
HHogg committed Feb 18, 2019
1 parent 973657d commit 674cd76
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Base/Base.js
Expand Up @@ -78,7 +78,10 @@ export default class Base extends Component {
/** Applies display styling */ /** Applies display styling */
display: PropTypes.oneOf(['block', 'inline-block']), display: PropTypes.oneOf(['block', 'inline-block']),
/** Fixed height applied through inline styling */ /** Fixed height applied through inline styling */
height: PropTypes.string, height: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
/** Forwarded React ref function */ /** Forwarded React ref function */
innerRef: PropTypes.func, innerRef: PropTypes.func,
/** Margins applied for the global spacing variables */ /** Margins applied for the global spacing variables */
Expand All @@ -105,7 +108,10 @@ export default class Base extends Component {
*/ */
theme: PropTypes.oneOf(['day', 'night']), theme: PropTypes.oneOf(['day', 'night']),
/** Fixed width applied through inline styling */ /** Fixed width applied through inline styling */
width: PropTypes.string, width: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string,
]),
/** z-index number for layering elements. */ /** z-index number for layering elements. */
zIndex: PropTypes.string, zIndex: PropTypes.string,
}; };
Expand Down Expand Up @@ -164,6 +170,11 @@ export default class Base extends Component {
// refs for component compositions. // refs for component compositions.
rest[typeof Component === 'string' ? 'ref' : 'innerRef'] = innerRef; rest[typeof Component === 'string' ? 'ref' : 'innerRef'] = innerRef;


if (typeof Component === 'string' && Component === 'canvas') {
if (height) rest.height = height;
if (width) rest.width = width;
}

return ( return (
<Component { ...rest } <Component { ...rest }
className={ classes } className={ classes }
Expand Down

0 comments on commit 674cd76

Please sign in to comment.