From 900268ab27ca0814cf014d3eb1f607e3375ff4f3 Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Wed, 11 Jan 2017 12:28:45 +0000 Subject: [PATCH] allowing component directories to contain there own stories for storybook. A component directory should now contain index.js, story.js and readme.md --- ui/.storybook/config.js | 5 +++- ui/src/components/button/story.js | 27 ++++++++++++++++++++ ui/stories/index.js | 42 +++++++++++++++---------------- 3 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 ui/src/components/button/story.js diff --git a/ui/.storybook/config.js b/ui/.storybook/config.js index c00d9483..404a63a1 100644 --- a/ui/.storybook/config.js +++ b/ui/.storybook/config.js @@ -1,7 +1,10 @@ const { configure } = require('@kadira/storybook'); +const req = require.context('../src/components', true, /story.js$/) + function loadStories() { + req.keys().forEach((filename) => req(filename)); require('../stories'); } -configure(loadStories, module); +configure(loadStories, module); \ No newline at end of file diff --git a/ui/src/components/button/story.js b/ui/src/components/button/story.js new file mode 100644 index 00000000..08e4d381 --- /dev/null +++ b/ui/src/components/button/story.js @@ -0,0 +1,27 @@ +const React = require('react'); +const { + storiesOf +} = require('@kadira/storybook'); + +const Button = require('./'); + +storiesOf('Button', module) + .add('With text', () => ( + + )).add('Secondary', () => ( + + )).add('Disabled', () => ( + + )).add('Anchor', () => ( +
+ +
+ )); \ No newline at end of file diff --git a/ui/stories/index.js b/ui/stories/index.js index e9d1f274..31893971 100644 --- a/ui/stories/index.js +++ b/ui/stories/index.js @@ -7,7 +7,7 @@ const { const { Base, - Button, + // Button, Container, Checkbox, Row, @@ -178,26 +178,26 @@ storiesOf('Avatar', module) )); -storiesOf('Button', module) - .add('With text', () => ( - - )).add('Secondary', () => ( - - )).add('Disabled', () => ( - - )).add('Anchor', () => ( -
- -
- )); +// storiesOf('Button', module) +// .add('With text', () => ( +// +// )).add('Secondary', () => ( +// +// )).add('Disabled', () => ( +// +// )).add('Anchor', () => ( +//
+// +//
+// )); storiesOf('Checkbox', module) .add('Default', () => (