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

Decorators for Vue stories #1653

Closed
miljan-aleksic opened this issue Aug 14, 2017 · 6 comments
Closed

Decorators for Vue stories #1653

miljan-aleksic opened this issue Aug 14, 2017 · 6 comments

Comments

@miljan-aleksic
Copy link

Hi, I wasn't able to make work decorators when using Vue Stories and the documentation only reference an react example.

Are those supported?

@kazupon
Copy link
Member

kazupon commented Aug 14, 2017

WIP now.
#1595

@kazupon
Copy link
Member

kazupon commented Aug 26, 2017

@kazupon kazupon closed this as completed Aug 26, 2017
@smiller171
Copy link

@kazupon I can't find any documentation for how to actually use decorators with Vue...

@adi-zz
Copy link

adi-zz commented Mar 15, 2018

@smiller171, for decorators with Vue, try:

// .storybook/stories/index.js 

import YourButton from 'path/to/YourButton.vue'

function Reded() {
  return {
    template: '<div style="color: red;"><story/></div>',
  }
}

storiesOf('YourButton', module)
  .addDecorator(Reded)
  .add('default form', () => ({
    components: {YourButton },
    template:   '<YourButton  />',
  }))

@belvederef
Copy link

This should be added to the documentation. It was actually an effort to find this here.

For anyone looking for a solution similar to the one shown in the docs, I solved with:

import { addDecorator } from '@storybook/vue';

// Decorator to center-align all stories
addDecorator(() => ({
  template: '<div style="textAlign: center"><story/></div>',
}));

@Inframatic
Copy link

@adi-zz This is good to add a decorator in my story but what about for pre-existing decorators in scss files.

For example, in Vue.js I have @import "~theme/colors.scss";, which returns me the error: Module parse failed: Unexpected character '@'

mercedesb added a commit to mercedesb/personal-site that referenced this issue Sep 28, 2019
* install storybook and addons

* Configure storybook

Base configuration: https://storybook.js.org/docs/guides/guide-vue/#step-3-create-the-config-file (see details)
Add SASS support: https://storybook.js.org/docs/configurations/custom-webpack-config/#full-control-mode
Global styles: storybookjs/storybook#1653 (comment)
Accessibility addon: https://github.com/storybookjs/storybook/tree/master/addons/a11y

* CTALink stories

* Blog List stories

* BlogListItem stories

* ContentColumn stories

* tweak styling

* HeroHeader stories

* Navigation stories

And fixed a11y issue with nav links' text

* start working on PageHeader stories

* cleaned up page header styles

* ReadingTime stories

* TalkList stories

* more tweaks

* fix tests
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

6 participants