Skip to content

Commit 2953be4

Browse files
committed
docs(storybook-router): configured <Link> routing through story-router
1 parent d9db770 commit 2953be4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.storybook/addons.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';
23
import 'storybook-addon-specifications/register';

stories/resource-list.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {withInfo} from '@storybook/addon-info';
44
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
55
import {mount} from 'enzyme';
66
import {assert} from 'chai';
7-
import any from '@travi/any';
8-
import {storiesOf, specs} from '../.storybook/facade-storybook';
7+
import {storiesOf, linkTo, specs} from '../.storybook/facade-storybook';
98
import {describe, it} from '../.storybook/facade-mocha';
109
import ResourceList from '../src/resources/list/maybe-list';
1110

@@ -15,7 +14,10 @@ storiesOf('Resource List', module)
1514
{story()}
1615
</MuiThemeProvider>
1716
))
18-
.addDecorator(storyRouter())
17+
.addDecorator(storyRouter({
18+
'/users/travi': linkTo('Resource Details', 'person'),
19+
'/resources/generic': linkTo('Resource Details', 'generic resource')
20+
}))
1921
.add(
2022
'empty list',
2123
withInfo('this is the empty state')(() => {
@@ -44,9 +46,9 @@ storiesOf('Resource List', module)
4446
resourceType="rides"
4547
loading={false}
4648
resources={[
47-
{id: 1, displayName: 'corvette', links: {self: {href: any.url()}}},
48-
{id: 2, displayName: 'truck', links: {self: {href: any.url()}}},
49-
{id: 3, displayName: 'camaro', links: {self: {href: any.url()}}}
49+
{id: 1, displayName: 'corvette', links: {self: {href: '/resources/generic'}}},
50+
{id: 2, displayName: 'truck', links: {self: {href: '/resources/generic'}}},
51+
{id: 3, displayName: 'camaro', links: {self: {href: '/resources/generic'}}}
5052
]}
5153
/>
5254
))
@@ -62,7 +64,7 @@ storiesOf('Resource List', module)
6264
id: 1,
6365
displayName: 'Matt Travi',
6466
thumbnail: {src: 'https://www.gravatar.com/avatar/f69785efc7d990da20f1ab49fc2a6648?size=32'},
65-
links: {}
67+
links: {self: {href: '/users/travi'}}
6668
}
6769
]}
6870
/>

0 commit comments

Comments
 (0)