-
Notifications
You must be signed in to change notification settings - Fork 14
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
docs(Storybook): upgrade to Storybook V8 #639
Conversation
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, 'package.json'))); | ||
} | ||
|
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.
Following recommendations for monorepo environments.
@@ -36,7 +36,8 @@ | |||
"files": ["*.stories.tsx", "packages/*/demo/**/*"], | |||
"rules": { | |||
"react/button-has-type": "off", | |||
"react/no-array-index-key": "off" | |||
"react/no-array-index-key": "off", | |||
"func-name-matching": "off" |
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.
To support React hooks and useArgs
within story's render field, the docs recommend using this syntax to avoid linting errors.
{
render: function Render (args) {...}
...
}
Disabling func-name-matching
is preferable to turning off react-hooks/rules-of-hooks.
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.
From that link...
To avoid linting issues, it is recommended to use a function with a capitalized name. If you are not concerned with linting, you may use an arrow function.
Are you sure they aren't referring to their own Storybook linter (which we don't use)? If so, then Garden would definitely prefer arrow functions.
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.
That applies to our eslint config as well. To be clear, we can still use arrow functions and should do so when not using hooks.
func-name-matching
expects { render: function render {...} }
, however react-hooks/rules-of-hooks requires that a function be PascalCased
when using hooks. Disabling react-hooks/rules-of-hooks
can lead to bugs but turning off func-name-matching
won't. That's why I think it's a better choice.
The alternative is to move that function elsewhere.
const Controlled: Story = {
render: function Render (args) {...}
...
}
Becomes
export const Controlled: Story = {
render: Render,
...
}
function Render (args) {...}
But I think it's more cumbersome and would reduce readability.
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.
ic – yeah, then what you have is the right trade-off. Thanks for the explanation.
.storybook/preview.js
Outdated
@@ -8,7 +8,7 @@ | |||
import React, { StrictMode } from 'react'; | |||
import { createGlobalStyle } from 'styled-components'; | |||
import { create } from '@storybook/theming/create'; | |||
import { DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming'; | |||
import { DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming'; |
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.
Future-proofing until v9 upgrade.
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 think we'd prefer to leave this as getColor
so that it is forced to be addressed when this repo renovates up to v9.
}; | ||
|
||
export const Controlled: Story = { | ||
render: function Render(args) { |
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.
Following the docs recommended syntax when using hooks within the render fn.
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.
ditto .. can Garden opt for arrow functions? Or are they referring to the hooks linter?
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.
Hard to tell if there's more magic in v8 or if there was a lot of MDX magic in v7 that is now being passed along to the consumer 😅 . But solid work here @ze-flo
package.json
Outdated
"@storybook/addon-a11y": "^8.0.9", | ||
"@storybook/addon-essentials": "^8.0.9", | ||
"@storybook/addon-mdx-gfm": "^8.0.9", | ||
"@storybook/addon-styling": "1.3.7", | ||
"@storybook/react": "7.6.17", | ||
"@storybook/react-webpack5": "7.6.17", | ||
"@storybook/addon-webpack5-compiler-babel": "^3.0.3", | ||
"@storybook/blocks": "^8.0.9", | ||
"@storybook/react": "^8.0.9", | ||
"@storybook/react-webpack5": "^8.0.9", |
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.
All dependencies should be exact versions – no ^
ranges
@@ -0,0 +1,19 @@ | |||
import { Meta, Controls, Canvas, Story, Markdown } from '@storybook/blocks'; | |||
import README from '../README.md'; | |||
import * as FocusvisibleStories from './focusvisible.stories'; |
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.
import * as FocusvisibleStories from './focusvisible.stories'; | |
import * as FocusVisibleStories from './focusvisible.stories'; |
[nit]
@@ -0,0 +1,19 @@ | |||
import { Meta, Controls, Canvas, Story, Markdown } from '@storybook/blocks'; | |||
import README from '../README.md'; | |||
import * as ScrollregionStories from './scrollregion.stories'; |
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.
import * as ScrollregionStories from './scrollregion.stories'; | |
import * as ScrollRegionStories from './scrollregion.stories'; |
[nit]
8745fd8
to
5e352ae
Compare
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.
👌🏻 Appreciate your diligence on the component signatures in the Story objects. Came together really nice!
'@storybook/addon-a11y' | ||
getAbsolutePath('@storybook/addon-a11y'), | ||
getAbsolutePath('@storybook/addon-mdx-gfm'), | ||
'@storybook/addon-webpack5-compiler-babel' |
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.
Did you end up having any insights into why the SWC compiler was having issues?
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.
Not sure what the root cause is. I'll have to dig deeper on that in a follow-up PR.
Everything is type-safe now. That uncovered a few errors that are now fixed. 🙌 |
Description
Migrate from
Storybook@7.x.x
toStorybook@8.0.10
Detail
*.stories.mdx
to CSF3 + MDX using scriptUpgrades togetColorV8
from@zendeskgarden/react-theming
to avoid future breaking-changesChecklist
npm start
)💂♂️ includes new unit tests♿ tested for WCAG 2.1 AA compliance