From c3925f507f902a7512f1358729e33ee9c5ea0b1b Mon Sep 17 00:00:00 2001 From: Tasso Date: Mon, 14 Oct 2024 17:43:42 -0300 Subject: [PATCH] Recover storybooks from `@rocket.chat/ui-video-conf` and `@rocket.chat/ui-voip` --- packages/ui-video-conf/.babelrc.json | 9 + packages/ui-video-conf/.eslintrc.json | 2 +- packages/ui-video-conf/.storybook/main.js | 12 -- packages/ui-video-conf/.storybook/main.ts | 38 ++++ .../.storybook/preview.tsx} | 9 +- packages/ui-video-conf/jest.config.ts | 7 +- packages/ui-video-conf/package.json | 27 +-- .../VideoConfButton/VideoConfButton.spec.tsx | 6 +- .../VideoConfButton.stories.tsx | 7 +- .../VideoConfController.spec.tsx | 6 +- .../VideoConfController.stories.tsx | 6 +- .../VideoConfMessage.spec.tsx | 6 +- .../VideoConfMessage.stories.tsx | 14 +- .../src/VideoConfMessage/VideoConfMessage.tsx | 1 + .../VideoConfMessageUserStack.tsx | 2 +- .../VideoConfPopup/VideoConfPopup.spec.tsx | 6 +- .../VideoConfPopup/VideoConfPopup.stories.tsx | 29 ++- .../src/VideoConfPopup/VideoConfPopup.tsx | 8 +- packages/ui-video-conf/tsconfig.json | 4 +- packages/ui-voip/.babelrc.json | 9 + packages/ui-voip/.storybook/main.js | 12 -- packages/ui-voip/.storybook/main.ts | 37 ++++ .../.storybook/preview.tsx} | 9 +- packages/ui-voip/package.json | 26 +-- .../VoipActionButton.stories.tsx | 12 +- .../VoipActionButton/VoipActionButton.tsx | 4 +- .../VoipActions/VoipActions.stories.tsx | 12 +- .../VoipContactId/VoipContactId.stories.tsx | 14 +- .../VoipDialPad/VoipDialPad.stories.tsx | 8 +- .../components/VoipPopup/VoipPopup.spec.tsx | 2 +- .../VoipPopup/VoipPopup.stories.tsx | 12 +- .../hooks/useVoipDeviceSettings.tsx | 2 +- packages/ui-voip/src/tests/mocks/index.ts | 4 +- packages/ui-voip/tsconfig.json | 2 +- yarn.lock | 166 ++++++++++++------ 35 files changed, 340 insertions(+), 190 deletions(-) create mode 100644 packages/ui-video-conf/.babelrc.json delete mode 100644 packages/ui-video-conf/.storybook/main.js create mode 100644 packages/ui-video-conf/.storybook/main.ts rename packages/{ui-voip/.storybook/preview.js => ui-video-conf/.storybook/preview.tsx} (66%) create mode 100644 packages/ui-voip/.babelrc.json delete mode 100644 packages/ui-voip/.storybook/main.js create mode 100644 packages/ui-voip/.storybook/main.ts rename packages/{ui-video-conf/.storybook/preview.js => ui-voip/.storybook/preview.tsx} (68%) diff --git a/packages/ui-video-conf/.babelrc.json b/packages/ui-video-conf/.babelrc.json new file mode 100644 index 0000000000000..f474986efbca9 --- /dev/null +++ b/packages/ui-video-conf/.babelrc.json @@ -0,0 +1,9 @@ +{ + "presets": [ + "@babel/preset-env", + ["@babel/preset-react", { + "runtime": "automatic" + }], + "@babel/preset-typescript" + ] +} diff --git a/packages/ui-video-conf/.eslintrc.json b/packages/ui-video-conf/.eslintrc.json index cbaa27e73b96c..b05b092e98ade 100644 --- a/packages/ui-video-conf/.eslintrc.json +++ b/packages/ui-video-conf/.eslintrc.json @@ -49,7 +49,7 @@ "files": ["*.ts", "*.tsx"], "rules": { "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/indent": "off", "@typescript-eslint/no-extra-parens": "off", "@typescript-eslint/no-explicit-any": "off", diff --git a/packages/ui-video-conf/.storybook/main.js b/packages/ui-video-conf/.storybook/main.js deleted file mode 100644 index dc95f3584a3f9..0000000000000 --- a/packages/ui-video-conf/.storybook/main.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @type {import('@storybook/react/types').StorybookConfig} */ -module.exports = { - stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], - addons: ['@storybook/addon-essentials', '@storybook/addon-a11y'], - framework: '@storybook/react', - features: { - postcss: false, - }, - typescript: { - reactDocgen: 'react-docgen-typescript-plugin', - }, -}; diff --git a/packages/ui-video-conf/.storybook/main.ts b/packages/ui-video-conf/.storybook/main.ts new file mode 100644 index 0000000000000..e3f4381d1ddb8 --- /dev/null +++ b/packages/ui-video-conf/.storybook/main.ts @@ -0,0 +1,38 @@ +import { dirname, join, resolve } from 'path'; + +import type { StorybookConfig } from '@storybook/react-webpack5'; + +export default { + stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], + addons: [ + getAbsolutePath('@storybook/addon-essentials'), + getAbsolutePath('@storybook/addon-a11y'), + getAbsolutePath('@storybook/addon-webpack5-compiler-babel'), + getAbsolutePath('@storybook/addon-styling-webpack'), + ], + + framework: { + name: getAbsolutePath('@storybook/react-webpack5'), + options: {}, + }, + + typescript: { + reactDocgen: 'react-docgen', + }, + + docs: {}, + + webpackFinal: (config) => { + // This is only needed because of Fontello + config.resolve = { + ...config.resolve, + roots: [...(config.resolve?.roots ?? []), resolve(__dirname, '../../../apps/meteor/public')], + }; + + return config; + }, +} satisfies StorybookConfig; + +function getAbsolutePath(value: any): string { + return dirname(require.resolve(join(value, 'package.json'))); +} diff --git a/packages/ui-voip/.storybook/preview.js b/packages/ui-video-conf/.storybook/preview.tsx similarity index 66% rename from packages/ui-voip/.storybook/preview.js rename to packages/ui-video-conf/.storybook/preview.tsx index d1e44f0c2b8c0..20914d6a3d22c 100644 --- a/packages/ui-voip/.storybook/preview.js +++ b/packages/ui-video-conf/.storybook/preview.tsx @@ -1,9 +1,11 @@ +import type { Decorator } from '@storybook/react'; +import type { ReactElement } from 'react'; + import '../../../apps/meteor/app/theme/client/main.css'; import 'highlight.js/styles/github.css'; import '@rocket.chat/icons/dist/rocketchat.css'; export const parameters = { - actions: { argTypesRegex: '^on[A-Z].*' }, controls: { matchers: { color: /(background|color)$/i, @@ -12,8 +14,8 @@ export const parameters = { }, }; -export const decorators = [ - (Story) => ( +export const decorators: Decorator[] = [ + (Story): ReactElement => (