@storybook/addon-backgrounds
Advanced tools
Comparing version 4.0.0-alpha.4 to 4.0.0-alpha.6
@@ -53,2 +53,6 @@ 'use strict'; | ||
var _events = require('./events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
var _Swatch = require('./Swatch'); | ||
@@ -164,3 +168,3 @@ | ||
this.channel.on('background-set', function (backgrounds) { | ||
this.channel.on(_events2.default.SET, function (backgrounds) { | ||
_this2.setState({ backgrounds: backgrounds }); | ||
@@ -181,3 +185,3 @@ var currentBackground = api.getQueryParam('background'); | ||
this.channel.on('background-unset', function () { | ||
this.channel.on(_events2.default.UNSET, function () { | ||
_this2.setState({ backgrounds: [] }); | ||
@@ -184,0 +188,0 @@ _this2.updateIframe('none'); |
@@ -42,2 +42,6 @@ 'use strict'; | ||
var _events = require('./events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -70,3 +74,3 @@ | ||
value: function componentDidMount() { | ||
this.channel.emit('background-set', this.props.backgrounds); | ||
this.channel.emit(_events2.default.SET, this.props.backgrounds); | ||
} | ||
@@ -76,3 +80,3 @@ }, { | ||
value: function componentWillUnmount() { | ||
this.channel.emit('background-unset'); | ||
this.channel.emit(_events2.default.UNSET); | ||
} | ||
@@ -79,0 +83,0 @@ }, { |
@@ -24,7 +24,8 @@ 'use strict'; | ||
var _events = require('./events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** @jsx m */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
var BackgroundDecorator = exports.BackgroundDecorator = function () { | ||
@@ -54,3 +55,3 @@ function BackgroundDecorator(vnode) { | ||
value: function oncreate() { | ||
this.channel.emit('background-set', this.props.backgrounds); | ||
this.channel.emit(_events2.default.SET, this.props.backgrounds); | ||
} | ||
@@ -60,3 +61,3 @@ }, { | ||
value: function onremove() { | ||
this.channel.emit('background-unset'); | ||
this.channel.emit(_events2.default.UNSET); | ||
} | ||
@@ -70,4 +71,7 @@ }, { | ||
return BackgroundDecorator; | ||
}(); | ||
}(); /** @jsx m */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
exports.default = function (backgrounds) { | ||
@@ -74,0 +78,0 @@ return function (story) { |
@@ -13,2 +13,6 @@ 'use strict'; | ||
var _events = require('./events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -30,6 +34,6 @@ | ||
created: function created() { | ||
channel.emit('background-set', backgrounds); | ||
channel.emit(_events2.default.SET, backgrounds); | ||
}, | ||
beforeDestroy: function beforeDestroy() { | ||
channel.emit('background-unset'); | ||
channel.emit(_events2.default.UNSET); | ||
} | ||
@@ -36,0 +40,0 @@ }; |
{ | ||
"name": "@storybook/addon-backgrounds", | ||
"version": "4.0.0-alpha.4", | ||
"version": "4.0.0-alpha.6", | ||
"description": "A storybook addon to show different backgrounds for your preview", | ||
@@ -27,3 +27,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@storybook/addons": "4.0.0-alpha.4", | ||
"@storybook/addons": "4.0.0-alpha.6", | ||
"@storybook/core-events": "4.0.0-alpha.6", | ||
"babel-runtime": "^6.26.0", | ||
@@ -30,0 +31,0 @@ "global": "^4.3.2", |
@@ -6,2 +6,3 @@ import React from 'react'; | ||
import BackgroundPanel from '../BackgroundPanel'; | ||
import Events from '../events'; | ||
@@ -53,3 +54,3 @@ const backgrounds = [ | ||
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />); | ||
SpiedChannel.emit('background-set', backgrounds); | ||
SpiedChannel.emit(Events.SET, backgrounds); | ||
@@ -62,3 +63,3 @@ expect(mockedApi.getQueryParam).toBeCalledWith('background'); | ||
mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />); | ||
SpiedChannel.emit('background-unset', []); | ||
SpiedChannel.emit(Events.UNSET, []); | ||
@@ -71,3 +72,3 @@ expect(mockedApi.setQueryParams).not.toHaveBeenCalled(); | ||
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />); | ||
SpiedChannel.emit('background-set', backgrounds); | ||
SpiedChannel.emit(Events.SET, backgrounds); | ||
@@ -82,3 +83,3 @@ expect(backgroundPanel.state('backgrounds')).toEqual(backgrounds); | ||
const localBgs = [{ ...head, default: true }, ...tail]; | ||
SpiedChannel.emit('background-set', localBgs); | ||
SpiedChannel.emit(Events.SET, localBgs); | ||
@@ -101,3 +102,3 @@ expect(backgroundPanel.state('backgrounds')).toEqual(localBgs); | ||
}); | ||
SpiedChannel.emit('background-set', localBgs); | ||
SpiedChannel.emit(Events.SET, localBgs); | ||
@@ -115,3 +116,3 @@ expect(backgroundPanel.state('backgrounds')).toEqual(localBgs); | ||
const backgroundPanel = mount(<BackgroundPanel channel={SpiedChannel} api={mockedApi} />); | ||
SpiedChannel.emit('background-set', backgrounds); | ||
SpiedChannel.emit(Events.SET, backgrounds); | ||
@@ -121,3 +122,3 @@ expect(backgroundPanel.state('backgrounds')).toEqual(backgrounds); | ||
SpiedChannel.emit('background-unset'); | ||
SpiedChannel.emit(Events.UNSET); | ||
expect(backgroundPanel.state('backgrounds')).toHaveLength(0); | ||
@@ -124,0 +125,0 @@ }); |
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import EventEmitter from 'events'; | ||
import { BackgroundDecorator } from '../index'; | ||
import Events from '../events'; | ||
const EventEmitter = require('events'); | ||
const testStory = () => () => <p>Hello World!</p>; | ||
@@ -26,3 +26,3 @@ | ||
const spy = jest.fn(); | ||
SpiedChannel.on('background-unset', spy); | ||
SpiedChannel.on(Events.UNSET, spy); | ||
@@ -37,3 +37,3 @@ backgroundDecorator.unmount(); | ||
const spy = jest.fn(); | ||
SpiedChannel.on('background-set', spy); | ||
SpiedChannel.on(Events.SET, spy); | ||
@@ -40,0 +40,0 @@ shallow(<BackgroundDecorator story={testStory} channel={SpiedChannel} />); |
import Vue from 'vue'; | ||
import { vueHandler } from '../vue'; | ||
import Events from '../events'; | ||
describe('Vue handler', () => { | ||
@@ -40,4 +42,4 @@ it('Returns a component with a created function', () => { | ||
expect(testChannel.emit).toHaveBeenCalledTimes(1); | ||
expect(testChannel.emit).toHaveBeenCalledWith('background-set', expect.any(Array)); | ||
expect(testChannel.emit).toHaveBeenCalledWith(Events.SET, expect.any(Array)); | ||
}); | ||
}); |
@@ -6,2 +6,3 @@ import { document } from 'global'; | ||
import Events from './events'; | ||
import Swatch from './Swatch'; | ||
@@ -92,3 +93,3 @@ | ||
this.channel.on('background-set', backgrounds => { | ||
this.channel.on(Events.SET, backgrounds => { | ||
this.setState({ backgrounds }); | ||
@@ -105,3 +106,3 @@ const currentBackground = api.getQueryParam('background'); | ||
this.channel.on('background-unset', () => { | ||
this.channel.on(Events.UNSET, () => { | ||
this.setState({ backgrounds: [] }); | ||
@@ -108,0 +109,0 @@ this.updateIframe('none'); |
@@ -7,2 +7,4 @@ import React from 'react'; | ||
import Events from './events'; | ||
export class BackgroundDecorator extends React.Component { | ||
@@ -25,7 +27,7 @@ constructor(props) { | ||
componentDidMount() { | ||
this.channel.emit('background-set', this.props.backgrounds); | ||
this.channel.emit(Events.SET, this.props.backgrounds); | ||
} | ||
componentWillUnmount() { | ||
this.channel.emit('background-unset'); | ||
this.channel.emit(Events.UNSET); | ||
} | ||
@@ -32,0 +34,0 @@ |
@@ -8,2 +8,4 @@ /** @jsx m */ | ||
import Events from './events'; | ||
export class BackgroundDecorator { | ||
@@ -26,7 +28,7 @@ constructor(vnode) { | ||
oncreate() { | ||
this.channel.emit('background-set', this.props.backgrounds); | ||
this.channel.emit(Events.SET, this.props.backgrounds); | ||
} | ||
onremove() { | ||
this.channel.emit('background-unset'); | ||
this.channel.emit(Events.UNSET); | ||
} | ||
@@ -33,0 +35,0 @@ |
import addons from '@storybook/addons'; | ||
import Events from './events'; | ||
export const vueHandler = (channel, backgrounds) => (getStory, context) => ({ | ||
@@ -17,7 +19,7 @@ data() { | ||
created() { | ||
channel.emit('background-set', backgrounds); | ||
channel.emit(Events.SET, backgrounds); | ||
}, | ||
beforeDestroy() { | ||
channel.emit('background-unset'); | ||
channel.emit(Events.UNSET); | ||
}, | ||
@@ -24,0 +26,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42935
27
1061
7
+ Added@storybook/addons@4.0.0-alpha.6(transitive)
+ Added@storybook/channels@4.0.0-alpha.6(transitive)
+ Added@storybook/core-events@4.0.0-alpha.6(transitive)
- Removed@storybook/addons@4.0.0-alpha.4(transitive)
- Removed@storybook/channels@4.0.0-alpha.4(transitive)