-
Notifications
You must be signed in to change notification settings - Fork 13
refactor: migrate storybook from v5 to v8 and update component stories #51
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
base: master
Are you sure you want to change the base?
Changes from 7 commits
ecf3b11
928b0af
f2dcd4e
ee61f79
ea3b5e0
5cb4cd9
2076212
1cafb90
07a7757
9cadaa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,5 @@ reports/ | |
| .DS_Store | ||
| npm-debug.log | ||
| .idea | ||
| .tsconfig-lint.json | ||
| .tsconfig-lint.json | ||
| *storybook.log | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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; | ||
|
Collaborator
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 think we need to also add support for lingui. Because we move from react intl to lingui
Collaborator
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. https://github.com/wednesday-solutions/react-template/tree/master/.storybook Refer the files from here
Author
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. Right, Thank you for pointing that out! I've now added support for lingui |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { translationMessages, appLocales, DEFAULT_LOCALE } from '../app/i18n'; | ||
|
|
||
| import type { Preview } from '@storybook/react'; | ||
|
|
||
| type TranslationMessages = { | ||
| [key: string]: { [key: string]: string }; | ||
| }; | ||
|
|
||
| const getMessages = (locale: string) => (translationMessages as TranslationMessages)[locale]; | ||
|
|
||
| const preview: Preview = { | ||
| parameters: { | ||
| controls: { | ||
| matchers: { | ||
| color: /(background|color)$/i, | ||
| date: /Date$/i | ||
| } | ||
| }, | ||
| intl: { | ||
| locales: appLocales, | ||
| defaultLocale: DEFAULT_LOCALE, | ||
| getMessages | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| export default preview; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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')]; | ||
|
Collaborator
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 removed because the doc generation is done by default on the new version ?
Author
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. Yes , Post v6 doc-gen support is by default. |
||
| return config; | ||
| }; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
| import { Meta, Story } from '@storybook/react'; | ||
| import { Clickable } from '../index'; | ||
|
|
||
| export default { | ||
| title: 'Clickable', | ||
| component: Clickable | ||
| }; | ||
|
|
||
| const ClickableTemplate = (args) => <Clickable {...args} />; | ||
|
|
||
| export const ClickableStoryComponent = ClickableTemplate.bind({}); | ||
| ClickableStoryComponent.args = {}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,19 @@ | ||
| /** | ||
| * | ||
| * Stories for Header | ||
| * | ||
| * @see https://github.com/storybookjs/storybook | ||
| * | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import { text } from '@storybook/addon-knobs'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import Header from '../index'; | ||
|
|
||
| storiesOf('Header').add('simple', () => <Header id={text('id', 'Header')} />); | ||
| export default { | ||
| title: 'Header', | ||
| component: Header | ||
| }; | ||
|
|
||
| const HeaderTemplate = (args) => ( | ||
| <MemoryRouter> | ||
| <Header {...args} /> | ||
| </MemoryRouter> | ||
| ); | ||
|
|
||
| export const HeaderStoryComponent = HeaderTemplate.bind({}); | ||
| HeaderStoryComponent.args = { | ||
| id: 'Header' | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,27 @@ | ||
| /** | ||
| * | ||
| * Stories for LaunchList | ||
| * | ||
| * @see https://github.com/storybookjs/storybook | ||
| * | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import { LaunchList } from '../index'; | ||
| import LaunchList from '../index'; | ||
|
|
||
| const loading = false; | ||
| const launchData = { | ||
| launches: [ | ||
| { | ||
| id: '1', | ||
| launchDateUtc: '2014-01-06T14:06:00', | ||
| missionName: 'Thaicom 6', | ||
| links: { | ||
| wikipedia: 'https://en.wikipedia.org/wiki/Thaicom_6', | ||
| flickrImages: ['https://farm9.staticflickr.com/8617/16789019815_f99a165dc5_o.jpg'] | ||
| } | ||
| } | ||
| ] | ||
| export default { | ||
| title: 'LaunchList', | ||
| component: LaunchList | ||
| }; | ||
|
|
||
| storiesOf('LaunchList').add('simple', () => <LaunchList launchData={launchData} loading={loading} />); | ||
| const LaunchListTemplate = (args) => <LaunchList {...args} />; | ||
|
|
||
| export const LaunchListStoryComponent = LaunchListTemplate.bind({}); | ||
| LaunchListStoryComponent.args = { | ||
| launchData: { | ||
| launches: [ | ||
| { | ||
| id: '1', | ||
| launchDateUtc: '2014-01-06T14:06:00', | ||
| missionName: 'Thaicom 6', | ||
| links: { | ||
| wikipedia: 'https://en.wikipedia.org/wiki/Thaicom_6', | ||
| flickrImages: ['https://farm9.staticflickr.com/8617/16789019815_f99a165dc5_o.jpg'] | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| loading: false | ||
| }; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| }, | ||
| "engines": { | ||
| "npm": ">=5", | ||
| "node": ">=8.15.1 <17.9.1" | ||
| "node": ">=8.15.1" | ||
| }, | ||
| "author": "Mac", | ||
| "homepage": "https://github.com/wednesday-solutions/react-graphql-ts-template", | ||
|
|
@@ -25,7 +25,7 @@ | |
| "build:prod": "export ENVIRONMENT_NAME=production && npm run compile-lingui && cross-env NODE_ENV=production webpack --config internals/webpack/webpack.config.prod.js --color --progress --stats-children --stats-error-details", | ||
| "build:dev": "export ENVIRONMENT_NAME=development && cross-env NODE_ENV=production webpack --config internals/webpack/webpack.config.dev.js --color --progress", | ||
| "build:clean": "rimraf ./build", | ||
| "start": "export ENVIRONMENT_NAME=local && concurrently -c green.bold,blue.bold -n WEBPACK,TYPESCRIPT \"cross-env NODE_ENV=development node server\" \"yarn tsc:watch\"", | ||
| "start": "export NODE_OPTIONS=--openssl-legacy-provider ENVIRONMENT_NAME=local && concurrently -c green.bold,blue.bold -n WEBPACK,TYPESCRIPT \"cross-env NODE_ENV=development node server\" \"yarn tsc:watch\"", | ||
| "start:tunnel": "cross-env NODE_ENV=development ENABLE_TUNNEL=true node server", | ||
| "start:production": "npm run test && npm run build:prod && npm run start:prod", | ||
| "start:prod": "cross-env NODE_ENV=production node server", | ||
|
|
@@ -51,8 +51,8 @@ | |
| "create:badges": "jest-coverage-badges --output './badges'", | ||
| "coveralls": "cat ./coverage/lcov.info | coveralls", | ||
| "prettify": "prettier --write", | ||
| "storybook": "export ENVIRONMENT_NAME=development && start-storybook -p 6006", | ||
| "build-storybook": "export ENVIRONMENT_NAME=production && build-storybook", | ||
| "storybook": "storybook dev -p 6006", | ||
| "build-storybook": "storybook build", | ||
| "initialize": "git checkout --orphan temp-branch && git add -A && git commit -m 'Initial commit' && git branch -D master && git branch -m master", | ||
| "generate": "react-generate" | ||
| }, | ||
|
|
@@ -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", | ||
|
Collaborator
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. Why do we need this in dependencies ? It should go to dev dependency ?
Author
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. Right, Thank you for pointing that out! I've moved it to devDependencies as suggested. |
||
| "@testing-library/jest-dom": "^5.16.4", | ||
| "@testing-library/react": "^13.3.0", | ||
| "antd": "^4.9.3", | ||
|
|
@@ -136,18 +137,24 @@ | |
| "@babel/plugin-transform-react-inline-elements": "7.14.5", | ||
| "@babel/preset-env": "^7.14.7", | ||
| "@babel/preset-react": "^7.14.5", | ||
| "@babel/preset-typescript": "^7.16.7", | ||
| "@babel/preset-typescript": "^7.24.7", | ||
| "@babel/register": "7.14.5", | ||
| "@babel/runtime": "^7.14.6", | ||
| "@chromatic-com/storybook": "^1.6.1", | ||
| "@lcdp/offline-plugin": "^5.1.0", | ||
| "@lingui/cli": "^4.11.2", | ||
| "@lingui/format-json": "^4.11.2", | ||
| "@lingui/macro": "^4.11.2", | ||
| "@storybook/addon-actions": "^5.2.1", | ||
| "@storybook/addon-knobs": "^5.2.1", | ||
| "@storybook/addon-links": "^5.2.1", | ||
| "@storybook/addon-onboarding": "^8.2.9", | ||
| "@storybook/addon-webpack5-compiler-swc": "^1.0.5", | ||
| "@storybook/addons": "^5.2.1", | ||
| "@storybook/react": "^5.2.1", | ||
| "@storybook/blocks": "^8.2.9", | ||
| "@storybook/react": "^8.2.9", | ||
| "@storybook/react-webpack5": "^8.2.9", | ||
| "@storybook/test": "^8.2.9", | ||
| "@types/intl": "^1.2.0", | ||
| "@types/invariant": "^2.2.35", | ||
| "@types/lodash-es": "^4.17.6", | ||
|
|
@@ -165,7 +172,7 @@ | |
| "babel-core": "7.0.0-bridge.0", | ||
| "babel-eslint": "10.1.0", | ||
| "babel-jest": "^27.5.1", | ||
| "babel-loader": "^8.2.2", | ||
| "babel-loader": "^9.1.3", | ||
| "babel-plugin-dynamic-import-node": "2.3.3", | ||
| "babel-plugin-import": "^1.13.3", | ||
| "babel-plugin-lodash": "^3.3.4", | ||
|
|
@@ -195,6 +202,7 @@ | |
| "eslint-plugin-react-native": "3.7.0", | ||
| "eslint-plugin-redux-saga": "1.1.3", | ||
| "eslint-plugin-standard": "4.0.1", | ||
| "eslint-plugin-storybook": "^0.8.0", | ||
| "file-loader": "6.2.0", | ||
| "html-loader": "2.1.2", | ||
| "html-webpack-plugin": "5.3.2", | ||
|
|
@@ -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", | ||
|
Collaborator
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 not required now ? Why is this removed ?
Author
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. 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
Collaborator
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. @storybook/addon-controls is required to be added or it comes by default ?
Author
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. @storybook/addon-controls needs to be added ( recommended ) |
||
| "storybook": "^8.2.9", | ||
| "storybook-addon-intl": "^4.0.0", | ||
| "storybook-router": "^0.3.4", | ||
| "style-loader": "2.0.0", | ||
| "stylelint": "10.0.1", | ||
|
|
@@ -229,7 +237,8 @@ | |
| "stylelint-processor-styled-components": "1.6.0", | ||
| "svg-url-loader": "7.1.1", | ||
| "terser-webpack-plugin": "5.1.3", | ||
| "typescript": "^4.6.2", | ||
| "ts-loader": "^9.5.1", | ||
| "typescript": "^5.5.4", | ||
| "url-loader": "4.1.1", | ||
| "webpack": "^5.75.0", | ||
| "webpack-bundle-analyzer": "^4.4.2", | ||
|
|
||
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.
Also can we add the configuration to auto generate docs
docs: {
autodocs: true
},
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.
Right, done !