Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 8 additions & 22 deletions packages/apps/storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
* 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 { useDarkMode } from "storybook-dark-mode";
import { darkTheme, lightTheme } from "./itwinTheme";
import '@itwin/itwinui-react/styles.css';

// get an instance to the communication channel for the manager and preview
const channel = addons.getChannel();
import "@itwin/itwinui-react/styles.css";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
Expand All @@ -31,24 +26,15 @@ export const parameters = {
},
};

const useTheme = () => {
const [dark, setDark] = React.useState(false);

React.useEffect(() => {
channel.on("DARK_MODE", setDark);
}, []);

return dark ? "dark" : "light";
}

export const decorators = [
(Story) => {
const theme = useTheme();
const isDark = useDarkMode();
const theme = isDark ? "dark" : "light";

return (
<ThemeProvider style={{ background: "transparent" }} theme={theme}>
<Story />
</ThemeProvider>
<ThemeProvider style={{ background: "transparent" }} theme={theme}>
<Story />
</ThemeProvider>
);
},
];
];
2 changes: 1 addition & 1 deletion packages/apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@itwin/delete-itwin-react": "workspace:*",
"@itwin/imodel-browser-react": "workspace:*",
"@itwin/itwinui-icons-react": "2.10.0",
"@itwin/itwinui-react": "3.18.0",
"@itwin/itwinui-react": "^3.19.4",
"@itwin/manage-versions-react": "workspace:*",
"@itwin/storybook-auth-addon": "workspace:*",
"@storybook/addon-actions": "^6.5.16",
Expand Down