Skip to content

Commit a0ac0cd

Browse files
committed
Support Storybook v6
1 parent 63223a7 commit a0ac0cd

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

.storybook/stories.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,23 @@ import { withAdk, adkParams } from '../dev/withAdk';
1515
*/
1616

1717
addParameters(
18-
adkParams({ themes: ['theme1-aa', 'theme2-bb', 't3', 't4', 't5'], currentTheme: 0 })
18+
adkParams({
19+
themes: ['theme1-aa', 'theme2-bb', 't3', 't4', 't5'],
20+
currentTheme: 0,
21+
})
1922
);
2023

2124
storiesOf('Storybook Addon Development Kit', module)
2225
.addDecorator(withAdk({ mainColor: 'green' }))
2326
.add(
2427
'Stories',
25-
() => {
28+
storyArgs => {
2629
return (
2730
<div>
2831
<button>Button 1</button>
2932
</div>
3033
);
31-
},
34+
}
3235
// adkParams({ currentTheme: 1 })
3336
)
3437
.add(
@@ -39,7 +42,7 @@ storiesOf('Storybook Addon Development Kit', module)
3942
<button>Button 2</button>
4043
</div>
4144
);
42-
},
45+
}
4346
// adkParams({ currentTheme: 0 })
4447
);
4548
// .add('Details', () => (

dev/withAdk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const DecoratorUI = ({ context, getStory, theme, info }) => (
66
<div>
77
Theme: {theme} <br />
88
Data: {info} <br />
9-
{getStory(context)}
9+
{getStory({ customAddonArgs: { result: 'foo' } })}
1010
</div>
1111
);
1212

src/decorator.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,31 @@ export const createDecorator = (
6868
createActions,
6969
})(createHOC(paramSelectors));
7070

71+
const getStoryAndInjectParams = ctx => {
72+
const {
73+
argTypes,
74+
args,
75+
globals,
76+
hooks,
77+
id,
78+
kind,
79+
loaded,
80+
name,
81+
parameters,
82+
story,
83+
viewMode,
84+
...additionalArgs
85+
} = ctx || {};
86+
Object.assign(context.args, additionalArgs);
87+
return getStory(additionalArgs);
88+
};
89+
7190
return (
72-
<WithChannel getStory={getStory} context={context} Component={Component} />
91+
<WithChannel
92+
getStory={getStoryAndInjectParams}
93+
context={context}
94+
Component={Component}
95+
/>
7396
);
7497
};
7598

0 commit comments

Comments
 (0)