Giter Site home page Giter Site logo

vue-cli-plugin-vuetify-storybook's Introduction

vue-cli-plugin-vuetify-storybook

A Vuetify Storybook Plugin for vue-cli

โš  Archived

This package has been moved to the main vue-cli-plugins repository.

๐Ÿ’ช Supporting Vuetify

Vuetify is an open source MIT project that has been made possible due to the generous contributions by community backers. If you are interested in supporting this project, please consider:

๐Ÿ“‘ License

MIT

Copyright (c) 2016-present Vuetify LLC

vue-cli-plugin-vuetify-storybook's People

Contributors

johnleider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

morphatic

vue-cli-plugin-vuetify-storybook's Issues

Idea: Add global knobs to toggle/edit $vuetify props in stories

In .storybook/addon-vuetify/decorator.js I added a knob to toggle the theme like so:

// inside of the `wrapper()` function
return Vue.extend({
  vuetify,
  components: { WrappedComponent },
  props: {
    dark: {
      default: boolean('Dark Theme', false), // or options.theme.dark see #2 
    },
  },
  watch: {
    dark (val) {
      this.$vuetify.theme.dark = val
    },
  },
  template: `
    <v-app>
      <v-container fluid>
        <wrapped-component />
      </v-container>
    </v-app>
  `
})

Now in all of my stories, there's a knob that allows me to toggle Vuetify's dark theme on and off to see what components look like in those scenarios. Here are some screenshots:

Vuetify with default light theme
Vuetify with dark theme toggled on

Dunno if this kinda thing should be baked into the addon or not, but I thought it was a neat trick that I'd share.

Idea: Maybe import vuetify options directly from app

This is a change I made to my app's addon-vuetify designed to import all of my app's custom theme options.

I modified my app's plugins/vuetify.js to export the base options:

export const options = {
  icons: {
    iconfont: 'mdiSvg',
  },
  theme: {
    dark: true,
    // ... etc., etc., etc....
  }
}

export default new Vuetify(options)

Then in .storybook/addon-vuetify/decorator.js, I imported them and did something like:

// at the top with other imports
import { options } from '../../src/plugins/vuetify'

export default makeDecorator({
  name: 'withVuetify',
  parameterName: 'vuetify',
  wrapper: (storyFn, context, { parameters = {} }) => {
    const vuetify = new Vuetify(deepmerge(options, parameters))
    // ... everything else is basically the same ...
  }
})

I always have custom options in my plugins/vuetify.js file in all my apps, so I don't know if this would break simpler installs. Maybe there's a way to detect that it's setup this way and adjust accordingly?

Also, I have a question: what is the purpose of the parameters param in the wrapper() function??? I logged it's value, which was always an empty object, and I tried to tweak things that might give it a value, but I couldn't figure out how to modify it. If it never does anything we could simplify this decorator by not worrying about merging it into the Vuetify instance.

Feature Request: add custom SASS variables to webpack

In my .storybook/webpack.config.js file, I was able to import my custom SASS variables like this:

const path = require('path')

module.exports = async ({ config }) => {
  config.resolve.alias['~storybook'] = path.resolve(__dirname)
  config.resolve.alias['@'] = path.resolve(__dirname, '..', 'src')

  config.module.rules.push({
    resourceQuery: /blockType=story/,
    loader: 'vue-storybook'
  })

  config.module.rules.push({
    test: /\.s(a|c)ss$/,
    use: [
      'style-loader',
      'css-loader',
      {
        loader: 'sass-loader',
        options: {
          prependData: `@import '${path.resolve(__dirname, '..', 'src', 'scss')}/variables.scss'`
        }
      }
    ],
    include: [
      path.resolve(__dirname, '../'),
    ],
  })

  return config
}

This works for my particular setup, but not everyone will define their custom variables like I have. I suggest that this plugin should be updated to do the same thing that vue-cli-plugin-vuetify does, which is to detect whether custom variables are saved in src/(sass|scss|styles)/variables.s(c|a)ss and load them appropriately.

js-beautify is might be missing form devDependencies.

npm run serve:storybook fails because of missing dependencies.

ERROR in ./.storybook/addon-show-vue-markup/decorator.js
Module not found: Error: Can't resolve 'js-beautify' in '~/.storybook/addon-show-vue-markup'

For now i installed the dev dependencies manually:
npm install --save-dev js-beautify

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.