Skip to content

Commit

Permalink
Add (P)react Storybook. (forem#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline authored and maestromac committed Mar 26, 2018
1 parent 447a134 commit 6a8df8c
Show file tree
Hide file tree
Showing 8 changed files with 4,914 additions and 82 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ latest.dump
/public/packs
/public/packs-test
/node_modules

# Ignore storybook static site generation
storybook-static/
2 changes: 2 additions & 0 deletions app/javascript/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
9 changes: 9 additions & 0 deletions app/javascript/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@storybook/react';

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.js$/);
function loadStories() {
req.keys().forEach((filename) => req(filename));
}

configure(loadStories, module);
9 changes: 9 additions & 0 deletions app/javascript/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
resolve: {
extensions: [".js", "jsx"],
alias: {
react: "preact-compat",
"react-dom": "preact-compat"
}
}
};
13 changes: 13 additions & 0 deletions app/javascript/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { h } from "preact";

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';

import { Button, Welcome } from '@storybook/react/demo';

storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Button', module)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
Loading

0 comments on commit 6a8df8c

Please sign in to comment.