npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wix-storybook-config

v1.0.2

Published

<img src="./storybook_logo.svg" align="right" alt="storybook logo" width="120" height="178">

Downloads

130

Readme

Wix Storybook Config

Wix Storybook Config is a collection of decorating functions that help Wix Design Systems teams maintain its storybook configuration in one place.

  • decorateMainConfig - general purpose storybook main.js config.
  • decorateMainDocsConfig - wix design systems opinionated storybook stories config.
  • fully typed and documented options.

⚙️ Installation

First of all, install @storybook/react and @storybook/addon-essentials:

npm install --save-dev @storybook/react @storybook/addon-essentials

🔔 Please note: version 6 or higher is required.

Install additional storybook packages that are mandatory for stylable plugin to work:

npm install --save-dev @storybook/builder-webpack5 @storybook/manager-webpack5

🔔 Please note: webpack 5 or higher is required.

🔧 Decorator Functions

decorateMainConfig

This is a decorator base function for storybook main.js file.

  1. Enables webpack 5 and resolves unpolyfilled webpack modules.
  2. Adds stylable v4 support with ability to pass options.
  3. Add scss support with ability to write .global.scss too.

Example of storybook main.js usage:

// .storybook/main.js

const { decorateMainConfig } = require('wix-storybook-config')

module.exports = decorateMainConfig({
   /**
    * An array of globs that indicates the location of your story files, relative to main.js.
    */
   stories: ['../src/**/*.stories.ts'],
   /**
    * A list of the addons you would like to use.
    */
   addons: ['my-addon'],
   /**
    * A function for modyfing default storybook webpack config.
    */
   webpackFinal: (config) => config,
   /**
    * Stylable Webpack Plugin options.
    */
   stylableWebpackPluginOptions: {
     /**
      * Read more:https://github.com/wix/stylable/tree/master/packages/webpack-plugin#plugin-configuration-options
     */
   },
   /**
    * The rest of the storybook main.js config values. Read more here: https://storybook.js.org/docs/react/configure/overview
    */
   ...rest
})

decorateMainDocsConfig

This is a decorator function for storybook main.js file with opinionated wix storybook utils plugin.

  1. Uses decorateMainConfig decorator as base.
  2. Adds wix storybook utils plugin with exposed options parameter.
import { decorateMainDocsConfig } from 'wix-storybook-config'

Example of storybook main.js usage:

// .storybook/main.js

const { decorateMainDocsConfig } = require('wix-storybook-config')

module.exports = decorateMainDocsConfig({
   /**
    * An array of globs that indicates the location of your story files, relative to main.js.
    */
   stories: ['../src/**/*.stories.ts'],
   /**
    * A list of the addons you would like to use.
    */
   addons: ['my-addon'],
   /**
    * A function for modyfing default storybook webpack config.
    */
   webpackFinal: (config) => config,
   /**
    * Stylable Webpack Plugin options
    */
   stylableWebpackPluginOptions: {
     /**
      * Read more:https://github.com/wix/stylable/tree/master/packages/webpack-plugin#plugin-configuration-options
     */
   },
    /**
    * Wix Storybook Utils Plugin options
    */
   wixStorybookWebpackUtilsOptions: {
      /**
      * Your package or repo name. Used for constructing import examples for components.
      * import { ComponentName } from 'package-name';
      */
      moduleName: 'package-name',
       /**
       * Your components import format. Used for showing imports in story design tab.
       * @default - import { %componentName } from '%moduleName'
       */
      importFormat: "import { %componentName } from '%moduleName'",
      /**
       *  Absolute path to a file that exports components for every code playground on storybook.
       *  This ensures components playground autocomplete features and ability to copy paste from one
       *  example to another.
       */
      playgroundComponentsPath: path.resolve(__dirname, './playground'),
      /**
      * Your components src folder path in github. Used for constructing component source link
      * in storybook story. Can be seen in storybook story header.
      */
      repoBaseURL:'https://github.com/package-name/src',
      /**
      * Your library url for opening issues. Can be seen in storybook story header.
      */
      issueURL: 'https://open-library-issue.io',
      /**
      * Story feedback section description value.
      */
      feedbackText: 'You can help us improve this component by providing feedback',
      /**
       *  A string representing description in story testkit tab below the title.
       *  Used for adding additional information.
       */
      testkitsWarning: 'Read more here',
      /**
       * Components testkit import path. Used for constructing testkit imports in story testkit tab.
       * Format example: import { <%= component.displayName %>Testkit } from '${importTestkitPath}/testkit/enzyme';
       */
      importTestkitPath: 'package-name/dist',
      /**
       * Components custom testkit import paths. Used for constructing custom testkit import paths per testing platform. @supported vanilla, enzyme, puppeteer.
       * By providing this configuration importTestkitPath parameter will be ignored.
       */
      testkits: {
        vanilla: {
          template: `import { ComponentNameTestkit } from 'package-name/testkit';`,
        }
      },
   },
   /**
    * The rest of the storybook main.js config values. Read more here: https://storybook.js.org/docs/react/configure/overview
    */
   ...rest
})