Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { AudioMutedOutlined, AudioOutlined } from '@ant-design/icons';
import type { ButtonProps } from 'antd';
import classNames from 'classnames';
import * as React from 'react';
import ActionButton, { ActionButtonContext } from '../ActionButton';
import RecordingIcon from './RecordingIcon';

function SpeechButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
const { speechRecording, onSpeechDisabled, prefixCls } = React.useContext(ActionButtonContext);
const { className, ...restProps } = props;

let icon: React.ReactNode = null;
if (speechRecording) {
Expand All @@ -21,7 +23,10 @@ function SpeechButton(props: ButtonProps, ref: React.Ref<HTMLButtonElement>) {
icon={icon}
color="primary"
variant="text"
{...props}
{...restProps}
className={classNames(className, {
[`${prefixCls}-speech-disabled`]: onSpeechDisabled,
})}
action="onSpeech"
ref={ref}
/>
Expand Down
9 changes: 9 additions & 0 deletions packages/x/components/sender/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ const genSenderStyle: GenerateStyle<SenderToken> = (token) => {
color: token.colorTextLightSolid,
},

// Speech button disabled style (e.g. browser doesn't support SpeechRecognition)
'&-speech-disabled, &-speech-disabled[disabled]': {
color: token.colorTextDisabled,
cursor: 'not-allowed',
'&:hover': {
color: token.colorTextDisabled,
},
},

'&-loading-button': {
padding: 0,
border: 0,
Expand Down
Loading