如何在多个前端添加故事书故事目录?
How to add storybook stories directories in several frontends?
我们想在几个目录中为我们的项目集成 Storybook 组件,但通过 .storybook/main.js
中的设置访问所有这些组件
现在我们使用解决方法来取消注释 main.js 配置中不需要的部分,但显然这不是一个长期的解决方案。
然后看起来像这样:
module.exports = {
stories: [
// TODO: make all stories visible at the same time
// --- GPF components ---
"../../../apps/frontend/src/components/stories/**/*.stories.mdx",
"../../../apps/frontend/src/components/stories/**/*.stories.@(js|jsx|ts|tsx)",
// // --- UTR components ---
// "../../../apps/utr-frontend/components/stories/**/*.stories.mdx",
// "../../../apps/utr-frontend/components/stories/**/*.stories.@(js|jsx|ts|tsx)",
// // --- Global components ---
// "../../components/stories/**/*.stories.mdx",
// "../../components/stories/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],};
有什么正确的建议吗?
提前致谢!!
glob 模式应该可以解决这个问题
stories: ['../../**/*.stories.@(js|jsx|ts|tsx|mdx)'],
好吧,我太笨了,我忘了更改单个组件的标题:
import React from "react";
import { action } from "@storybook/addon-actions";
import Button from "../lib/button";
export default {
title: "Global Button", // -- change title here! --
component: Button,
};
export const Text = () => (
<Button onClick={action("clicked")}>Global Button</Button>
);
export const Emoji = () => (
<Button onClick={action("clicked")}>
<span role='img' aria-label='so cool'>
</span>
</Button>
);
我们想在几个目录中为我们的项目集成 Storybook 组件,但通过 .storybook/main.js
中的设置访问所有这些组件现在我们使用解决方法来取消注释 main.js 配置中不需要的部分,但显然这不是一个长期的解决方案。
然后看起来像这样:
module.exports = {
stories: [
// TODO: make all stories visible at the same time
// --- GPF components ---
"../../../apps/frontend/src/components/stories/**/*.stories.mdx",
"../../../apps/frontend/src/components/stories/**/*.stories.@(js|jsx|ts|tsx)",
// // --- UTR components ---
// "../../../apps/utr-frontend/components/stories/**/*.stories.mdx",
// "../../../apps/utr-frontend/components/stories/**/*.stories.@(js|jsx|ts|tsx)",
// // --- Global components ---
// "../../components/stories/**/*.stories.mdx",
// "../../components/stories/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],};
有什么正确的建议吗?
提前致谢!!
glob 模式应该可以解决这个问题
stories: ['../../**/*.stories.@(js|jsx|ts|tsx|mdx)'],
好吧,我太笨了,我忘了更改单个组件的标题:
import React from "react";
import { action } from "@storybook/addon-actions";
import Button from "../lib/button";
export default {
title: "Global Button", // -- change title here! --
component: Button,
};
export const Text = () => (
<Button onClick={action("clicked")}>Global Button</Button>
);
export const Emoji = () => (
<Button onClick={action("clicked")}>
<span role='img' aria-label='so cool'>
</span>
</Button>
);