Skip to content
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
64 changes: 63 additions & 1 deletion packages/fuselage-ui-kit/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
{
"extends": ["@rocket.chat/eslint-config", "@rocket.chat/eslint-config/react"]
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"@rocket.chat/eslint-config/original",
"@rocket.chat/eslint-config/react",
"prettier",
"plugin:anti-trojan-source/recommended",
"plugin:react/jsx-runtime",
"plugin:storybook/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"func-call-spacing": "off",
"import/named": "error",
"import/order": [
"error",
{
"newlines-between": "always",
"groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
"alphabetize": {
"order": "asc"
}
}
],
"indent": "off",
"jsx-quotes": ["error", "prefer-single"],
"new-cap": ["error"],
"no-extra-parens": "off",
"no-spaced-func": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-useless-constructor": "off",
"no-use-before-define": "off",
"prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
"prettier/prettier": 2
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".ts", ".tsx"]
}
}
},
"ignorePatterns": ["**/dist"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/prefer-optional-chain": "warn"
}
}
]
}
1 change: 0 additions & 1 deletion packages/fuselage-ui-kit/.prettierrc.js

This file was deleted.

18 changes: 7 additions & 11 deletions packages/fuselage-ui-kit/.storybook/DocsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';

const channel = addons.getChannel();

const DocsContainer = (
props: ComponentPropsWithoutRef<typeof BaseContainer>,
) => {
const [isDark, setDark] = useState(false);
const DocsContainer = (props: ComponentPropsWithoutRef<typeof BaseContainer>) => {
const [isDark, setDark] = useState(false);

useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, setDark);
return () => channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
}, [setDark]);
useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, setDark);
return () => channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
}, [setDark]);

return (
<BaseContainer {...props} theme={isDark ? themes.dark : themes.light} />
);
return <BaseContainer {...props} theme={isDark ? themes.dark : themes.light} />;
};

export default DocsContainer;
4 changes: 2 additions & 2 deletions packages/fuselage-ui-kit/.storybook/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const surface = {
sidebar: '#2F343D',
main: '#262931',
sidebar: '#2F343D',
main: '#262931',
};
32 changes: 16 additions & 16 deletions packages/fuselage-ui-kit/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ import { dirname, join } from 'path';
import type { StorybookConfig } from '@storybook/react-webpack5';

export default {
stories: ['../src/**/*.stories.tsx', '../src/**/stories.tsx'],
stories: ['../src/**/*.stories.tsx', '../src/**/stories.tsx'],

addons: [
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('storybook-dark-mode'),
'./webpackAddon',
getAbsolutePath('@storybook/addon-styling-webpack'),
],
addons: [
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('storybook-dark-mode'),
'./webpackAddon',
getAbsolutePath('@storybook/addon-styling-webpack'),
],

framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},

typescript: {
reactDocgen: 'react-docgen',
},
typescript: {
reactDocgen: 'react-docgen',
},

docs: {},
docs: {},
} satisfies StorybookConfig;

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
return dirname(require.resolve(join(value, 'package.json')));
}
86 changes: 43 additions & 43 deletions packages/fuselage-ui-kit/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,55 @@ import '@rocket.chat/icons/dist/rocketchat.css';
import 'normalize.css/normalize.css';

export const parameters: Parameters = {
backgrounds: {
grid: {
cellSize: 4,
cellAmount: 4,
opacity: 0.5,
},
},
options: {
storySort: {
method: 'alphabetical',
},
},
layout: 'fullscreen',
docs: {
container: DocsContainer,
},
darkMode: {
dark: {
...themes.dark,
appBg: surface.sidebar,
appContentBg: surface.main,
barBg: surface.main,
brandTitle: manifest.name,
brandImage: logo,
brandUrl: manifest.homepage,
},
light: {
...themes.normal,
brandTitle: manifest.name,
brandImage: logo,
brandUrl: manifest.homepage,
},
},
backgrounds: {
grid: {
cellSize: 4,
cellAmount: 4,
opacity: 0.5,
},
},
options: {
storySort: {
method: 'alphabetical',
},
},
layout: 'fullscreen',
docs: {
container: DocsContainer,
},
darkMode: {
dark: {
...themes.dark,
appBg: surface.sidebar,
appContentBg: surface.main,
barBg: surface.main,
brandTitle: manifest.name,
brandImage: logo,
brandUrl: manifest.homepage,
},
light: {
...themes.normal,
brandTitle: manifest.name,
brandImage: logo,
brandUrl: manifest.homepage,
},
},
};

const queryClient = new QueryClient();

export const decorators: Decorator[] = [
(fn) => {
const dark = useDarkMode();
(fn) => {
const dark = useDarkMode();

return (
<>
<PaletteStyleTag theme={dark ? 'dark' : 'light'} />
{fn()}
</>
);
},
(fn) => <QueryClientProvider client={queryClient} children={fn()} />,
return (
<>
<PaletteStyleTag theme={dark ? 'dark' : 'light'} />
{fn()}
</>
);
},
(fn) => <QueryClientProvider client={queryClient} children={fn()} />,
];

export const tags = ['autodocs'];
14 changes: 7 additions & 7 deletions packages/fuselage-ui-kit/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import client from '@rocket.chat/jest-presets/client';
import type { Config } from 'jest';

export default {
preset: client.preset,
setupFilesAfterEnv: [...client.setupFilesAfterEnv],
moduleNameMapper: {
'^react($|/.+)': '<rootDir>/../../node_modules/react$1',
'^react-dom($|/.+)': '<rootDir>/../../node_modules/react-dom$1',
'^react-i18next($|/.+)': '<rootDir>/../../node_modules/react-i18next$1',
},
preset: client.preset,
setupFilesAfterEnv: [...client.setupFilesAfterEnv],
moduleNameMapper: {
'^react($|/.+)': '<rootDir>/../../node_modules/react$1',
'^react-dom($|/.+)': '<rootDir>/../../node_modules/react-dom$1',
'^react-i18next($|/.+)': '<rootDir>/../../node_modules/react-i18next$1',
},
} satisfies Config;
2 changes: 0 additions & 2 deletions packages/fuselage-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@rocket.chat/icons": "^0.43.0",
"@rocket.chat/jest-presets": "workspace:~",
"@rocket.chat/mock-providers": "workspace:^",
"@rocket.chat/prettier-config": "~0.31.25",
"@rocket.chat/styled": "~0.32.0",
"@rocket.chat/tsconfig": "workspace:*",
"@rocket.chat/ui-avatar": "workspace:^",
Expand Down Expand Up @@ -105,7 +104,6 @@
"@rocket.chat/fuselage-hooks": "*",
"@rocket.chat/fuselage-polyfills": "*",
"@rocket.chat/icons": "*",
"@rocket.chat/prettier-config": "*",
"@rocket.chat/styled": "*",
"@rocket.chat/ui-avatar": "workspace:^",
"@rocket.chat/ui-contexts": "workspace:^",
Expand Down
42 changes: 18 additions & 24 deletions packages/fuselage-ui-kit/src/blocks/ActionsBlock.Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,28 @@ import * as UiKit from '@rocket.chat/ui-kit';
import type { ReactElement } from 'react';

type ActionProps = {
element: UiKit.ActionsBlock['elements'][number];
parser: UiKit.SurfaceRenderer<ReactElement>;
index: number;
element: UiKit.ActionsBlock['elements'][number];
parser: UiKit.SurfaceRenderer<ReactElement>;
index: number;
};

const Action = ({
element,
parser,
index,
}: ActionProps): ReactElement | null => {
const renderedElement = parser.renderActionsBlockElement(element, index);
const Action = ({ element, parser, index }: ActionProps): ReactElement | null => {
const renderedElement = parser.renderActionsBlockElement(element, index);

if (!renderedElement) {
return null;
}
if (!renderedElement) {
return null;
}

return (
<Box
display='flex'
margin={4}
flexGrow={element.type !== UiKit.BlockElementType.BUTTON ? 1 : undefined}
flexBasis={
element.type !== UiKit.BlockElementType.BUTTON ? '45%' : undefined
}
>
{renderedElement}
</Box>
);
return (
<Box
display='flex'
margin={4}
flexGrow={element.type !== UiKit.BlockElementType.BUTTON ? 1 : undefined}
flexBasis={element.type !== UiKit.BlockElementType.BUTTON ? '45%' : undefined}
>
{renderedElement}
</Box>
);
};

export default Action;
Loading
Loading