From 40c8b8fd75c174c2d7dea9906a4812e20704ef87 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:22:39 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20CallButton=20componen?= =?UTF-8?q?t=20and=20integrate=20with=20SendButton=20for=20improved=20mess?= =?UTF-8?q?aging=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Chat/Input/CallButton.tsx | 40 +++++++++++++ client/src/components/Chat/Input/ChatForm.tsx | 1 + .../src/components/Chat/Input/SendButton.tsx | 60 +++++++++++++------ client/src/components/svg/CallIcon.tsx | 30 ++++++++++ client/src/components/svg/index.ts | 1 + 5 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 client/src/components/Chat/Input/CallButton.tsx create mode 100644 client/src/components/svg/CallIcon.tsx diff --git a/client/src/components/Chat/Input/CallButton.tsx b/client/src/components/Chat/Input/CallButton.tsx new file mode 100644 index 0000000000..e8a1f11d65 --- /dev/null +++ b/client/src/components/Chat/Input/CallButton.tsx @@ -0,0 +1,40 @@ +import React, { forwardRef } from 'react'; +import { TooltipAnchor } from '~/components/ui'; +import { SendIcon } from '~/components/svg'; +import { useLocalize } from '~/hooks'; +import { cn } from '~/utils'; + +const Button = React.memo( + forwardRef((props: { disabled: boolean }) => { + const localize = useLocalize(); + return ( + + + + + + } + > + ); + }), +); + +const CallButton = React.memo( + forwardRef((props: { disabled: boolean }) => { + return } /> ); - }), + }, ); -const SendButton = React.memo( - forwardRef((props: SendButtonProps, ref: React.ForwardedRef) => { - const data = useWatch({ control: props.control }); - return ; - }), -); +const SendButton = forwardRef((props: ButtonProps, ref: React.ForwardedRef) => { + const localize = useLocalize(); + const { text } = useWatch({ control: props.control }); + + const buttonProps = text + ? { + icon: , + tooltip: localize('com_nav_send_message'), + testId: 'send-button', + } + : { + icon: , + tooltip: localize('com_nav_call'), + testId: 'call-button', + }; + + return ; +}); + +SendButton.displayName = 'SendButton'; export default SendButton; diff --git a/client/src/components/svg/CallIcon.tsx b/client/src/components/svg/CallIcon.tsx new file mode 100644 index 0000000000..b493a67747 --- /dev/null +++ b/client/src/components/svg/CallIcon.tsx @@ -0,0 +1,30 @@ +import { cn } from '~/utils'; + +export default function CallIcon({ size = 24, className = '' }) { + return ( + + + + + + + ); +} diff --git a/client/src/components/svg/index.ts b/client/src/components/svg/index.ts index 745c5210bd..c430e65052 100644 --- a/client/src/components/svg/index.ts +++ b/client/src/components/svg/index.ts @@ -56,3 +56,4 @@ export { default as SpeechIcon } from './SpeechIcon'; export { default as SaveIcon } from './SaveIcon'; export { default as CircleHelpIcon } from './CircleHelpIcon'; export { default as BedrockIcon } from './BedrockIcon'; +export { default as CallIcon } from './CallIcon';