Skip to content

Commit 86436db

Browse files
committed
refactor(livechat): disable multiple components per module
1 parent 2994cc7 commit 86436db

84 files changed

Lines changed: 1542 additions & 1107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,6 @@ export default [
394394
pragmaFrag: 'Fragment',
395395
},
396396
},
397-
rules: {
398-
'react/no-multi-comp': 'warn',
399-
},
400397
},
401398
{
402399
ignores: ['packages/node-poplib/**', 'packages/storybook-config/*.@(d.ts|js)', 'scripts/**', '.github/**', '.houston/**'],

packages/livechat/src/components/Avatar/stories.tsx renamed to packages/livechat/src/components/Avatar/Avatar.stories.tsx

File renamed without changes.

packages/livechat/src/components/ButtonGroup/stories.tsx renamed to packages/livechat/src/components/ButtonGroup/ButtonGroup.stories.tsx

File renamed without changes.

packages/livechat/src/components/FilesDropTarget/stories.tsx renamed to packages/livechat/src/components/FilesDropTarget/FilesDropTarget.stories.tsx

File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { CSSProperties } from 'preact/compat';
2+
3+
import styles from './styles.scss';
4+
import { createClassName } from '../../helpers/createClassName';
5+
6+
export type CharCounterProps = {
7+
className?: string;
8+
style?: CSSProperties;
9+
textLength: number;
10+
limitTextLength: number;
11+
};
12+
13+
const CharCounter = ({ className, style = {}, textLength, limitTextLength }: CharCounterProps) => (
14+
<span className={createClassName(styles, 'footer__remainder', { highlight: textLength === limitTextLength }, [className])} style={style}>
15+
{textLength} / {limitTextLength}
16+
</span>
17+
);
18+
19+
export default CharCounter;

packages/livechat/src/components/Footer/stories.tsx renamed to packages/livechat/src/components/Footer/Footer.stories.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { action } from '@storybook/addon-actions';
22
import type { Meta, StoryFn } from '@storybook/preact';
33
import type { ComponentProps } from 'preact';
44

5-
import { Footer, FooterContent, FooterOptions, PoweredBy } from '.';
65
import ChangeIcon from '../../icons/change.svg';
76
import FinishIcon from '../../icons/finish.svg';
87
import RemoveIcon from '../../icons/remove.svg';
98
import { Composer } from '../Composer';
10-
import Menu from '../Menu';
9+
import { MenuGroup, MenuItem } from '../Menu';
1110
import { PopoverContainer } from '../Popover';
12-
11+
import Footer from './Footer';
12+
import FooterContent from './FooterContent';
13+
import FooterOptions from './FooterOptions';
14+
import PoweredBy from './PoweredBy';
1315
import '../../i18next';
1416

1517
export default {
@@ -46,17 +48,17 @@ export const WithComposerAndOptions: StoryFn<ComponentProps<typeof Footer>> = (a
4648
</FooterContent>
4749
<FooterContent>
4850
<FooterOptions>
49-
<Menu.Group>
50-
<Menu.Item onClick={action('change-department')} icon={ChangeIcon}>
51+
<MenuGroup>
52+
<MenuItem onClick={action('change-department')} icon={ChangeIcon}>
5153
Change department
52-
</Menu.Item>
53-
<Menu.Item onClick={action('remove-user-data')} icon={RemoveIcon}>
54+
</MenuItem>
55+
<MenuItem onClick={action('remove-user-data')} icon={RemoveIcon}>
5456
Forget/Remove my personal data
55-
</Menu.Item>
56-
<Menu.Item danger onClick={action('finish-chat')} icon={FinishIcon}>
57+
</MenuItem>
58+
<MenuItem danger onClick={action('finish-chat')} icon={FinishIcon}>
5759
Finish this chat
58-
</Menu.Item>
59-
</Menu.Group>
60+
</MenuItem>
61+
</MenuGroup>
6062
</FooterOptions>
6163
<PoweredBy />
6264
</FooterContent>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ComponentChildren } from 'preact';
2+
3+
import styles from './styles.scss';
4+
import { createClassName } from '../../helpers/createClassName';
5+
6+
export type FooterProps = {
7+
children: ComponentChildren;
8+
className?: string;
9+
};
10+
11+
const Footer = ({ children, className, ...props }: FooterProps) => (
12+
<footer className={createClassName(styles, 'footer', {}, [className])} {...props}>
13+
{children}
14+
</footer>
15+
);
16+
17+
export default Footer;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ComponentChildren } from 'preact';
2+
3+
import styles from './styles.scss';
4+
import { createClassName } from '../../helpers/createClassName';
5+
6+
export type FooterContentProps = {
7+
children: ComponentChildren;
8+
className?: string;
9+
};
10+
11+
const FooterContent = ({ children, className, ...props }: FooterContentProps) => (
12+
<div className={createClassName(styles, 'footer__content', {}, [className])} {...props}>
13+
{children}
14+
</div>
15+
);
16+
17+
export default FooterContent;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ComponentChildren } from 'preact';
2+
3+
import { MenuPopover } from '../Menu';
4+
import OptionsTrigger from './OptionsTrigger';
5+
6+
export type FooterOptionsProps = {
7+
children: ComponentChildren;
8+
};
9+
10+
const FooterOptions = ({ children }: FooterOptionsProps) => (
11+
<MenuPopover trigger={OptionsTrigger} overlayed>
12+
{children}
13+
</MenuPopover>
14+
);
15+
16+
export default FooterOptions;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { type MouseEventHandler } from 'preact/compat';
2+
import { useTranslation } from 'react-i18next';
3+
4+
import styles from './styles.scss';
5+
import { createClassName } from '../../helpers/createClassName';
6+
7+
const handleMouseUp: MouseEventHandler<HTMLButtonElement> = ({ target }) => (target as HTMLButtonElement | null)?.blur();
8+
9+
type OptionsTriggerProps = {
10+
pop: () => void;
11+
};
12+
13+
const OptionsTrigger = ({ pop }: OptionsTriggerProps) => {
14+
const { t } = useTranslation();
15+
16+
return (
17+
<button className={createClassName(styles, 'footer__options')} onClick={pop} onMouseUp={handleMouseUp}>
18+
{t('options')}
19+
</button>
20+
);
21+
};
22+
23+
export default OptionsTrigger;

0 commit comments

Comments
 (0)