Gaëtan Maisse 36ee762ec7 fix: clean usage of @types/webpack-env dep in all packages
- `@types/webpack-env` must be defined as `dependencies` in packages that export a type/function using typings from `@types/webpack-env` (it is often `NodeModule`). In that case `/// <reference types="webpack-env" />` is present in some files of the `dist` folder of the lib. Example: `lib/client-api`.
 - `@types/webpack-env` must be defined as `devDependencies` in packages that use its typings internally but does not expose anything related to it. Many addons need the type because they use `module.hot` function. Example: `addons/a11y`
 - `webpack-env` should be removed from "compilerOptions.types" key of `tsconfig.json` of packages that don't need it.

 I also bump `@types/webpack-env` to ^1.15.0 to have the same version all across the monorepo
2020-01-20 08:41:44 +01:00
..
2018-10-29 18:26:55 -07:00
2019-10-15 00:53:33 +02:00
2019-11-27 16:31:36 +01:00
2018-10-29 15:03:59 -07:00

Storybook Addon Cssresources

Storybook Addon Cssresources to switch between css resources at runtime for your story Storybook.

Framework Support

Storybook Addon Cssresources Demo

Installation

yarn add -D @storybook/addon-cssresources

Configuration

Then create a file called main.js in your storybook config.

Add following content to it:

module.exports = {
  addons: ['@storybook/addon-cssresources/register']
}

Usage

You need add the all the css resources at compile time using the withCssResources decorator. They can be added globally or per story. You can then choose which ones to load from the cssresources addon UI:

import { withCssResources } from '@storybook/addon-cssresources';

export default {
  title: 'CssResources',
  parameters: {
    cssresources: [{
        id: `bluetheme`,
        code: `<style>body { background-color: lightblue; }</style>`,
        picked: false,
      },
    ],
  },
  decorators: [withCssResources],
};

export const defaultView = () => (
  <div />
);