-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Storybook UI * Setup channel for preview * Load addons from user or load default addons * Allow easy importing default set of addons For an example addons.js: ```js import '@kadira/storybook/addons'; import '@kadira/storybook-addon-hello/register'; ``` * Export correct action, linkTo functions * Rename pageBus to channel * Fix tests and lint errors * Update some comments.
- Loading branch information
Showing
23 changed files
with
267 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// We are not using this file inside this project. | ||
// But, this will be useful when a user is configuring it's own addons. | ||
// Then he can import this file to add default set of addons. | ||
require('./dist/server/addons'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
|
||
var _stringify2 = _interopRequireDefault(_stringify); | ||
|
||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
|
||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
|
||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
|
||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
|
||
var _uuid = require('uuid'); | ||
|
||
var _uuid2 = _interopRequireDefault(_uuid); | ||
|
||
var _pageBus = require('page-bus'); | ||
|
||
var _pageBus2 = _interopRequireDefault(_pageBus); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var Channel = function () { | ||
function Channel(dataId) { | ||
(0, _classCallCheck3.default)(this, Channel); | ||
|
||
this._dataId = dataId || _uuid2.default.v4(); | ||
this._pageBus = (0, _pageBus2.default)(); | ||
this._listeners = {}; | ||
} | ||
|
||
(0, _createClass3.default)(Channel, [{ | ||
key: 'getDataId', | ||
value: function getDataId() { | ||
return this._dataId; | ||
} | ||
}, { | ||
key: 'on', | ||
value: function on(type, handler) { | ||
var listener = function listener(p) { | ||
return handler(JSON.parse(p)); | ||
}; | ||
// TODO add listener to a map[handler]listener | ||
this._pageBus.on(this._dataId + '.' + type, listener); | ||
} | ||
}, { | ||
key: 'emit', | ||
value: function emit(type, data) { | ||
var payload = (0, _stringify2.default)(data); | ||
this._pageBus.emit(this._dataId + '.' + type, payload); | ||
} | ||
}, { | ||
key: 'removeListener', | ||
value: function removeListener() /* type, handler */{ | ||
// TODO get listener from a map[handler]listener | ||
// this._pageBus.removeListener(type, listener); | ||
} | ||
}]); | ||
return Channel; | ||
}(); | ||
|
||
exports.default = Channel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.