Skip to content

Commit

Permalink
feat: Add 'Cancel Recording' and 'Finish Recording' tooltips for audi…
Browse files Browse the repository at this point in the history
…o/video buttons (#812)
  • Loading branch information
dhairyashiil authored Jan 27, 2025
1 parent c59a25a commit 9d84f49
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 39 deletions.
42 changes: 27 additions & 15 deletions packages/react/src/views/ChatInput/AudioMessageRecorder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { Box, Icon, ActionButton, useTheme } from '@embeddedchat/ui-elements';
import {
Box,
Icon,
ActionButton,
Tooltip,
useTheme,
} from '@embeddedchat/ui-elements';
import { useMediaRecorder } from '../../hooks/useMediaRecorder';
import useMessageStore from '../../store/messageStore';
import { getCommonRecorderStyles } from './ChatInput.styles';
Expand Down Expand Up @@ -131,33 +137,39 @@ const AudioMessageRecorder = ({ disabled }) => {

if (state === 'idle') {
return (
<ActionButton
ghost
square
disabled={disabled}
onClick={handleRecordButtonClick}
>
<Icon size="1.25rem" name="mic" />
</ActionButton>
<Tooltip text="Audio Message" position="top">
<ActionButton
ghost
square
disabled={disabled}
onClick={handleRecordButtonClick}
>
<Icon size="1.25rem" name="mic" />
</ActionButton>
</Tooltip>
);
}

return (
<Box css={styles.controller}>
{state === 'recording' && (
<>
<ActionButton ghost onClick={handleCancelRecordButton}>
<Icon size="1.25rem" name="circle-cross" />
</ActionButton>
<Tooltip text="Cancel Recording" position="top">
<ActionButton ghost onClick={handleCancelRecordButton}>
<Icon size="1.25rem" name="circle-cross" />
</ActionButton>
</Tooltip>
<Box css={styles.record}>
<Box is="span" css={styles.dot} />
<Box is="span" css={styles.timer}>
{time}
</Box>
</Box>
<ActionButton ghost onClick={handleStopRecordButton}>
<Icon name="circle-check" size="1.25rem" />
</ActionButton>
<Tooltip text="Finish Recording" position="top">
<ActionButton ghost onClick={handleStopRecordButton}>
<Icon name="circle-check" size="1.25rem" />
</ActionButton>
</Tooltip>
</>
)}
</Box>
Expand Down
12 changes: 2 additions & 10 deletions packages/react/src/views/ChatInput/ChatInputFormattingToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,8 @@ const ChatInputFormattingToolbar = ({
</ActionButton>
</Tooltip>
),
audio: (
<Tooltip text="Audio Message" position="top" key="audio">
<AudioMessageRecorder disabled={isRecordingMessage} />
</Tooltip>
),
video: (
<Tooltip text="Video Message" position="top" key="video">
<VideoMessageRecorder disabled={isRecordingMessage} />
</Tooltip>
),
audio: <AudioMessageRecorder disabled={isRecordingMessage} key="audio" />,
video: <VideoMessageRecorder disabled={isRecordingMessage} key="video" />,
file: (
<Tooltip text="Upload File" position="top" key="file">
<ActionButton
Expand Down
35 changes: 21 additions & 14 deletions packages/react/src/views/ChatInput/VideoMessageRecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Box,
Icon,
ActionButton,
Tooltip,
Modal,
useTheme,
} from '@embeddedchat/ui-elements';
Expand Down Expand Up @@ -146,14 +147,16 @@ const VideoMessageRecorder = ({ disabled }) => {
return (
<>
{state === 'idle' && (
<ActionButton
ghost
square
disabled={disabled}
onClick={handleRecordButtonClick}
>
<Icon size="1.25rem" name="video-recorder" />
</ActionButton>
<Tooltip text="Video Message" position="top">
<ActionButton
ghost
square
disabled={disabled}
onClick={handleRecordButtonClick}
>
<Icon size="1.25rem" name="video-recorder" />
</ActionButton>
</Tooltip>
)}

{state === 'recording' && (
Expand All @@ -178,16 +181,20 @@ const VideoMessageRecorder = ({ disabled }) => {
`}
/>
<Box css={styles.controller}>
<ActionButton ghost onClick={handleCancelRecordButton}>
<Icon size="1.25rem" name="circle-cross" />
</ActionButton>
<Tooltip text="Cancel Recording" position="bottom">
<ActionButton ghost onClick={handleCancelRecordButton}>
<Icon size="1.25rem" name="circle-cross" />
</ActionButton>
</Tooltip>
<Box css={styles.record}>
<Box is="span" css={styles.dot} />
<Box css={styles.timer}>{time}</Box>
</Box>
<ActionButton ghost onClick={handleStopRecordButton}>
<Icon name="circle-check" size="1.25rem" />
</ActionButton>
<Tooltip text="Finish Recording" position="bottom">
<ActionButton ghost onClick={handleStopRecordButton}>
<Icon name="circle-check" size="1.25rem" />
</ActionButton>
</Tooltip>
</Box>
</Modal>
</>
Expand Down

0 comments on commit 9d84f49

Please sign in to comment.