forked from iTwin/admin-components-react
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreview.js
55 lines (49 loc) · 1.56 KB
/
preview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import React from "react";
import { ThemeProvider } from "@itwin/itwinui-react";
import addons from "@storybook/addons";
import { themes } from "@storybook/theming";
import { darkTheme, lightTheme } from "./itwinTheme";
// get an instance to the communication channel for the manager and preview
const channel = addons.getChannel();
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
backgrounds: { disable: true },
controls: { expanded: true },
darkMode: {
dark: { ...themes.dark, ...darkTheme },
light: { ...themes.light, ...lightTheme },
},
docs: {
theme: { ...themes.light, ...lightTheme },
},
authClientConfig: {
clientId: process.env.STORYBOOK_AUTH_CLIENT_ID,
scope: [
"imodels:read",
"imodels:modify",
"itwins:modify",
"itwins:read",
].join(" "),
authority: "https://qa-ims.bentley.com",
},
};
export const decorators = [
(Story) => {
const [dark, setDark] = React.useState(false);
React.useEffect(() => {
channel.on("DARK_MODE", setDark);
}, []);
return (
<ThemeProvider
style={{ background: "transparent" }}
theme={dark ? "dark" : "light"}
>
<Story />
</ThemeProvider>
);
},
];