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

Add storybook #99

Merged
merged 8 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import Base from 'terra-base';
import { configure, addDecorator } from '@storybook/react';

/* eslint-disable react/jsx-filename-extension */
addDecorator(story => <Base locale="en-US">{story()}</Base>);

/* eslint-disable global-require */
function loadStories() {
require('../packages/terra-consumer-nav/stories/Index.jsx');
require('../packages/terra-consumer-icon/stories/Index.jsx');
require('../packages/terra-consumer-layout/stories/Index.jsx');
}

configure(loadStories, module);
3 changes: 3 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
document.documentElement.setAttribute("dir", "ltr");
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

neat! will update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just found that it doesn't work for popup/modal rendered outside the Base tree. NavHelp looks like this after the change:
screen shot 2017-12-04 at 9 55 07 am
So we still need to put it in html tag

</script>
45 changes: 45 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('path');
const I18nAggregatorPlugin = require('terra-i18n-plugin');
const i18nSupportedLocales = require('terra-i18n/lib/i18nSupportedLocales');
const CustomProperties = require('postcss-custom-properties');
const rtl = require('postcss-rtl');

const customProperties = CustomProperties({ preserve: true, warnings: false });

module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [
customProperties,
rtl(),
],
},
},
'sass-loader',
],
},
],
},
plugins: [
new I18nAggregatorPlugin({
baseDirectory: path.resolve(__dirname, '../'),
translationsDirectoryRouters: ['packages'],
supportedLocales: i18nSupportedLocales,
}),
],
resolve: {
modules: [path.resolve(__dirname, '../aggregated-translations'), 'node_modules'],
},
};
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Cerner Corporation
- Muhammad M Khan [@Mahmud-Khan]
- Alex Bezek [@alex-bezek]
- Jim Pruetting [@jpruetting]
- Yaonan Zhong [@zhongyn]

[@mhemesath]: https://github.com/mhemesath
[@KevinJJackson]: https://github.com/KevinJJackson
Expand All @@ -15,3 +16,4 @@ Cerner Corporation
[@amf9t2]: https://github.com/amf9t2
[@Mahmud-Khan]:https://github.com/Mahmud-Khan
[@jpruetting]:https://github.com/jpruetting
[@zhongyn]:https://github.com/zhongyn
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@
"publish": "check-installed-dependencies && npm run compile && npm test && npm run props-table && lerna publish",
"start": "cd packages/terra-consumer-site && npm run start",
"start:express": "node scripts/express/app.js",
"storybook": "start-storybook -p 8081 -c .storybook",
"test": "npm run jest && npm run nightwatch"
},
"devDependencies": {
"@storybook/addon-actions": "^3.3.0-alpha.4",
"@storybook/react": "^3.2.14",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-jest": "^20.0.0",
Expand All @@ -72,6 +75,7 @@
"babel-preset-react": "^6.24.1",
"check-installed-dependencies": "^1.0.0",
"chromedriver": "^2.31.0",
"css-loader": "^0.28.7",
"danger": "^1.0.0",
"enzyme": "^2.8.2",
"enzyme-to-json": "^1.5.1",
Expand All @@ -87,19 +91,30 @@
"lerna": "2.0.0-rc.4",
"load-json-file": "^2.0.0",
"nightwatch": "^0.9.16",
"node-sass": "^4.6.0",
"postcss-custom-properties": "^6.2.0",
"postcss-loader": "^2.0.8",
"postcss-rtl": "^1.1.3",
"prop-types": "^15.6.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router": "^3.0.5",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^15.5.4",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.6",
"selenium-server-standalone-jar": "^3.4.0",
"shelljs": "^0.7.7",
"style-loader": "^0.19.0",
"stylelint": "~8.0.0",
"stylelint-config-sass-guidelines": "^3.0.0",
"stylelint-scss": "1.5.1",
"stylelint-suitcss": "^1.0.0",
"terra-base": "^2.6.1",
"terra-i18n": "^1.4.0",
"terra-i18n-plugin": "^1.9.0",
"terra-icon": "^1.13.0",
"terra-table": "^1.15.0",
"webpack": "^3.3.0",
"webpack-dev-server": "^2.5.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/terra-consumer-icon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"terra-toolkit": "^1.2.2"
},
"peerDependencies": {
"@storybook/react": "^3.2.14",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"terra-base": "^2.1.0"
Expand Down
105 changes: 105 additions & 0 deletions packages/terra-consumer-icon/stories/IconStatic.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// This file is autogenerated from scripts/src/generate-example
/* eslint-disable */
import React from 'react';
import Table from 'terra-table';
import IconColorIncentives from '../src/icon/IconColorIncentives';
import IconColorFootsteps from '../src/icon/IconColorFootsteps';
import IconColorRunning from '../src/icon/IconColorRunning';
import IconColorAward49 from '../src/icon/IconColorAward49';
import IconUiColor1CalendarGrid61 from '../src/icon/IconUiColor1CalendarGrid61';
import IconColorWeightScale from '../src/icon/IconColorWeightScale';
import IconColorPeakFlow from '../src/icon/IconColorPeakFlow';
import IconColorHeartRate from '../src/icon/IconColorHeartRate';
import IconColorBloodGlucose from '../src/icon/IconColorBloodGlucose';
import IconColorBloodPressure from '../src/icon/IconColorBloodPressure';
import IconColorPulseOximetry from '../src/icon/IconColorPulseOximetry';
const IconAll = () => (
<div> <Table isStriped={false} >
<Table.Header>
<Table.HeaderCell content={'SVG'} key={'svg'} />
<Table.HeaderCell content={'Concept'} key={'concept'} />
<Table.HeaderCell content={'Code'} key={'code'} />
</Table.Header>
<Table.Rows>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorIncentives height='2em' width='2em' /></td>
<td>color-incentives</td>
<td>
import IconColorIncentives from 'terra-consumer-icon/lib/icon/IconColorIncentives';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorFootsteps height='2em' width='2em' /></td>
<td>color-footsteps</td>
<td>
import IconColorFootsteps from 'terra-consumer-icon/lib/icon/IconColorFootsteps';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorRunning height='2em' width='2em' /></td>
<td>color-running</td>
<td>
import IconColorRunning from 'terra-consumer-icon/lib/icon/IconColorRunning';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorAward49 height='2em' width='2em' /></td>
<td>color_award-49</td>
<td>
import IconColorAward49 from 'terra-consumer-icon/lib/icon/IconColorAward49';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconUiColor1CalendarGrid61 height='2em' width='2em' /></td>
<td>ui-color-1_calendar-grid-61</td>
<td>
import IconUiColor1CalendarGrid61 from 'terra-consumer-icon/lib/icon/IconUiColor1CalendarGrid61';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorWeightScale height='2em' width='2em' /></td>
<td>color-weight-scale</td>
<td>
import IconColorWeightScale from 'terra-consumer-icon/lib/icon/IconColorWeightScale';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorPeakFlow height='2em' width='2em' /></td>
<td>color-peak-flow</td>
<td>
import IconColorPeakFlow from 'terra-consumer-icon/lib/icon/IconColorPeakFlow';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorHeartRate height='2em' width='2em' /></td>
<td>color-heart-rate</td>
<td>
import IconColorHeartRate from 'terra-consumer-icon/lib/icon/IconColorHeartRate';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorBloodGlucose height='2em' width='2em' /></td>
<td>color-blood-glucose</td>
<td>
import IconColorBloodGlucose from 'terra-consumer-icon/lib/icon/IconColorBloodGlucose';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorBloodPressure height='2em' width='2em' /></td>
<td>color-blood-pressure</td>
<td>
import IconColorBloodPressure from 'terra-consumer-icon/lib/icon/IconColorBloodPressure';
</td>
</tr>
<tr style={{ backgroundColor: '#EEEEEE' }}>
<td><IconColorPulseOximetry height='2em' width='2em' /></td>
<td>color-pulse-oximetry</td>
<td>
import IconColorPulseOximetry from 'terra-consumer-icon/lib/icon/IconColorPulseOximetry';
</td>
</tr>
</Table.Rows>
</Table>
</div>);

export default IconAll;
Loading