Skip to content
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

chore: update storybook up to v8 #180

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
const config: StorybookConfig = {
framework: {
name: '@storybook/react-webpack5',
options: {fastRefresh: true},
options: {},
},

stories: ['../src/**/*.stories.@(ts|tsx)'],

addons: [
'@storybook/preset-scss',
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
'./theme-addon/register.tsx',
'@storybook/addon-webpack5-compiler-babel',
],

webpackFinal: (storybookBaseConfig) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need these config changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fastRefresh option is removed.

Expand All @@ -23,7 +26,7 @@

// to turn fileName in context.parameters into path form number in production bundle
if (storybookBaseConfig?.optimization) {
storybookBaseConfig.optimization.moduleIds = 'named';

Check warning on line 29 in .storybook/main.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'storybookBaseConfig'
}

return storybookBaseConfig;
Expand Down
2 changes: 1 addition & 1 deletion .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {addons} from '@storybook/addons';
import {addons} from '@storybook/manager-api';

import {themes} from './theme';

Expand Down
3 changes: 1 addition & 2 deletions .storybook/theme-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';

import {getThemeType} from '@gravity-ui/uikit';
import {addons, types} from '@storybook/addons';
import {type API, useGlobals} from '@storybook/api';
import {type API, addons, types, useGlobals} from '@storybook/manager-api';

import {themes} from '../theme';

Expand All @@ -23,6 +22,6 @@
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
}, [theme]);

Check warning on line 25 in .storybook/theme-addon/register.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array
return null;
}
3,402 changes: 1,037 additions & 2,365 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"typecheck": "tsc --noEmit",
"clean": "gulp clean",
"build": "gulp",
"start": "sb dev",
"build-storybook": "sb build -c .storybook -o storybook-static",
"start": "storybook dev",
"build-storybook": "storybook build -c .storybook -o storybook-static",
"prepublishOnly": "npm run build"
},
"dependencies": {
Expand All @@ -58,18 +58,17 @@
"@gravity-ui/stylelint-config": "^4.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
"@gravity-ui/uikit": "^6.3.0",
"@storybook/addon-actions": "^7.6.12",
"@storybook/addon-docs": "^7.6.12",
"@storybook/addon-essentials": "^7.6.12",
"@storybook/addon-viewport": "7.6.12",
"@storybook/addons": "^7.6.12",
"@storybook/api": "^7.6.12",
"@storybook/cli": "^7.6.12",
"@storybook/client-api": "^7.6.12",
"@storybook/addon-actions": "^8.0.6",
"@storybook/addon-docs": "^8.0.6",
"@storybook/addon-essentials": "^8.0.6",
"@storybook/addon-viewport": "^8.0.6",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/cli": "^8.0.6",
"@storybook/manager-api": "^8.0.6",
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "^7.6.12",
"@storybook/react-webpack5": "^7.6.12",
"@storybook/theming": "^7.6.12",
"@storybook/react": "^8.0.6",
"@storybook/react-webpack5": "^8.0.6",
"@storybook/theming": "^8.0.6",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.4.1",
"@testing-library/react": "^14.2.0",
Expand Down Expand Up @@ -97,6 +96,7 @@
"rimraf": "^5.0.5",
"sass": "^1.70.0",
"sass-loader": "^14.1.0",
"storybook": "^8.0.6",
"stylelint": "^15.11.0",
"stylelint-use-logical": "^2.1.0",
"ts-jest": "^29.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {Meta, Story} from '@storybook/react';
import {Meta, StoryFn} from '@storybook/react';

import {ActionsPanel, ActionsPanelProps} from '../../ActionsPanel';

Expand All @@ -11,7 +11,7 @@ export default {
component: ActionsPanel,
} as Meta;

const WithIconsTemplate: Story<ActionsPanelProps> = (args) => {
const WithIconsTemplate: StoryFn<ActionsPanelProps> = (args) => {
return (
<ActionsPanel
{...args}
Expand All @@ -22,7 +22,7 @@ const WithIconsTemplate: Story<ActionsPanelProps> = (args) => {
};
export const WithIcons = WithIconsTemplate.bind({});

const WithNoteTemplate: Story<ActionsPanelProps> = (args) => {
const WithNoteTemplate: StoryFn<ActionsPanelProps> = (args) => {
return (
<ActionsPanel
{...args}
Expand All @@ -34,12 +34,12 @@ const WithNoteTemplate: Story<ActionsPanelProps> = (args) => {
};
export const WithNote = WithNoteTemplate.bind({});

const GroupsTemplate: Story<ActionsPanelProps> = (args) => {
const GroupsTemplate: StoryFn<ActionsPanelProps> = (args) => {
return <ActionsPanel {...args} actions={actionsGroups} />;
};
export const Groups = GroupsTemplate.bind({});

const SubmenuTemplate: Story<ActionsPanelProps> = (args) => {
const SubmenuTemplate: StoryFn<ActionsPanelProps> = (args) => {
return <ActionsPanel {...args} actions={actionsSubmenu} />;
};
export const Submenu = SubmenuTemplate.bind({});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {Meta, Story} from '@storybook/react';
import {Meta, StoryFn} from '@storybook/react';

import {AdaptiveTabs, AdaptiveTabsProps} from '../AdaptiveTabs';

Expand All @@ -17,7 +17,7 @@ export default {
},
},
} as Meta;
const Template: Story<{size: 'm' | 'l' | 'xl'} & AdaptiveTabs<{}>> = (args) => {
const Template: StoryFn<{size: 'm' | 'l' | 'xl'} & AdaptiveTabs<{}>> = (args) => {
const [activeTab, setActiveTab] = React.useState('active');
const items: AdaptiveTabsProps<{}>['items'] = React.useMemo(
() => [
Expand Down Expand Up @@ -59,7 +59,7 @@ const Template: Story<{size: 'm' | 'l' | 'xl'} & AdaptiveTabs<{}>> = (args) => {
};
export const Default = Template.bind({});

const WrapTemplate: Story<AdaptiveTabsProps<{}>> = (args) => {
const WrapTemplate: StoryFn<AdaptiveTabsProps<{}>> = (args) => {
const [activeTab, setActiveTab] = React.useState('active');
const items: AdaptiveTabsProps<{}>['items'] = React.useMemo(
() => [
Expand Down Expand Up @@ -109,7 +109,7 @@ const WrapTemplate: Story<AdaptiveTabsProps<{}>> = (args) => {
};
export const Wrap = WrapTemplate.bind({});

const CustomTabTemplate: Story<AdaptiveTabsProps<{}>> = (args) => {
const CustomTabTemplate: StoryFn<AdaptiveTabsProps<{}>> = (args) => {
const [activeTab, setActiveTab] = React.useState('active');
return (
<div style={{resize: 'horizontal', overflow: 'auto'}}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type {Meta, Story} from '@storybook/react';
import type {Meta, StoryFn} from '@storybook/react';

import {InfiniteScroll} from '../InfiniteScroll';

Expand All @@ -11,5 +11,5 @@ export default {
component: InfiniteScroll,
} as Meta;

export const Playground: Story = () => <InfiniteScrollShowcase />;
export const Playground: StoryFn = () => <InfiniteScrollShowcase />;
Playground.storyName = 'InfiniteScroll';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import {useArgs} from '@storybook/client-api';
import {Meta, Story} from '@storybook/react';
import {useArgs} from '@storybook/manager-api';
import {Meta, StoryFn} from '@storybook/react';

import {ItemSelector, ItemSelectorProps} from '../ItemSelector';

Expand Down Expand Up @@ -56,7 +56,7 @@ export default {
},
} as Meta;

const DefaultTemplate: Story<ItemSelectorProps<{name: string; type: string}>> = (args) => {
const DefaultTemplate: StoryFn<ItemSelectorProps<{name: string; type: string}>> = (args) => {
const [, setStoryArgs] = useArgs();
return (
<ItemSelector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import {GraduationCap} from '@gravity-ui/icons';
import {Button} from '@gravity-ui/uikit';
import {actions} from '@storybook/addon-actions';
import type {Meta, Story} from '@storybook/react';
import type {Meta, StoryFn} from '@storybook/react';

import type {OnboardingMenuProps} from '../OnboardingMenu';
import {OnboardingMenu} from '../OnboardingMenu';
Expand All @@ -16,7 +16,7 @@ export default {
const actionsButtonHandlers = () => actions('onClick').onClick('Click on the button');
const actionsButtonComplete = () => actions('onClick').onClick('Click on the end button');

const DefaultTemplate: Story<OnboardingMenuProps> = (args) => {
const DefaultTemplate: StoryFn<OnboardingMenuProps> = (args) => {
const [expanded, setExpanded] = React.useState(false);

const actionsOnboardingMenuHandlers = (expanded: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {Meta, Story} from '@storybook/react';
import {Meta, StoryFn} from '@storybook/react';

import {PlaceholderContainer} from '../PlaceholderContainer';

Expand All @@ -11,5 +11,5 @@ export default {
component: PlaceholderContainer,
} as Meta;

const ShowcaseTemplate: Story = () => <PlaceholderContainerShowcase />;
const ShowcaseTemplate: StoryFn = () => <PlaceholderContainerShowcase />;
export const Showcase = ShowcaseTemplate.bind({});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type {ComponentMeta, ComponentStory} from '@storybook/react';
import type {Meta, StoryFn} from '@storybook/react';

import {SharePopover, sharePopoverDefaultProps} from '../SharePopover';

Expand All @@ -18,12 +18,12 @@ export default {
},
},
args: {...sharePopoverDefaultProps},
} as ComponentMeta<typeof SharePopover>;
} as Meta<typeof SharePopover>;

const DefaultTemplate: ComponentStory<typeof SharePopover> = (args) => <SharePopover {...args} />;
const DefaultTemplate: StoryFn<typeof SharePopover> = (args) => <SharePopover {...args} />;
export const Default = DefaultTemplate.bind({});

const ShowcaseTemplate: ComponentStory<typeof SharePopover & typeof SharePopoverDemo> = () => (
const ShowcaseTemplate: StoryFn<typeof SharePopover & typeof SharePopoverDemo> = () => (
<SharePopoverDemo />
);
export const Showcase = ShowcaseTemplate.bind({});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import {Platform} from '@gravity-ui/uikit';
import {Meta, Story} from '@storybook/react';
import {Meta, StoryFn} from '@storybook/react';

import {StoreBadge, StoreBadgeProps} from '../StoreBadge';

Expand All @@ -13,11 +13,11 @@ export default {
},
} as Meta;

const Template: Story<StoreBadgeProps> = (args) => <StoreBadge {...args} />;
const Template: StoryFn<StoreBadgeProps> = (args) => <StoreBadge {...args} />;

export const Default = Template.bind({});

const WithHrefTemplate: Story<StoreBadgeProps> = (args) => (
const WithHrefTemplate: StoryFn<StoreBadgeProps> = (args) => (
<StoreBadge {...args} href="https://github.com/gravity-ui/uikit" />
);

Expand Down
Loading