Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue API decorator improvements #1529

Closed
tmeasday opened this issue Jul 27, 2017 · 3 comments
Closed

Vue API decorator improvements #1529

tmeasday opened this issue Jul 27, 2017 · 3 comments

Comments

@tmeasday
Copy link
Member

tmeasday commented Jul 27, 2017

It's possible to write simple "DOM wrapping" decorators in the new Vue API, but a bit clunky:

addDecorator((storyFn, context) => {
  const options = storyFn();
  return {
     template: `<div class="foo">${options.template}</div>`,
     ...options,
  };
});

It would be cool if somehow we registered the story as story as per the Vue component API and allowed you to write instead:

addDecorator(() => ({
  template: `<div class="foo"><story/></div>`,
});

I'm not quite sure how to do that ;) but it seems conceptually possible anyway. Would love to hear thoughts.

@kazupon
Copy link
Member

kazupon commented Aug 3, 2017

Vue is possible to write simple DOM wrapping like story component due to be able to write HOC.
The below link helps us a lot:
vuejs/vue#6201

I'll try to support decorator for Vue.

@kazupon kazupon self-assigned this Aug 3, 2017
@tmeasday
Copy link
Member Author

tmeasday commented Aug 4, 2017

@kazupon am I right to say if we follow those patterns, we would want to get passed a Vue Component instance rather than a set of options (which is basically the input to new Component()), which is what is currently passed around?

I do wonder whether the storybook API should be something like:

.add('name', new Component(options));

Rather than:

.add('name', () => options);

I'm not really sure and far from a Vue expert, so of course I totally defer to your opinion here, just wanted to point something out about decorators that I noticed when working on knobs stuff.

@kazupon
Copy link
Member

kazupon commented Aug 26, 2017

close due to released v3.2.8

@kazupon kazupon closed this as completed Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants