support storybook 4 active property

This commit is contained in:
Nils Norman Haukås 2018-11-14 11:03:59 +01:00
parent fa0d8eb314
commit 3ebb222eae
No known key found for this signature in database
GPG key ID: BB8DD87F83E1359E
3 changed files with 14 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{
"name": "react-storybook-addon-static-markup",
"version": "0.1.0",
"version": "0.1.1",
"description": "",
"main": "index.js",
"scripts": {

View file

@ -89,13 +89,18 @@ var StaticMarkup = function (_React$Component) {
key: 'render',
value: function render() {
var markup = this.state.markup;
// setting it to true to support past
// versions of storybook, which might not
// have active property.
var _props$active = this.props.active,
active = _props$active === undefined ? true : _props$active;
return _react2.default.createElement(
return active ? _react2.default.createElement(
'div',
{ style: styles.markupPanel },
markup
);
) : null;
}
// This is some cleanup tasks when the StaticMarkup panel is unmounting.

View file

@ -40,12 +40,15 @@ class StaticMarkup extends React.Component {
render() {
const { markup } = this.state;
return (
// setting it to true to support past
// versions of storybook, which might not
// have active property.
const { active = true } = this.props
return active ? (
<div style={styles.markupPanel}>
{ markup }
</div>
);
) : null;
}
// This is some cleanup tasks when the StaticMarkup panel is unmounting.