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: Storybook organization and errors #21923

Merged
merged 1 commit into from
May 10, 2021
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
13 changes: 11 additions & 2 deletions .storybook/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ export const rocketChatDecorator = (fn) => {
};

export const fullHeightDecorator = (storyFn) =>
<div style={{ display: 'flex', flexDirection: 'column', maxHeight: '100vh' }}>
<div style={{
display: 'flex',
flexDirection: 'column',
maxHeight: '100vh',
}}>
{storyFn()}
</div>;

export const centeredDecorator = (storyFn) =>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
minHeight: '100vh',
}}>
{storyFn()}
</div>;
9 changes: 6 additions & 3 deletions .storybook/mocks/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import i18next from 'i18next';
import React from 'react';

import { TranslationContext } from '../../client/contexts/TranslationContext';
import ServerProvider from '../../client/providers/ServerProvider';

let contextValue;

Expand Down Expand Up @@ -61,7 +62,9 @@ function TranslationProviderMock({ children }) {
}

export function MeteorProviderMock({ children }) {
return <TranslationProviderMock>
{children}
</TranslationProviderMock>;
return <ServerProvider>
<TranslationProviderMock>
{children}
</TranslationProviderMock>
</ServerProvider>;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC, CSSProperties } from 'react';

const Body = ({ children, flexDirection = 'row' }) => (
const Body: FC<{ flexDirection: CSSProperties['flexDirection'] }> = ({
children,
flexDirection = 'row',
}) => (
<Box mb='x8' display='flex' flexDirection={flexDirection} flexGrow={1}>
{children}
</Box>
Expand Down
6 changes: 3 additions & 3 deletions client/components/Card/Card.stories.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Box, Button, ButtonGroup } from '@rocket.chat/fuselage';
import React from 'react';

import Card from './Card';
import Card from '.';

export default {
title: 'components/basic/Card',
title: 'components/Card',
component: Card,
};

Expand Down Expand Up @@ -74,7 +74,7 @@ export const Double = () => (
<Card.Icon name='cross' />A bunch of stuff
</Box>
<Box display='flex' flexDirection='row' alignItems='center'>
<Card.Icon name='num-pad' />A bunch of stuff
<Card.Icon name='dialpad' />A bunch of stuff
</Box>
</Box>
<Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const Card = ({ children, ...props }) => (
const Card: FC = ({ children, ...props }) => (
<Box
display='flex'
flexDirection='column'
Expand Down
6 changes: 0 additions & 6 deletions client/components/Card/CardDivider.js

This file was deleted.

6 changes: 6 additions & 0 deletions client/components/Card/CardDivider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Divider } from '@rocket.chat/fuselage';
import React, { FC } from 'react';

const CardDivider: FC = () => <Divider width='x1' mi='x24' mb='none' alignSelf='stretch' />;

export default CardDivider;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Icon } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const CardIcon = ({ name, children, ...props }) => (
const CardIcon: FC<{ name: string }> = ({ name, children, ...props }) => (
<Box
minWidth='x16'
display='inline-flex'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const Col = ({ children }) => (
const Col: FC = ({ children }) => (
<Box display='flex' alignSelf='stretch' w='x228' flexDirection='column' fontScale='c1'>
{children}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const ColSection = ({ children }) => (
const ColSection: FC = ({ children }) => (
<Box mb='x8' color='info'>
{children}
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const ColTitle = ({ children }) => (
const ColTitle: FC = ({ children }) => (
<Box fontScale='c2' m='none'>
{children}
</Box>
Expand Down
6 changes: 0 additions & 6 deletions client/components/Card/Footer.js

This file was deleted.

6 changes: 6 additions & 0 deletions client/components/Card/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Box } from '@rocket.chat/fuselage';
import React, { FC } from 'react';

const Footer: FC = ({ children }) => <Box mb='x8'>{children}</Box>;

export default Footer;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';
import React, { FC } from 'react';

const Title = ({ children }) => (
const Title: FC = ({ children }) => (
<Box mb='x8' fontScale='p2'>
{children}
</Box>
Expand Down
4 changes: 2 additions & 2 deletions client/components/Card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import ColTitle from './ColTitle';
import Footer from './Footer';
import Title from './Title';

export const DOUBLE_COLUMN_CARD_WIDTH = 552;

export default Object.assign(Card, {
Title,
Body,
Expand All @@ -19,5 +21,3 @@ export default Object.assign(Card, {
Divider: CardDivider,
Icon: CardIcon,
});

export const DOUBLE_COLUMN_CARD_WIDTH = 552;
2 changes: 1 addition & 1 deletion client/components/DotLeader.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import DotLeader from './DotLeader';

export default {
title: 'components/basic/DotLeader',
title: 'components/DotLeader',
component: DotLeader,
};

Expand Down
2 changes: 1 addition & 1 deletion client/components/Header/Header.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import RoomAvatar from '../avatar/RoomAvatar';
import Header from './Header';

export default {
title: 'Chat Header',
title: 'room/Header',
component: Header,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Retry from './Retry';

export default {
title: 'Image',
title: 'components/Image',
component: Image,
};

Expand Down
2 changes: 1 addition & 1 deletion client/components/Message/Metrics/Metrics.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Reply from './Reply';
import Metrics from './index';

export default {
title: 'components/Message/Metrics',
title: 'message/Metrics',
component: Metrics,
};

Expand Down
9 changes: 8 additions & 1 deletion client/components/Page/PageScrollableContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ type PageScrollableContentProps = {
const PageScrollableContent = forwardRef<HTMLElement, PageScrollableContentProps>(
function PageScrollableContent({ onScrollContent, ...props }, ref) {
return (
<Box display='flex' flexShrink={1} flexDirection='column' flexGrow={1} overflow='hidden'>
<Box
height='50vh'
display='flex'
flexShrink={1}
flexDirection='column'
flexGrow={1}
overflow='hidden'
>
<ScrollableContentWrapper
onScroll={onScrollContent as CustomScrollbarsProps['onScroll']}
ref={ref as any}
Expand Down
10 changes: 9 additions & 1 deletion client/components/data/Counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ function Counter({ count, variation = 0, description }) {
<>
<Flex.Container alignItems='end'>
<Box>
<Box is='span' color='default' fontScale='h1' style={{ fontSize: '3em', lineHeight: 1 }}>
<Box
is='span'
color='default'
fontScale='h1'
style={{
fontSize: '3em',
lineHeight: 1,
}}
>
{count}
</Box>
<Growth fontScale='s1'>{variation}</Growth>
Expand Down
2 changes: 1 addition & 1 deletion client/lib/asyncState/AsyncStatePhase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum AsyncStatePhase {
export enum AsyncStatePhase {
LOADING = 'loading',
RESOLVED = 'resolved',
REJECTED = 'rejected',
Expand Down
1 change: 1 addition & 0 deletions client/sidebar/Item/Condensed.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { memo, useState } from 'react';
const Condensed = ({
icon,
title = '',
titleIcon,
avatar,
actions,
href,
Expand Down
2 changes: 1 addition & 1 deletion client/sidebar/Item/Condensed.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserAvatar from '../../components/avatar/UserAvatar';
import Condensed from './Condensed';

export default {
title: 'Sidebar/condensed',
title: 'Sidebar/Condensed',
component: Condensed,
};

Expand Down
1 change: 1 addition & 0 deletions client/sidebar/Item/Extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Extended = ({
menu,
menuOptions,
subtitle = '',
titleIcon,
badges,
threadUnread,
unread,
Expand Down
1 change: 0 additions & 1 deletion client/sidebar/Item/Extended.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const Menu = () => (
clickable
title={title}
subtitle={subtitle}
w
titleIcon={<Box mi='x4'>{<Status.Online />}</Box>}
avatar={avatar}
menuOptions={{
Expand Down
1 change: 1 addition & 0 deletions client/sidebar/Item/Medium.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { memo, useState } from 'react';
const Medium = ({
icon,
title = '',
titleIcon,
avatar,
actions,
href,
Expand Down
2 changes: 1 addition & 1 deletion client/sidebar/Item/Medium.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserAvatar from '../../components/avatar/UserAvatar';
import Medium from './Medium';

export default {
title: 'Sidebar/medium',
title: 'Sidebar/Medium',
component: Medium,
};

Expand Down
4 changes: 2 additions & 2 deletions client/sidebar/Sidebar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ const Sidebar = () => (
<>
<SettingsContext.Provider value={settingContextValue}>
<UserContext.Provider value={userContextValue}>
<aside class='sidebar sidebar--main' role='navigation'>
<aside className='sidebar sidebar--main' role='navigation'>
<Header />
<div class='rooms-list sidebar--custom-colors' aria-label='Channels' role='region'>
<div className='rooms-list sidebar--custom-colors' aria-label='Channels' role='region'>
<RoomList />
</div>
</aside>
Expand Down
3 changes: 2 additions & 1 deletion client/sidebar/hooks/useSidebarPaletteColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ const useTheme = () => {
return result;
};

const toVar = (color) => (color[0] === '#' ? color : oldPallet[color] || `var(--${color})`);
const toVar = (color) =>
color && color[0] === '#' ? color : oldPallet[color] || `var(--${color})`;

const getStyle = ((selector) => (colors) => `
${selector} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export const withValue = () => (
_id='setting_id'
label='Label'
placeholder='Placeholder'
value='1'
values={options}
value={[
[1, 'Lorem Ipsum'],
[2, 'Lorem Ipsum'],
]}
/>
);

Expand Down
2 changes: 1 addition & 1 deletion client/views/notFound/NotFoundPage.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import NotFoundPage from './NotFoundPage';

export default {
title: 'views/notFound/NotFoundPage',
title: 'components/NotFoundPage',
component: NotFoundPage,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import DateRangePicker from './DateRangePicker';

export default {
title: 'DateRange',
title: 'components/DateRangePicker',
component: DateRangePicker,
};

Expand Down
2 changes: 1 addition & 1 deletion client/views/omnichannel/installation/Installation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Wrapper from './Wrapper';
const Installation = () => {
const t = useTranslation();

const siteUrl = useSetting('Site_Url').replace(/\/$/, '');
const siteUrl = useSetting('Site_Url')?.replace(/\/$/, '');

const installString = `<!-- Start of Rocket.Chat Livechat Script -->
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion client/views/room/Announcement/Announcement.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Announcement from '.';

export default {
title: 'components/Announcement',
title: 'room/Announcement',
component: Announcement,
};

Expand Down
2 changes: 1 addition & 1 deletion client/views/room/Room.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { RoomTemplate } from './components/RoomTemplate/RoomTemplate';

export default {
title: 'views/Room',
title: 'room',
component: RoomTemplate,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import VerticalBar from '../../../../components/VerticalBar';
import AutoTranslate from './AutoTranslate';

export default {
title: 'components/basic/AutoTranslate',
title: 'room/contextualBar/AutoTranslate',
component: AutoTranslate,
};

Expand Down
Loading