-
Notifications
You must be signed in to change notification settings - Fork 3
Migrate Storybook for Next.js #1525
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dfb6e49
Next.js Initial Migration (#1505)
jonkafton 9addf7f
Fix linting on nextjs branch (#1509)
ChristopherChudzicki fe10082
Fixes for successful build (#1516)
jonkafton 46ff868
Move Storybook root to ol-components
jonkafton f9e294d
Move GlobalStyles to ol-components
jonkafton 73991f3
Self contained images
jonkafton 48ad565
Storybook for Next.js
jonkafton f19d4e0
Remove react-router addon. Upgrade Storybook addons
jonkafton aa7022f
Fix issue trying to resolve react-dom/test-utils. Storybook 8 migrati…
jonkafton 3db9ee6
Local image
jonkafton 66e299a
Replace react-router useLocation
jonkafton b078bff
Images fixes. Copy images into ol-components. Embedly fallback
jonkafton 4546b3a
Migrate routed drawer stories for @storybook/nextjs
jonkafton 4d9604b
Next.js Initial Migration (#1505)
jonkafton ac67ac9
Fix linting on nextjs branch (#1509)
ChristopherChudzicki 35c32c4
Fixes for successful build (#1516)
jonkafton 9404d71
Enable Storybook action
jonkafton 3e5dc5b
Merge branch 'nextjs' into jk/migrate-storybook
jonkafton a4d584a
Enable Storybook action
jonkafton 9b4b737
Update lockfile
jonkafton 97b66c1
Use client directive missing from layout
jonkafton 87e6714
Merge branch 'nextjs' into jk/migrate-storybook
jonkafton 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
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 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 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 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,2 @@ | ||
| import "slick-carousel/slick/slick.css" | ||
| import "slick-carousel/slick/slick-theme.css" |
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
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,79 @@ | ||
| import { resolve, join, dirname } from "path" | ||
| import * as dotenv from "dotenv" | ||
| import * as webpack from "webpack" | ||
| import { StorybookConfig } from '@storybook/nextjs'; | ||
|
|
||
| dotenv.config({ path: resolve(__dirname, "../../../.env") }) | ||
|
|
||
| /** | ||
| * This function is used to resolve the absolute path of a package. | ||
| * It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
| */ | ||
| function getAbsolutePath(value: string) { | ||
| return dirname(require.resolve(join(value, "package.json"))) | ||
| } | ||
|
|
||
| const config: StorybookConfig = { | ||
| stories: [ | ||
| "../src/**/*.mdx", | ||
| "../src/**/*.stories.tsx", | ||
| "../../ol-components/src/**/*.mdx", | ||
| "../../ol-components/src/**/*.stories.@(tsx|ts)", | ||
| ], | ||
|
|
||
| staticDirs: ["./public"], | ||
|
|
||
| addons: [ | ||
| getAbsolutePath("@storybook/addon-links"), | ||
| getAbsolutePath("@storybook/addon-essentials"), | ||
| getAbsolutePath("@storybook/addon-interactions"), | ||
| getAbsolutePath("@storybook/addon-webpack5-compiler-swc"), | ||
| getAbsolutePath("@storybook/addon-mdx-gfm") | ||
| ], | ||
|
|
||
| framework: { | ||
| name: getAbsolutePath("@storybook/nextjs"), | ||
| options: {} | ||
| }, | ||
|
|
||
| docs: {}, | ||
|
|
||
| webpackFinal: async (config: any) => { | ||
| config.plugins.push( | ||
| new webpack.DefinePlugin({ | ||
| APP_SETTINGS: { | ||
| EMBEDLY_KEY: JSON.stringify(process.env.EMBEDLY_KEY), | ||
| PUBLIC_URL: JSON.stringify(process.env.PUBLIC_URL), | ||
| }, | ||
| }), | ||
| ) | ||
|
|
||
|
|
||
| /* Fix for this error: | ||
| Module not found: Error: Can't resolve 'react-dom/test-utils' in './node_modules/@testing-library/react/dist/@testing-library' | ||
|
|
||
| Described here: https://github.com/vercel/next.js/issues/55620 | ||
|
|
||
| react-dom/test-utils is deprecated and replaced with @testing-library/react and @storybook/nextjs introduces an incompatibility. | ||
| The fix is to use @storybook/test in place of @testing-library/react, which provides the same API. | ||
| The issue is that we are using factories from api/test-utils, which imports ol-test-utilities, which imports @testing-library/react, which itself requires react-dom/test-utils, | ||
| We should not use @storybook packages in ol-test-utilities or anywhere outside of ol-components as they are not related | ||
| so below we are aliasing @testing-library/react. | ||
| */ | ||
| config.resolve = { | ||
| ...config.resolve, | ||
| alias: { | ||
| ...config.resolve?.alias, | ||
| "@testing-library/react": "@storybook/test" | ||
| } | ||
| } | ||
|
|
||
| return config | ||
| }, | ||
|
|
||
| typescript: { | ||
| reactDocgen: "react-docgen-typescript" | ||
| } | ||
| } | ||
|
|
||
| export default config | ||
File renamed without changes.
File renamed without changes.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
frontends/ol-components/.storybook/public/images/platform_logos/bootcamps.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
frontends/ol-components/.storybook/public/images/platform_logos/csail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
This surprised me because:
react-dom/test-utilsis deprecated; its main export,acthas been moved to the mainreactpackage.@testing-library/reactimportsactfromreact, but imports it fromreact-dom/test-utilsas a fallback for older versions of react.I suspect what's happening is... NextJS's app router uses the canary channel of react (see blog), and in that channel,
react-dom/test-utilsmay not just be deprecated, but removed all together. Hence the error.