Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Link story fix #49

Merged
merged 5 commits into from
Feb 17, 2017
Merged

Link story fix #49

merged 5 commits into from
Feb 17, 2017

Conversation

takarzyna
Copy link
Contributor

A fix proposition for Link component story, as well as other links in the Storybook - if we don't want them to throw an error after clicking.
Based on: storybookjs/storybook#485 (comment)

Right now I don't think we can use it like react-router's Link and avoid the need of specifying labels in the "label" parameter, though.

Katarzyna Tumidajewicz added 3 commits February 7, 2017 15:44
@@ -123,6 +122,7 @@
"webpack-node-externals": "^1.5.4"
},
"dependencies": {
"@kadira/storybook": "^2.21.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required by changes in storybook/rr.js and storybook/webpack.config.js

@@ -1,7 +1,7 @@
import React from 'react'
import { List, ListItem } from 'material-ui/List'
import Divider from 'material-ui/Divider'
import { Link } from 'react-router'
import Link from 'components/Link'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes in this file were done mostly to test using link in another component. I can drop the changes in this file if you wish.


module.exports = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried adding the loaders to the config, but they produce errors. I don't see where could they be needed. Are they needed?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running the storybook. A lot of Module build failed: Unknown word errors appear.

This is the code I use to add the loaders:

newConfig.module.loaders.push({
    test: /\.css$/,
    loader: 'style!css?localIdentName=[local]___[hash:base64:5]',
  })
  newConfig.module.loaders.push({
    test: /\.png$/,
    loader: 'url-loader',
    query: { mimetype: 'image/png' },
  })

@takarzyna takarzyna requested review from mariangemarcano, kwi-dk, wsprent, kkateq and henriksunity and removed request for kwi-dk February 13, 2017 10:21

module.exports = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly doesn't work?

// This is just the basic way to add addional webpack configurations.
// For more information refer the docs: https://goo.gl/qPbSyX
// load the default config generator.
const genDefaultConfig = require('@kadira/storybook/dist/server/config/defaults/webpack.config.js')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add the default configurations here, you should be able resolve aliases without default storybook config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just discovered that the errors I was getting earlier disappear if I return the config without creating a const newConfig. I'll prepare a new commit

// this is used by the custom `rr.js` module
newConfig.resolve.alias['react-router-original'] = require.resolve('react-router')
// this `rr.js` will replace the Link with a our own mock component
newConfig.resolve.alias['react-router'] = require.resolve('./rr.js')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename rr.js file to something maybe react-router.js ?

@takarzyna takarzyna merged commit de14e3c into master Feb 17, 2017
@takarzyna takarzyna deleted the LinkStoryFix branch February 17, 2017 12:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants