From 867d998d15d312170432ef39c16c0de661c56d08 Mon Sep 17 00:00:00 2001 From: Robert Pintilii Date: Wed, 27 Jul 2022 12:33:50 +0300 Subject: [PATCH] ref(participants-pane) Use new button component (#11913) --- .../components/buttons/QuickActionButton.js | 67 ------------------ react/features/base/components/index.js | 1 - .../base/ui/components/web/Button.tsx | 17 ++++- ...ionButton.js => JoinQuickActionButton.tsx} | 30 ++++---- .../components/web/RoomActionEllipsis.js | 40 ----------- .../components/web/RoomActionEllipsis.tsx | 27 +++++++ .../components/web/LobbyParticipantItem.js | 30 ++++---- .../web/LobbyParticipantQuickAction.js | 70 ------------------- .../web/ParticipantActionEllipsis.js | 43 ------------ .../web/ParticipantActionEllipsis.tsx | 27 +++++++ ...ckAction.js => ParticipantQuickAction.tsx} | 26 +++---- 11 files changed, 116 insertions(+), 262 deletions(-) delete mode 100644 react/features/base/components/buttons/QuickActionButton.js rename react/features/participants-pane/components/breakout-rooms/components/web/{JoinQuickActionButton.js => JoinQuickActionButton.tsx} (59%) delete mode 100644 react/features/participants-pane/components/breakout-rooms/components/web/RoomActionEllipsis.js create mode 100644 react/features/participants-pane/components/breakout-rooms/components/web/RoomActionEllipsis.tsx delete mode 100644 react/features/participants-pane/components/web/LobbyParticipantQuickAction.js delete mode 100644 react/features/participants-pane/components/web/ParticipantActionEllipsis.js create mode 100644 react/features/participants-pane/components/web/ParticipantActionEllipsis.tsx rename react/features/participants-pane/components/web/{ParticipantQuickAction.js => ParticipantQuickAction.tsx} (79%) diff --git a/react/features/base/components/buttons/QuickActionButton.js b/react/features/base/components/buttons/QuickActionButton.js deleted file mode 100644 index 3334a29eb..000000000 --- a/react/features/base/components/buttons/QuickActionButton.js +++ /dev/null @@ -1,67 +0,0 @@ -// @flow - -import { makeStyles } from '@material-ui/styles'; -import React from 'react'; - -type Props = { - - /** - * Label used for accessibility. - */ - accessibilityLabel: string, - - /** - * Additional class name for custom styles. - */ - className: string, - - /** - * Children of the component. - */ - children: string | React$Node, - - /** - * Click handler. - */ - onClick: Function, - - /** - * Data test id. - */ - testId?: string -} - -const useStyles = makeStyles(theme => { - return { - button: { - backgroundColor: theme.palette.action01, - color: theme.palette.text01, - borderRadius: `${theme.shape.borderRadius}px`, - ...theme.typography.labelBold, - lineHeight: `${theme.typography.labelBold.lineHeight}px`, - padding: '8px 12px', - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - border: 0, - - '&:hover': { - backgroundColor: theme.palette.action01Hover - } - } - }; -}); - -const QuickActionButton = ({ accessibilityLabel, className, children, onClick, testId }: Props) => { - const styles = useStyles(); - - return (); -}; - -export default QuickActionButton; diff --git a/react/features/base/components/index.js b/react/features/base/components/index.js index 136e8da53..d862ff40d 100644 --- a/react/features/base/components/index.js +++ b/react/features/base/components/index.js @@ -1,4 +1,3 @@ export { default as ContextMenu } from './context-menu/ContextMenu'; export { default as ContextMenuItemGroup } from './context-menu/ContextMenuItemGroup'; export { default as ListItem } from './participants-pane-list/ListItem'; -export { default as QuickActionButton } from './buttons/QuickActionButton'; diff --git a/react/features/base/ui/components/web/Button.tsx b/react/features/base/ui/components/web/Button.tsx index 0b6b28c61..1af85e7d7 100644 --- a/react/features/base/ui/components/web/Button.tsx +++ b/react/features/base/ui/components/web/Button.tsx @@ -11,6 +11,11 @@ import { ButtonProps } from '../types'; interface IButtonProps extends ButtonProps { + /** + * Class name used for additional styles. + */ + className?: string, + /** * Whether or not the button should be full width. */ @@ -24,12 +29,17 @@ interface IButtonProps extends ButtonProps { /** * Click callback. */ - onClick: () => void; + onClick: (e?: React.MouseEvent) => void; /** * Which size the button should be. */ size?: 'small' | 'medium' | 'large'; + + /** + * Data test id. + */ + testId?: string; } const useStyles = makeStyles((theme: Theme) => { @@ -163,6 +173,7 @@ const useStyles = makeStyles((theme: Theme) => { const Button = ({ accessibilityLabel, + className, disabled, fullWidth, icon, @@ -170,6 +181,7 @@ const Button = ({ label, onClick, size = 'medium', + testId, type = BUTTON_TYPES.PRIMARY }: IButtonProps) => { const styles = useStyles(); @@ -180,7 +192,8 @@ const Button = ({ className = { clsx(styles.button, styles[type], disabled && styles.disabled, icon && !label && `${styles.iconButton} iconButton`, - styles[size], fullWidth && styles.fullWidth) } + styles[size], fullWidth && styles.fullWidth, className) } + data-testid = { testId } disabled = { disabled } { ...(id ? { id } : {}) } onClick = { onClick } diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.js b/react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.tsx similarity index 59% rename from react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.js rename to react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.tsx index a044ff6bb..5275a5c7f 100644 --- a/react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.js +++ b/react/features/participants-pane/components/breakout-rooms/components/web/JoinQuickActionButton.tsx @@ -1,12 +1,14 @@ -// @flow - +/* eslint-disable lines-around-comment */ import { makeStyles } from '@material-ui/styles'; import React, { useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; +// @ts-ignore import { createBreakoutRoomsEvent, sendAnalytics } from '../../../../../analytics'; -import { QuickActionButton } from '../../../../../base/components'; +import Button from '../../../../../base/ui/components/web/Button'; +import { Theme } from '../../../../../base/ui/types'; +// @ts-ignore import { moveToRoom } from '../../../../../breakout-rooms/actions'; type Props = { @@ -14,10 +16,13 @@ type Props = { /** * The room to join. */ - room: Object + room: { + id: string; + jid: string; + } } -const useStyles = makeStyles(theme => { +const useStyles = makeStyles((theme: Theme) => { return { button: { marginRight: `${theme.spacing(2)}px` @@ -36,13 +41,14 @@ const JoinActionButton = ({ room }: Props) => { dispatch(moveToRoom(room.jid)); }, [ dispatch, room ]); - return ( - {t('breakoutRooms.actions.join')} - + return ( +