From 8bb7115fcf76c66e2496bb6481230abb24a079ab Mon Sep 17 00:00:00 2001 From: Daniel K Date: Thu, 7 Jul 2016 18:13:24 +0200 Subject: [PATCH] Make a description optional Sometimes it's completely viable to describe story with `storyName` only while being able to see additional details like source code and prop types. --- src/index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index e2f44c485fef..c8abf7e5ba48 100644 --- a/src/index.js +++ b/src/index.js @@ -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), @@ -27,7 +39,7 @@ export default { return ( - {storyFn(context)} + {_storyFn(context)} ); });