-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Storybook: Upgrade to v8.0.x #67574
Storybook: Upgrade to v8.0.x #67574
Changes from all commits
919accf
86fc08e
b1211a8
974f446
b11de11
d3d72b0
5c5078a
146f748
aab89cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
"@emotion/babel-plugin": "11.11.0", | ||
"@emotion/jest": "11.7.1", | ||
"@emotion/native": "11.0.0", | ||
"@geometricpanda/storybook-addon-badges": "2.0.1", | ||
"@geometricpanda/storybook-addon-badges": "2.0.5", | ||
"@octokit/rest": "16.26.0", | ||
"@octokit/types": "6.34.0", | ||
"@octokit/webhooks-types": "5.8.0", | ||
|
@@ -42,16 +42,18 @@ | |
"@react-native/babel-preset": "0.73.10", | ||
"@react-native/metro-babel-transformer": "0.73.10", | ||
"@react-native/metro-config": "0.73.4", | ||
"@storybook/addon-a11y": "7.6.15", | ||
"@storybook/addon-actions": "7.6.15", | ||
"@storybook/addon-controls": "7.6.15", | ||
"@storybook/addon-docs": "7.6.15", | ||
"@storybook/addon-toolbars": "7.6.15", | ||
"@storybook/addon-viewport": "7.6.15", | ||
"@storybook/react": "7.6.15", | ||
"@storybook/react-webpack5": "7.6.15", | ||
"@storybook/source-loader": "7.6.15", | ||
"@storybook/theming": "7.6.15", | ||
"@storybook/addon-a11y": "8.0.10", | ||
"@storybook/addon-actions": "8.0.10", | ||
"@storybook/addon-controls": "8.0.10", | ||
"@storybook/addon-docs": "8.0.10", | ||
"@storybook/addon-toolbars": "8.0.10", | ||
"@storybook/addon-viewport": "8.0.10", | ||
"@storybook/addon-webpack5-compiler-babel": "3.0.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now necessary in order to specifically use Babel, see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-babelcore-and-babel-loader-from-storybookbuilder-webpack5 |
||
"@storybook/react": "8.0.10", | ||
"@storybook/react-webpack5": "8.0.10", | ||
"@storybook/source-loader": "8.0.10", | ||
"@storybook/test": "8.0.10", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used to explicitly declare action handler spies, see: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#implicit-actions-can-not-be-used-during-rendering-for-example-in-the-play-function |
||
"@storybook/theming": "8.0.10", | ||
"@testing-library/jest-dom": "5.16.5", | ||
"@testing-library/react": "14.3.0", | ||
"@testing-library/react-native": "12.4.3", | ||
|
@@ -156,7 +158,7 @@ | |
"snapshot-diff": "0.10.0", | ||
"source-map-loader": "3.0.0", | ||
"sprintf-js": "1.1.1", | ||
"storybook": "7.6.15", | ||
"storybook": "8.0.10", | ||
"storybook-source-link": "2.0.9", | ||
"strip-json-comments": "5.0.0", | ||
"style-loader": "3.2.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import { fn } from '@storybook/test'; | ||
|
||
/** | ||
* WordPress dependencies | ||
|
@@ -44,6 +45,9 @@ const meta: Meta< typeof CustomSelectControlV2 > = { | |
</div> | ||
), | ||
], | ||
args: { | ||
onChange: fn(), | ||
}, | ||
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that adding these lines of code is necessary since we're already specifying Given that I don't think we any Storybook tests, and that we typically use If instead we wanted to change approach and go down the "explicit action spies" route, we'd need to refactor all stories specifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, we seem to need these, otherwise I'm getting an error when navigating to these 3 stories (I tested them all, one by one, manually):
Here's the error: Once I add the action spies, the errors disappear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird. It doesn't make sense to me, since I would then expect this error to appear on a lot more stories. I think the checks a bit buggy (and we may not be the only ones). For the sake of moving forward with the refactor, I'm OK keeping those changes and investigate the reason for the error in a separate follow-up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, and yep, would like to take a look separately. Opened an issue here: #67834 |
||
}; | ||
export default meta; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import { fn } from '@storybook/test'; | ||
|
||
/** | ||
* WordPress dependencies | ||
|
@@ -22,6 +23,9 @@ const meta: Meta< typeof TabPanel > = { | |
controls: { expanded: true }, | ||
docs: { canvas: { sourceState: 'shown' } }, | ||
}, | ||
args: { | ||
onSelect: fn(), | ||
}, | ||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}; | ||
export default meta; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import { fn } from '@storybook/test'; | ||
|
||
/** | ||
* WordPress dependencies | ||
|
@@ -39,6 +40,10 @@ const meta: Meta< typeof Tabs > = { | |
controls: { expanded: true }, | ||
docs: { canvas: { sourceState: 'shown' } }, | ||
}, | ||
args: { | ||
onActiveTabIdChange: fn(), | ||
onSelect: fn(), | ||
}, | ||
Comment on lines
+43
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}; | ||
export default meta; | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for this patch? Is it necessary to migrate to v8 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we need this patch primarily for two reasons:
Support for v8 is in progress but not there yet, so we need the patch to unblock the upgrade temporarily. Hopefully, the v8 support will land soon. And maybe we can lend a hand if that doesn't happen for some reason. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
diff --git a/node_modules/storybook-source-link/dist/esm/Tool.js b/node_modules/storybook-source-link/dist/esm/Tool.js | ||
index 100099e..53d37c4 100644 | ||
--- a/node_modules/storybook-source-link/dist/esm/Tool.js | ||
+++ b/node_modules/storybook-source-link/dist/esm/Tool.js | ||
@@ -1,7 +1,8 @@ | ||
import React from "react"; | ||
-import { Icons, IconButton, TooltipMessage, WithTooltip } from "@storybook/components"; | ||
-import { PARAM_KEY, PREFIX_PARAM_KEY, ICON_PARAM_KEY, INFO_LINK, TOOL_ID } from "./constants"; | ||
-import { useParameter } from '@storybook/api'; | ||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleanup of unused code after the introduced changes. |
||
+import { IconButton, TooltipMessage, WithTooltip } from "@storybook/components"; | ||
+import { RepoIcon } from '@storybook/icons'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is half of the patch: using |
||
+import { PARAM_KEY, PREFIX_PARAM_KEY, INFO_LINK, TOOL_ID } from "./constants"; | ||
+import { useParameter } from '@storybook/manager-api'; | ||
|
||
var Tooltip = function Tooltip() { | ||
return /*#__PURE__*/React.createElement(TooltipMessage, { | ||
@@ -24,7 +25,6 @@ export var getLink = function getLink(prefix, link) { | ||
export var Tool = function Tool() { | ||
var param_link = useParameter(PARAM_KEY, null); | ||
var param_prefix = useParameter(PREFIX_PARAM_KEY, null); | ||
- var param_icon = useParameter(ICON_PARAM_KEY, "repository"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
var link = getLink(param_prefix, param_link); | ||
return link ? /*#__PURE__*/React.createElement(IconButton, { | ||
key: TOOL_ID, | ||
@@ -35,9 +35,7 @@ export var Tool = function Tool() { | ||
window.open(link); | ||
} | ||
} | ||
- }, /*#__PURE__*/React.createElement(Icons, { | ||
- icon: param_icon | ||
- })) : /*#__PURE__*/React.createElement(WithTooltip, { | ||
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now going with a |
||
+ }, /*#__PURE__*/React.createElement(RepoIcon)) : /*#__PURE__*/React.createElement(WithTooltip, { | ||
placement: "top", | ||
trigger: "click", | ||
tooltip: /*#__PURE__*/React.createElement(Tooltip, null) | ||
@@ -45,7 +43,5 @@ export var Tool = function Tool() { | ||
key: TOOL_ID, | ||
title: "View Source Repository", | ||
active: false | ||
- }, /*#__PURE__*/React.createElement(Icons, { | ||
- icon: param_icon | ||
- }))); | ||
Comment on lines
+40
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above - using |
||
+ }, /*#__PURE__*/React.createElement(RepoIcon))); | ||
}; | ||
\ No newline at end of file | ||
diff --git a/node_modules/storybook-source-link/dist/esm/preset/manager.js b/node_modules/storybook-source-link/dist/esm/preset/manager.js | ||
index 845f81d..ca1d066 100644 | ||
--- a/node_modules/storybook-source-link/dist/esm/preset/manager.js | ||
+++ b/node_modules/storybook-source-link/dist/esm/preset/manager.js | ||
@@ -1,4 +1,4 @@ | ||
-import { addons, types } from "@storybook/addons"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other half of the patch: |
||
+import { addons, types } from "@storybook/manager-api"; | ||
import { ADDON_ID, TOOL_ID } from "../constants"; | ||
import { Tool } from "../Tool"; // Register the addon | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ module.exports = { | |
'@storybook/addon-a11y', | ||
'@storybook/addon-toolbars', | ||
'@storybook/addon-actions', | ||
'@storybook/addon-webpack5-compiler-babel', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed in order to opt-in to using Babel explicitly, see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-babelcore-and-babel-loader-from-storybookbuilder-webpack5 |
||
'storybook-source-link', | ||
'@geometricpanda/storybook-addon-badges', | ||
], | ||
|
@@ -64,6 +65,9 @@ module.exports = { | |
docs: { | ||
autodocs: true, | ||
}, | ||
typescript: { | ||
reactDocgen: 'react-docgen-typescript', | ||
}, | ||
Comment on lines
+68
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed since the default in v8 is |
||
webpackFinal: async ( config ) => { | ||
return { | ||
...config, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* External dependencies | ||
*/ | ||
import { | ||
ArgsTable, | ||
Controls, | ||
Description, | ||
Primary, | ||
Stories, | ||
|
@@ -114,8 +114,7 @@ export const parameters = { | |
<Subtitle /> | ||
<Primary /> | ||
<Description /> | ||
{ /* `story="^"` enables Controls for the primary props table */ } | ||
<ArgsTable story="^" /> | ||
<Controls /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<Stories includePrimary={ false } /> | ||
</> | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ const Title = styled.span( { | |
|
||
const Icons = styled.span( {} ); | ||
|
||
const Icon = styled.span( {} ); | ||
const Icon = styled.span( { | ||
lineHeight: 1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to better vertically center the icon in the respective menu item. |
||
} ); | ||
|
||
/** | ||
* Fetches tags from the Storybook API, and returns Icon | ||
|
@@ -41,7 +43,7 @@ function useIcons( item ) { | |
return useMemo( () => { | ||
let data = {}; | ||
|
||
if ( item.isComponent && item.children?.length ) { | ||
if ( item.type === 'component' && item.children?.length ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see this change documented in the changelog, but without it, the badges won't appear - |
||
data = api.getData( item.children[ 0 ] ) ?? {}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ | |
* External dependencies | ||
*/ | ||
import styled from '@emotion/styled'; | ||
import { Icons } from '@storybook/components'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const StyledIcons = styled( Icons )` | ||
const IconWrapper = ( { icon, ...props } ) => { | ||
const IconComponent = icon; | ||
return <IconComponent aria-hidden { ...props } />; | ||
}; | ||
|
||
export const InlineIcon = styled( IconWrapper )` | ||
display: inline-block !important; | ||
width: 14px; | ||
`; | ||
|
||
export const InlineIcon = ( props ) => <StyledIcons aria-hidden { ...props } />; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Meta } from '@storybook/blocks'; | ||
import { RepoIcon } from '@storybook/icons'; | ||
import { InlineIcon } from './inline-icon'; | ||
|
||
<Meta title="Docs/Introduction" name="page" /> | ||
|
@@ -28,7 +29,7 @@ The site shows the individual components in the sidebar and the Canvas on the ri | |
|
||
To view the documentation for each component use the **Docs** menu item in the top toolbar. | ||
|
||
To view the source code for the component and its stories on GitHub, click the <InlineIcon icon="repository" /> View Source Repository button in the top right corner. | ||
To view the source code for the component and its stories on GitHub, click the <InlineIcon icon={ RepoIcon } /> View Source Repository button in the top right corner. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're using |
||
|
||
To use it in your local development environment run the following command in the top level Gutenberg directory: | ||
|
||
|
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.
Needs to be bumped to support v8