Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
docs(storybook): add widgets usage
Browse files Browse the repository at this point in the history
* docs(storybook): add jsx addon

* docs(storybook): add method to display correct component names

* docs(storybook): add jsx usage to the stories

* docs(storybook): update yarn.lock

* docs(storybook): modify webpack config to fix build-storybook fail

See storybookjs/storybook#1774

* docs(storybook): filter out unnecessary props

* docs(storybook): updates after reviews on PR
  • Loading branch information
marielaures authored and mthuret committed Nov 2, 2017
1 parent a3b233a commit fbf098f
Show file tree
Hide file tree
Showing 26 changed files with 1,586 additions and 814 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"rheostat": "2.1.1",
"sass-loader": "6.0.6",
"stat-mode": "0.2.2",
"storybook-addon-jsx": "5.0.0",
"string": "3.3.3",
"style-loader": "0.19.0",
"uglify-js": "3.0.25",
Expand Down
76 changes: 47 additions & 29 deletions stories/Breadcrumb.stories.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { setAddon, storiesOf } from '@storybook/react';
import {
Breadcrumb,
Panel,
HierarchicalMenu,
} from '../packages/react-instantsearch/dom';
import { connectHierarchicalMenu } from '../packages/react-instantsearch/connectors';
import { withKnobs, object, text } from '@storybook/addon-knobs';
import { WrapWithHits } from './util';
import { displayName, filterProps, WrapWithHits } from './util';
import JSXAddon from 'storybook-addon-jsx';

setAddon(JSXAddon);

const stories = storiesOf('Breadcrumb', module);
const VirtualHierarchicalMenu = connectHierarchicalMenu(() => null);

stories.addDecorator(withKnobs);

stories
.add('default', () => (
<div>
.addDecorator(withKnobs)
.addWithJSX(
'default',
() => (
<div>
<WrapWithHits hasPlayground={true} linkedStoryGroup="Breadcrumb">
<Breadcrumb
attributes={['category', 'sub_category', 'sub_sub_category']}
/>
<hr />
<HierarchicalMenu
attributes={['category', 'sub_category', 'sub_sub_category']}
defaultRefinement="Cooking > Kitchen textiles"
limitMax={3}
showMore={true}
/>
</WrapWithHits>
</div>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'with panel',
() => (
<WrapWithHits hasPlayground={true} linkedStoryGroup="Breadcrumb">
<Breadcrumb
attributes={['category', 'sub_category', 'sub_sub_category']}
/>
<Panel title="Category">
<Breadcrumb
attributes={['category', 'sub_category', 'sub_sub_category']}
separator=" / "
/>
</Panel>
<hr />
<HierarchicalMenu
attributes={['category', 'sub_category', 'sub_sub_category']}
defaultRefinement="Cooking > Kitchen textiles"
limitMax={3}
showMore={true}
defaultRefinement="Cooking > Bakeware"
/>
</WrapWithHits>
</div>
))
.add('with panel', () => (
<WrapWithHits hasPlayground={true} linkedStoryGroup="Breadcrumb">
<Panel title="Category">
<Breadcrumb
attributes={['category', 'sub_category', 'sub_sub_category']}
separator=" / "
/>
</Panel>
<hr />
<HierarchicalMenu
attributes={['category', 'sub_category', 'sub_sub_category']}
defaultRefinement="Cooking > Bakeware"
/>
</WrapWithHits>
))
),
{
displayName,
filterProps,
}
);

stories
.add('with custom component', () => (
<WrapWithHits hasPlayground={true} linkedStoryGroup="Breadcrumb">
<Breadcrumb
Expand Down
86 changes: 56 additions & 30 deletions stories/ClearAll.stories.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { setAddon, storiesOf } from '@storybook/react';
import { ClearAll, RefinementList } from '../packages/react-instantsearch/dom';
import { withKnobs } from '@storybook/addon-knobs';
import { WrapWithHits } from './util';
import { displayName, filterProps, WrapWithHits } from './util';
import JSXAddon from 'storybook-addon-jsx';

const stories = storiesOf('ClearAll', module);
setAddon(JSXAddon);

stories.addDecorator(withKnobs);
const stories = storiesOf('ClearAll', module);

stories
.add('with refinements to clear', () => (
<WrapWithHits linkedStoryGroup="ClearAll">
<div>
<ClearAll />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
.addDecorator(withKnobs)
.addWithJSX(
'with refinements to clear',
() => (
<WrapWithHits linkedStoryGroup="ClearAll">
<div>
<ClearAll />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
</div>
</div>
</div>
</WrapWithHits>
))
.add('nothing to clear', () => (
<WrapWithHits linkedStoryGroup="ClearAll">
<ClearAll />
</WrapWithHits>
))
.add('clear all refinements and the query', () => (
<WrapWithHits linkedStoryGroup="ClearAll">
<ClearAll
clearsQuery
translations={{ reset: 'Clear refinements and query' }}
/>
<RefinementList attributeName="category" defaultRefinement={['Dining']} />
</WrapWithHits>
));
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'nothing to clear',
() => (
<WrapWithHits linkedStoryGroup="ClearAll">
<ClearAll />
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'clear all refinements and the query',
() => (
<WrapWithHits linkedStoryGroup="ClearAll">
<ClearAll
clearsQuery
translations={{ reset: 'Clear refinements and query' }}
/>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
</WrapWithHits>
),
{
displayName,
filterProps,
}
);
118 changes: 74 additions & 44 deletions stories/CurrentRefinements.stories.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,91 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { setAddon, storiesOf } from '@storybook/react';
import {
CurrentRefinements,
RefinementList,
Toggle,
Panel,
} from '../packages/react-instantsearch/dom';
import { withKnobs } from '@storybook/addon-knobs';
import { WrapWithHits } from './util';
import { displayName, filterProps, WrapWithHits } from './util';
import JSXAddon from 'storybook-addon-jsx';
setAddon(JSXAddon);

const stories = storiesOf('CurrentRefinements', module);

stories.addDecorator(withKnobs);

stories
.add('default', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<div>
<CurrentRefinements />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
.addWithJSX(
'default',
() => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<div>
<CurrentRefinements />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
</div>
</div>
</div>
</WrapWithHits>
))
.add('with toggle', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<div>
<CurrentRefinements />
<Toggle
attributeName="materials"
label="Made with solid pine"
value={'Solid pine'}
/>
</div>
</WrapWithHits>
))
.add('with panel', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<Panel title="Current Refinements">
<CurrentRefinements />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'with toggle',
() => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<div>
<CurrentRefinements />
<Toggle
attributeName="materials"
label="Made with solid pine"
value={'Solid pine'}
/>
</div>
</Panel>
</WrapWithHits>
))
.add('with panel but no refinement', () => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<Panel title="Current Refinements">
<CurrentRefinements />
</Panel>
</WrapWithHits>
));
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'with panel',
() => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<Panel title="Current Refinements">
<CurrentRefinements />
<div style={{ display: 'none' }}>
<RefinementList
attributeName="category"
defaultRefinement={['Dining']}
/>
</div>
</Panel>
</WrapWithHits>
),
{
displayName,
filterProps,
}
)
.addWithJSX(
'with panel but no refinement',
() => (
<WrapWithHits linkedStoryGroup="CurrentRefinements">
<Panel title="Current Refinements">
<CurrentRefinements />
</Panel>
</WrapWithHits>
),
{
displayName,
filterProps,
}
);
Loading

0 comments on commit fbf098f

Please sign in to comment.