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

What is meant by serving styles with the -s ./path parameter? #5

Open
john-melin opened this issue Mar 31, 2023 · 1 comment
Open

Comments

@john-melin
Copy link

Where do i configure this?

@gynekolog
Copy link

gynekolog commented May 16, 2023

I don't know. But if you're looking for a solution how to make the addon work, you could use the staticDirs config in the main.ts file.

Usage:

root
 -public
 --theme-dark.css
 --theme-light.css

main.ts

import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    "storybook-stylesheet-toggle", // this
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
  ],
  staticDirs: ["../public"], // this
  framework: {
    name: "@storybook/react-vite",
    options: {},
  },
};
export default config;

and the preview.ts:

import { type Preview } from "@storybook/react";

const preview: Preview = {
  // quick fix to make the storybook-stylesheet-toggle addon work
  globalTypes: {
    selectedStylesheetID: {},
  },

  parameters: {
    actions: { argTypesRegex: "^on[A-Z].*" },
    controls: {
      matchers: {
        color: /(background|color)$/i,
        date: /Date$/,
      },
    },
    stylesheetToggle: {
      stylesheets: [
        {
          id: "theme-dark",
          title: "Dark",
          url: "dark.css",
        },
        {
          id: "theme-light",
          title: "Light",
          url: "theme-light.css",
        },
      ],
    },
  },
};

export default preview;

You can see I add the

globalTypes: {
    selectedStylesheetID: {},
  },

It's because the addon doesn't work properly with the storybook 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants