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

refactor: migrate storybook from v5 to v8 and update component stories #51

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ShriD2003
Copy link

@ShriD2003 ShriD2003 commented Aug 21, 2024

Description

Storybook Upgrade:

  • Migrated from Storybook v5 to v8, ensuring compatibility with the latest features and improvements.
  • Updated configurations making Storybook functional again.

Story Updates:

  • Refactored existing stories to use the latest Storybook syntax, transitioning from the storiesOf API to the new CSF (Component Story Format).
  • Replaced deprecated addons like @storybook/addon-knobs with equivalents such as @storybook/addon-controls for a more streamlined and maintainable approach.

Playwright and CI Integration

-Added Playwright configuration to enable automated end-to-end testing within the project.
-CI Integration: Configured the CI pipeline to automatically build Storybook and run tests against it using concurrently, http-server, and wait-on to ensure that all components are thoroughly tested within the Storybook environment during the CI process.

Additional Changes:

  • Added accessibility checks into the updated stories, improving our compliance with accessibility standards.
  • Updated the webpack configuration to better handle TypeScript, LESS, and other assets in the Storybook environment.

Gif

PRGIF-Storybook-Graphql-react

@ShriD2003 ShriD2003 changed the title Migrate Storybook from v5 to v8 and Update Component Stories refactor: migrate storybook from v5 to v8 and update component stories Aug 21, 2024
@@ -81,6 +81,7 @@
"@lingui/react": "^4.11.2",
"@redux-devtools/extension": "^3.2.2",
"@reduxjs/toolkit": "^1.8.0",
"@storybook/addon-a11y": "^8.2.9",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this in dependencies ? It should go to dev dependency ?

Copy link
Author

Choose a reason for hiding this comment

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

Right, Thank you for pointing that out! I've moved it to devDependencies as suggested.

@@ -219,8 +227,8 @@
"react-floki": "^1.0.70",
"rimraf": "2.6.3",
"shelljs": "0.8.3",
"storybook-addon-intl": "^2.4.1",
"storybook-addon-smart-knobs": "^5.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not required now ? Why is this removed ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is not required. As of versions > v6 we can now use @storybook/addon-controls for dynamically editing props, therefore eliminating the need for an additional addon-smart-knobs

Copy link
Collaborator

Choose a reason for hiding this comment

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

@storybook/addon-controls is required to be added or it comes by default ?

Copy link
Author

Choose a reason for hiding this comment

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

@storybook/addon-controls needs to be added ( recommended )

@@ -33,6 +33,5 @@ module.exports = ({ config }) => {
});
config.resolve.modules.push('app');
config.resolve.extensions.push('.js', '.jsx', '.react.js');
config.module.rules[0].use[0].options.plugins = [require.resolve('babel-plugin-react-docgen')];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is removed because the doc generation is done by default on the new version ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes , Post v6 doc-gen support is by default.

Comment on lines 1 to 20
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
addons: [
'@storybook/addon-webpack5-compiler-swc',
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
'storybook-addon-intl'
],
framework: {
name: '@storybook/react-webpack5',
options: {}
},
stories: ['../app/components/**/stories/**/*.mdx', '../app/components/**/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)']
};
export default config;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also can we add the configuration to auto generate docs

docs: {
autodocs: true
},

Copy link
Author

Choose a reason for hiding this comment

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

Right, done !

Comment on lines 1 to 20
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
addons: [
'@storybook/addon-webpack5-compiler-swc',
'@storybook/addon-onboarding',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
'storybook-addon-intl'
],
framework: {
name: '@storybook/react-webpack5',
options: {}
},
stories: ['../app/components/**/stories/**/*.mdx', '../app/components/**/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)']
};
export default config;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to also add support for lingui. Because we move from react intl to lingui

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Right, Thank you for pointing that out! I've now added support for lingui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants