Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Make a description optional #37

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ export default {
...defaultOptions,
..._options
};

this.add(storyName, (context) => {
let _info = info;
let _storyFn = storyFn;

if (typeof storyFn !== 'function') {
if (typeof info === 'function') {
_storyFn = info;
_info = '';
} else {
throw new Error('No story defining function has been specified');
}
}

const props = {
info,
_info,
context,
showInline: Boolean(options.inline),
showHeader: Boolean(options.header),
Expand All @@ -27,7 +39,7 @@ export default {

return (
<Story {...props}>
{storyFn(context)}
{_storyFn(context)}
</Story>
);
});
Expand Down