all files / dist/ index.js

92.11% Statements 35/38
66.67% Branches 4/6
81.82% Functions 9/11
97.14% Lines 34/35
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                                  11× 11× 11×      
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var React = require("react");
var storybook_addons_1 = require("@kadira/storybook-addons");
var assign = require("object-assign");
var style = {
    wrapper: {
        overflow: "scroll",
        position: "fixed",
        top: 0,
        bottom: 0,
        right: 0,
        left: 0,
        transition: "background 0.25s ease-in-out",
        backgroundPosition: "center",
        backgroundSize: "cover",
        background: "transparent",
    },
};
var BackgroundDecorator = (function (_super) {
    __extends(BackgroundDecorator, _super);
    function BackgroundDecorator(props) {
        var _this = this;
        _super.call(this, props);
        this.state = { background: "transparent" };
        this.setBackground = function (background) { return _this.setState({ background: background }); };
        Eif (this.props.channel) {
            this.channel = this.props.channel;
        }
        else {
            this.channel = storybook_addons_1.default.getChannel();
        }
        this.story = this.props.story();
    }
    BackgroundDecorator.prototype.componentWillMount = function () {
        this.channel.on("background", this.setBackground);
        this.channel.emit("background-set", this.props.backgrounds);
    };
    BackgroundDecorator.prototype.componentWillReceiveProps = function (nextProps) {
        if (nextProps.story !== this.props.story) {
            this.story = nextProps.story();
        }
    };
    BackgroundDecorator.prototype.componentWillUnmount = function () {
        this.channel.removeListener("background", this.setBackground);
        this.channel.emit("background-unset");
    };
    BackgroundDecorator.prototype.render = function () {
        var styles = style.wrapper;
        styles.background = this.state.background;
        return React.createElement("div", {style: assign({}, styles)}, this.story);
    };
    return BackgroundDecorator;
}(React.Component));
exports.BackgroundDecorator = BackgroundDecorator;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = function (backgrounds) { return function (story) { return (React.createElement(BackgroundDecorator, {story: story, backgrounds: backgrounds})); }; };
//# sourceMappingURL=index.js.map