-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
Generated by 🚫 dangerJS |
I prefer that the stories live in the package of each component. We can then use story discovery to pull all the stories into storybook. e.g https://github.com/cerner/terra-core/blob/storybook/.storybook/config.js |
Can we update the the deployment to run storybook rather than site? I want to remove the site, but we can do that in a subsequent pull request when we switch everything to webdriver.io and storybook |
@mhemesath Storybook just added a feature to autoload all files with |
@mhemesath putting the stories in the package of each component works for most components except those with translations. In this PR, all stories and story configs are inside the storybook folder and isolate from the outside.
so it can install terra-consumer-nav and add terra-i18n-plugin in its own node_modules. terra-in8-plugin then aggregates the translations by searching the node_modules folder. i18n is required for component like NavHelp. In the terra-badge example, the structure is:
That works. In the case of terra-alert with translations, it requires adding webpack.config.js with terra-i18n-plugin inside .storybook, and it will try to search the root level node_modules for translations folder. That means terra-alert should be added as devDependency in the root level. Not sure if that's appropriate. Any idea for handling this case? |
yes, will update the deployment to run storybook after this PR |
That plugin is only needed for aggregation. Do we need aggregation with storybook? Why can't the component find the translations relative to its directory. If we do need i18n plugin, can the source folder be modified it uses to search for translations? |
I am really adamant about having the stories of the components live in each package if possible. |
yes, terra-consumer-nav depends on terra-i18n, and i18n loads translation files from the aggregation folder. i18n-plugin generates the aggregation. Without the aggregation folder webpack compile will fail. One solution is creating the aggregation manually with empty message. If so terra-i18n will work but no message is pulled in the component.
terra-i18n at the root level pulls in the translations. The component itself doesn't load the translations.
i18n plugin only checks the node_modules for translation files. We can update it to take a custom path param so that it can search any custom folder |
I created an issue in terra-core for extending i18n plugin with custom search path: cerner/terra-core#998 |
package.json
Outdated
"terra-i18n": "^1.4.0", | ||
"terra-i18n-plugin": "file:../terra-core/packages/terra-i18n-plugin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for local dev, after this PR is merged we can update it with the new version
656be3a
to
388410a
Compare
package.json
Outdated
"test": "npm run jest && npm run nightwatch" | ||
}, | ||
"devDependencies": { | ||
"@storybook/addon-actions": "^3.2.14", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to update to 3.3.0-alpha.4
. Version 3.2
had issues with loading JSONP which is needed for requiring translations. This issue was fixed in v3.3.0 alphas. More info: storybookjs/storybook#1411
@@ -0,0 +1,3 @@ | |||
<script> | |||
document.documentElement.setAttribute("dir", "ltr"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably just do this in your main decorator
addDecorator(story => <div dir="ltr"><Base locale="en-US">{story()}</Base></div>);
Terra might log a warning, but the attribute will still work even if its not on HTML tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat! will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.storybook/webpack.config.js
Outdated
const rtl = require('postcss-rtl'); | ||
|
||
const customProperties = CustomProperties({ preserve: true, warnings: false }); | ||
customProperties.setVariables({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this duplicated from our other webpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's copied from terra-consumer-site webpack config. Probably it's not necessary, will remove it and test the code
Summary
Setup storybook as doc site, migrate nav/layout/icon examples to storybook