mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
Rename to makeDecorator
This commit is contained in:
parent
b8f8acb398
commit
199098ccb0
@ -1,4 +1,4 @@
|
||||
import addons, { makeTransitionalDecorator } from '@storybook/addons';
|
||||
import addons, { makeDecorator } from '@storybook/addons';
|
||||
import marked from 'marked';
|
||||
|
||||
function renderMarkdown(text, options) {
|
||||
@ -6,7 +6,7 @@ function renderMarkdown(text, options) {
|
||||
return marked(text);
|
||||
}
|
||||
|
||||
export const withNotes = makeTransitionalDecorator({
|
||||
export const withNotes = makeDecorator({
|
||||
name: 'withNotes',
|
||||
parameterName: 'notes',
|
||||
wrapper: (getStory, context, { options, parameters }) => {
|
||||
|
@ -2,7 +2,7 @@
|
||||
import global from 'global';
|
||||
|
||||
export mockChannel from './storybook-channel-mock';
|
||||
export { makeTransitionalDecorator } from './transitional-decorator';
|
||||
export { makeDecorator } from './make-decorator';
|
||||
|
||||
export class AddonStore {
|
||||
constructor() {
|
||||
|
@ -6,8 +6,11 @@ import deprecate from 'util-deprecate';
|
||||
// And in the new, "parameterized" style:
|
||||
// .addDecorator(decorator)
|
||||
// .add('story', () => <Story />, { name: { parameters } });
|
||||
//
|
||||
// *And* in the older, but not deprecated, "pass options to decorator" style:
|
||||
// .addDecorator(decorator(options))
|
||||
|
||||
export const makeTransitionalDecorator = ({ name, parameterName, wrapper }) => {
|
||||
export const makeDecorator = ({ name, parameterName, wrapper }) => {
|
||||
const decorator = options => (getStory, context) => {
|
||||
const parameters = context.parameters && context.parameters[parameterName];
|
||||
|
||||
@ -25,7 +28,7 @@ export const makeTransitionalDecorator = ({ name, parameterName, wrapper }) => {
|
||||
|
||||
return (...innerArgs) => {
|
||||
// Used as [.]addDecorator(decorator(options))
|
||||
if (typeof innerArgs.length > 1) {
|
||||
if (innerArgs.length > 1) {
|
||||
return decorator(...args)(...innerArgs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user