Skip to content

Commit a90b85c

Browse files
authored
Merge pull request #2259 from github/koesie10/upgrade-storybook-7
Upgrade to Storybook 7
2 parents d3a5a5e + b830781 commit a90b85c

39 files changed

Lines changed: 30552 additions & 48976 deletions
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StorybookConfig } from "@storybook/core-common";
1+
import type { StorybookConfig } from "@storybook/react-webpack5";
22

33
const config: StorybookConfig = {
44
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
@@ -8,13 +8,13 @@ const config: StorybookConfig = {
88
"@storybook/addon-interactions",
99
"./vscode-theme-addon/preset.ts",
1010
],
11-
framework: "@storybook/react",
12-
core: {
13-
builder: "@storybook/builder-webpack5",
11+
framework: {
12+
name: "@storybook/react-webpack5",
13+
options: {},
1414
},
15-
features: {
16-
babelModeV7: true,
15+
docs: {
16+
autodocs: "tag",
1717
},
1818
};
1919

20-
module.exports = config;
20+
export default config;

extensions/ql-vscode/.storybook/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addons } from "@storybook/addons";
1+
import { addons } from "@storybook/manager-api";
22
import { themes } from "@storybook/theming";
33

44
addons.setConfig({
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1+
import { Preview } from "@storybook/react";
12
import { themes } from "@storybook/theming";
23
import { action } from "@storybook/addon-actions";
34

45
// Allow all stories/components to use Codicons
56
import "@vscode/codicons/dist/codicon.css";
67

8+
(window as any).acquireVsCodeApi = () => ({
9+
postMessage: action("post-vscode-message"),
10+
setState: action("set-vscode-state"),
11+
});
12+
713
// https://storybook.js.org/docs/react/configure/overview#configure-story-rendering
8-
export const parameters = {
9-
// All props starting with `on` will automatically receive an action as a prop
10-
actions: { argTypesRegex: "^on[A-Z].*" },
11-
// All props matching these names will automatically get the correct control
12-
controls: {
13-
matchers: {
14-
color: /(background|color)$/i,
15-
date: /Date$/,
14+
const preview: Preview = {
15+
parameters: {
16+
// All props starting with `on` will automatically receive an action as a prop
17+
actions: { argTypesRegex: "^on[A-Z].*" },
18+
// All props matching these names will automatically get the correct control
19+
controls: {
20+
matchers: {
21+
color: /(background|color)$/i,
22+
date: /Date$/,
23+
},
24+
},
25+
// Use a dark theme to be aligned with VSCode
26+
docs: {
27+
theme: themes.dark,
28+
},
29+
backgrounds: {
30+
// The background is injected by our theme CSS files
31+
disable: true,
1632
},
17-
},
18-
// Use a dark theme to be aligned with VSCode
19-
docs: {
20-
theme: themes.dark,
21-
},
22-
backgrounds: {
23-
// The background is injected by our theme CSS files
24-
disable: true,
2533
},
2634
};
2735

28-
(window as any).acquireVsCodeApi = () => ({
29-
postMessage: action("post-vscode-message"),
30-
setState: action("set-vscode-state"),
31-
});
36+
export default preview;

extensions/ql-vscode/.storybook/vscode-theme-addon/ThemeSelector.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import * as React from "react";
22
import { FunctionComponent, useCallback } from "react";
33

4-
import { useGlobals } from "@storybook/api";
4+
import { useGlobals } from "@storybook/manager-api";
55
import {
66
IconButton,
77
Icons,
8-
WithTooltip,
98
TooltipLinkList,
10-
Link,
11-
WithHideFn,
9+
WithTooltip,
1210
} from "@storybook/components";
1311

1412
import { themeNames, VSCodeTheme } from "./theme";
@@ -26,7 +24,7 @@ export const ThemeSelector: FunctionComponent = () => {
2624
);
2725

2826
const createLinks = useCallback(
29-
(onHide: () => void): Link[] =>
27+
(onHide: () => void) =>
3028
Object.values(VSCodeTheme).map((theme) => ({
3129
id: theme,
3230
onClick() {
@@ -44,8 +42,8 @@ export const ThemeSelector: FunctionComponent = () => {
4442
<WithTooltip
4543
placement="top"
4644
trigger="click"
47-
closeOnClick
48-
tooltip={({ onHide }: WithHideFn) => (
45+
closeOnOutsideClick
46+
tooltip={({ onHide }: { onHide: () => void }) => (
4947
<TooltipLinkList links={createLinks(onHide)} />
5048
)}
5149
>

extensions/ql-vscode/.storybook/vscode-theme-addon/manager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import { addons, types } from "@storybook/addons";
2+
import { addons, types } from "@storybook/manager-api";
33
import { ThemeSelector } from "./ThemeSelector";
44

55
const ADDON_ID = "vscode-theme-addon";

extensions/ql-vscode/.storybook/vscode-theme-addon/preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function config(entry = []) {
1+
export function previewAnnotations(entry = []) {
22
return [...entry, require.resolve("./preview.ts")];
33
}
44

extensions/ql-vscode/.storybook/vscode-theme-addon/withTheme.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { useEffect, useGlobals } from "@storybook/addons";
1+
import { useEffect } from "react";
22
import type {
3-
AnyFramework,
43
PartialStoryFn as StoryFunction,
54
StoryContext,
65
} from "@storybook/csf";
@@ -34,11 +33,8 @@ const themeFiles: { [key in VSCodeTheme]: string } = {
3433
.default,
3534
};
3635

37-
export const withTheme = (
38-
StoryFn: StoryFunction<AnyFramework>,
39-
context: StoryContext<AnyFramework>,
40-
) => {
41-
const [{ vscodeTheme }] = useGlobals();
36+
export const withTheme = (StoryFn: StoryFunction, context: StoryContext) => {
37+
const { vscodeTheme } = context.globals;
4238

4339
useEffect(() => {
4440
const styleSelectorId =

0 commit comments

Comments
 (0)