Skip to content

Commit fc4e43d

Browse files
committed
enable inline story to show information in one screen
1 parent e2d2901 commit fc4e43d

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

.storybook/config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import 'babel-polyfill';
22
import svg4everybody from 'svg4everybody';
3-
import { configure, setAddon } from '@kadira/storybook';
4-
import infoAddon from '@kadira/react-storybook-addon-info';
3+
import { configure, setAddon, addDecorator } from '@kadira/storybook';
4+
import { withKnobs } from '@kadira/storybook-addon-knobs';
55
import { setAssetRoot } from '../src/scripts/util';
6+
import wrapContent from './wrapContent';
7+
import infoAddonWithDefaultOptions from './infoAddonWithDefaultOptions';
68

7-
setAddon(infoAddon);
9+
setAddon(infoAddonWithDefaultOptions);
10+
addDecorator(withKnobs);
11+
addDecorator(wrapContent());
812

913
if (/\.sbook\.io/.test(location.hostname)) {
1014
// As storybook hub cannot host the static files, use the externally hosted SLDS assets (CORS enabled)

.storybook/head.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
})();
1313
</script>
1414
<style>
15-
body {
16-
padding: 16px 56px 16px 16px;
15+
.content-wrapper {
16+
padding: 16px;
17+
}
18+
.content-wrapper > div > div:nth-child(2) {
19+
padding: 16px;
1720
}
1821
</style>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import infoAddon from '@kadira/react-storybook-addon-info';
2+
3+
const defaultOptions = {
4+
inline: true,
5+
styles(stylesheet) {
6+
return {
7+
...stylesheet,
8+
jsxInfoContent: {
9+
borderTop: '1px solid rgb(238, 238, 238)',
10+
marginTop: '25px',
11+
},
12+
infoPage: {
13+
padding: '16px',
14+
},
15+
infoContent: {
16+
marginTop: '10px',
17+
borderTop: '1px solid rgb(238, 238, 238)',
18+
padding: '16px 0',
19+
},
20+
};
21+
},
22+
};
23+
24+
export default {
25+
addWithInfo(storyName, info, storyFn, options) {
26+
return infoAddon.addWithInfo.call(this, storyName, info, storyFn, { ...defaultOptions, ...options });
27+
},
28+
};

.storybook/wrapContent.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import classnames from 'classnames';
3+
4+
export default function wrapContent(className) {
5+
return story => (
6+
<div className={ classnames('content-wrapper', className) }>{ story() }</div>
7+
);
8+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"uuid": "^2.0.2"
5050
},
5151
"devDependencies": {
52-
"@kadira/react-storybook-addon-info": "^3.3.0",
53-
"@kadira/storybook": "^2.35.1",
52+
"@kadira/react-storybook-addon-info": "^3.4.0",
53+
"@kadira/storybook": "^2.35.3",
5454
"@kadira/storybook-addon-knobs": "^1.7.1",
5555
"@kadira/storyshots": "^2.1.0",
5656
"@salesforce-ux/design-system": "^2.2.1",

0 commit comments

Comments
 (0)