-
Notifications
You must be signed in to change notification settings - Fork 15
Update to Storybook 10 #205
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
Open
alexdunae
wants to merge
34
commits into
main
Choose a base branch
from
alex/storybook-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
34f639d
Replace eslint-config-react-app
alexdunae a69f63b
Change files
alexdunae af299c1
less diff noise
alexdunae 01c11ec
remove change strings
alexdunae 8e7be25
Switch to `none`
alexdunae 8999d95
Update to Typescript 6 / Jest 29
alexdunae bf20547
Change files
alexdunae 3460226
.
alexdunae 1f30c8e
tsconfig jest
alexdunae c48acf2
allowJS
alexdunae 3542e11
change files
alexdunae e700db9
"eslint": "^8.57.0"
alexdunae 9ecba32
add ts to storybook pkg
alexdunae ead8657
revert
alexdunae db6eb1d
rollup-plugin-typescript2": "^0.37.0"
alexdunae 113c663
Spike
alexdunae ba6f276
Working iTwin selection
alexdunae 020c2cb
working
alexdunae 5d5133e
Merge branch 'main' into alex/typescript6
alexdunae 82bae4c
Merge branch 'alex/typescript6' into alex/storybook-update
alexdunae 3d971f3
SB10
alexdunae 42ace36
tidy
alexdunae cf59267
"@typescript-eslint/parser": "^8.57.0"
alexdunae 247de36
argTypes
alexdunae 4d116f5
fileURLToPath
alexdunae c4cd2fa
Merge branch 'alex/typescript6' into alex/storybook-update
alexdunae 373d4f9
.
alexdunae e8e4f74
Update to Typescript 6 / Jest 29 (#202)
alexdunae f545fb2
Merge branch 'main' into alex/storybook-update
alexdunae 08d730e
Remove stray file
alexdunae 3acecfc
Revert "."
alexdunae 5e22eb0
Merge branch 'main' into alex/storybook-update
alexdunae 04ef293
tidy and arg type improvements
alexdunae 0f94dca
CSF3 refactor
alexdunae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
| * See LICENSE.md in the project root for license terms and full copyright notice. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
| import path from "path"; | ||
| import { fileURLToPath } from "url"; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| const config: StorybookConfig = { | ||
| core: { | ||
| disableTelemetry: true, | ||
| disableWhatsNewNotifications: true, | ||
| }, | ||
| stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
| addons: [ | ||
| "@storybook/addon-webpack5-compiler-swc", | ||
| "storybook-dark-mode", | ||
| "../../../modules/storybook-auth-addon", | ||
| "../src/addon", | ||
| ], | ||
| framework: { | ||
| name: "@storybook/react-webpack5", | ||
| options: {}, | ||
| }, | ||
| typescript: { | ||
| reactDocgen: "react-docgen-typescript", | ||
| }, | ||
| staticDirs: ["../../../modules/storybook-auth-addon/build"], | ||
| webpackFinal: async (config, { configType }) => { | ||
| // `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION' | ||
| // You can change the configuration based on that. | ||
| // 'PRODUCTION' is used when building the static version of storybook. | ||
|
|
||
| config.resolve = config.resolve || {}; | ||
| config.resolve.mainFields = ["module", "main"]; | ||
|
|
||
| const packagePaths: Record<string, string> = { | ||
| "@itwin/imodel-browser-react": path.resolve( | ||
| __dirname, | ||
| "../../../modules/imodel-browser/src" | ||
| ), | ||
| "@itwin/create-imodel-react": path.resolve( | ||
| __dirname, | ||
| "../../../modules/create-imodel/src" | ||
| ), | ||
| "@itwin/delete-imodel-react": path.resolve( | ||
| __dirname, | ||
| "../../../modules/delete-imodel/src" | ||
| ), | ||
| "@itwin/delete-itwin-react": path.resolve( | ||
| __dirname, | ||
| "../../../modules/delete-itwin/src" | ||
| ), | ||
| "@itwin/manage-versions-react": path.resolve( | ||
| __dirname, | ||
| "../../../modules/manage-versions/src" | ||
| ), | ||
| }; | ||
|
|
||
| // Alias local packages to source directories for both dev and production builds | ||
| config.resolve.alias = { | ||
| ...config.resolve.alias, | ||
| ...packagePaths, | ||
| }; | ||
|
|
||
| // Enable HMR for local packages in development by aliasing to source directories | ||
| if (configType === "DEVELOPMENT") { | ||
| // Use full source maps to allow VS Code Chrome debugger to map back to TS/TSX sources | ||
| config.devtool = "source-map"; | ||
| config.output = config.output || {}; | ||
| config.output.devtoolModuleFilenameTemplate = (info: { | ||
| absoluteResourcePath: string; | ||
| }) => { | ||
| // Derive repo root (four levels up from .storybook: ../../../../) | ||
| const repoRoot = path.resolve(__dirname, "../../../../"); | ||
| const relPath = path | ||
| .relative(repoRoot, info.absoluteResourcePath) | ||
| .replace(/\\/g, "/"); | ||
| return `webpack:///${relPath}`; | ||
| }; | ||
| } | ||
|
|
||
| // Handle SCSS files from source directories | ||
| config.module = config.module || {}; | ||
| config.module.rules = config.module.rules || []; | ||
| config.module.rules.push({ | ||
| test: /\.scss$/, | ||
| include: Object.values(packagePaths), | ||
| use: ["style-loader", "css-loader", "sass-loader"], | ||
| }); | ||
|
|
||
| return config; | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
| * See LICENSE.md in the project root for license terms and full copyright notice. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
| import { ThemeProvider } from "@itwin/itwinui-react"; | ||
| import { themes } from "storybook/theming"; | ||
| import { useDarkMode } from "storybook-dark-mode"; | ||
| import { darkTheme, lightTheme } from "./itwinTheme"; | ||
| import "@itwin/itwinui-react/styles.css"; | ||
| import React from "react"; | ||
| import { addons } from "storybook/preview-api"; | ||
|
|
||
| const ITWIN_ID_EVENT = "project/toolbar/set-itwin-id"; | ||
| const ACCESS_TOKEN_EVENT = "auth/toolbar/set-access-token"; | ||
| let _currentITwinId = ""; | ||
| let _currentAccessToken = ""; | ||
|
|
||
| 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: "itwin-platform", | ||
| authority: "https://qa-ims.bentley.com", | ||
| }, | ||
| layout: "fullscreen", | ||
| }; | ||
|
|
||
| export const decorators = [ | ||
| ( | ||
| Story: React.ComponentType<{ args?: Record<string, unknown> }>, | ||
| context: { | ||
| globals: Record<string, string>; | ||
| args: Record<string, unknown>; | ||
| argTypes: Record<string, unknown>; | ||
| } | ||
| ) => { | ||
| const isDark = useDarkMode(); | ||
| const theme = isDark ? "dark" : "light"; | ||
| const [iTwinId, setITwinId] = React.useState(_currentITwinId); | ||
| const [accessToken, setAccessToken] = React.useState(_currentAccessToken); | ||
|
|
||
| React.useEffect(() => { | ||
| const channel = addons.getChannel(); | ||
| const handleITwinId = (id: string) => { | ||
| _currentITwinId = id; | ||
| setITwinId(id); | ||
| }; | ||
| const handleAccessToken = (token: string) => { | ||
| _currentAccessToken = token; | ||
| setAccessToken(token); | ||
| }; | ||
| channel.on(ITWIN_ID_EVENT, handleITwinId); | ||
| channel.on(ACCESS_TOKEN_EVENT, handleAccessToken); | ||
| return () => { | ||
| channel.off(ITWIN_ID_EVENT, handleITwinId); | ||
| channel.off(ACCESS_TOKEN_EVENT, handleAccessToken); | ||
| }; | ||
| }, []); | ||
|
|
||
| const injectedArgs: Record<string, unknown> = {}; | ||
| if ("accessToken" in context.argTypes) { | ||
| injectedArgs.accessToken = accessToken; | ||
| } | ||
| if ("iTwinId" in context.argTypes) { | ||
| injectedArgs.iTwinId = iTwinId; | ||
| } | ||
|
|
||
| return ( | ||
| <ThemeProvider | ||
| style={{ | ||
| background: "var(--iui-color-background)", | ||
| padding: "1rem", | ||
| minHeight: "100vh", | ||
| }} | ||
| theme={theme} | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| children={ | ||
| (<Story args={{ ...context.args, ...injectedArgs }} />) as any | ||
| } | ||
| /> | ||
| ); | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resisted the urge to ditch webpack for vite...