waveterm/.storybook/preview.tsx

62 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-05-25 02:44:41 +02:00
// organize-imports-ignore
import type { Preview } from "@storybook/react";
import React from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import "../frontend/app/theme.scss";
import "../frontend/app/app.scss";
import "../frontend/app/reset.scss";
2024-05-25 02:44:41 +02:00
import "./global.css";
import { light, dark } from "./theme";
import { DocsContainer } from "@storybook/addon-docs";
import { addons } from "@storybook/preview-api";
import { DARK_MODE_EVENT_NAME } from "storybook-dark-mode";
const channel = addons.getChannel();
2024-05-25 02:44:41 +02:00
const preview: Preview = {
2024-05-28 21:12:28 +02:00
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
darkMode: {
dark,
light,
stylePreview: true,
classTarget: "html",
},
docs: {
container: (props) => {
const [isDark, setDark] = React.useState();
React.useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, setDark);
return () => channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
}, [channel, setDark]);
return (
<div>
<DocsContainer {...props} theme={isDark ? dark : light} />
</div>
);
},
},
2024-05-28 21:12:28 +02:00
},
2024-06-14 04:50:27 +02:00
2024-05-28 21:12:28 +02:00
decorators: [
(Story) => (
<DndProvider backend={HTML5Backend}>
<Story />
</DndProvider>
),
],
2024-06-14 04:50:27 +02:00
2024-06-26 21:26:27 +02:00
tags: ["autodocs"],
2024-05-25 02:44:41 +02:00
};
export default preview;