etchteam / storybook-addon-css-variables-theme

Change the CSS variable based design tokens in your storybook on the fly
MIT License
28 stars 12 forks source link

Addon doesn't work #47

Closed osanzharevskyy closed 5 months ago

osanzharevskyy commented 1 year ago

Given:

main.ts

import type { StorybookConfig } from '@storybook/core-common';

export const rootMain: StorybookConfig = {
  stories: [],
  addons: [
    '@storybook/addon-essentials',
    'storybook-preset-inline-svg',
    '@etchteam/storybook-addon-css-variables-theme',
  ],
  typescript: {
    check: true,
  },
};

preview.ts

import light from '!!style-loader?injectType=lazyStyleTag!css-loader!../styles/light.css';
import dark from '!!style-loader?injectType=lazyStyleTag!css-loader!../styles/dark.css';

import cssVariablesTheme from '@etchteam/storybook-addon-css-variables-theme';

export const decorators = [cssVariablesTheme];

export const parameters = {
  cssVariables: {
    files: {
      'Light Theme': light,
      'Dark Theme': dark,
    },
  },
};

I followed the documentation, but the switcher even doesn't appear( no errors or warnings...

DanWebb commented 5 months ago

This may have been because '@etchteam/storybook-addon-css-variables-theme' was used in main.ts instead of '@etchteam/storybook-addon-css-variables-theme/dist/preset'.

In 2.1.0 either will work.

If this is still a problem we'll need a reproduction to be provided.