Skip to content

Commit

Permalink
feat: hide send button when input is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahumble committed May 15, 2023
1 parent e39f9e6 commit c52c82f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/InputPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ function InputPanel({
}

function SendButton() {
if (status === 'idle' || status === 'recording' || status === 'connecting') {
if (
(status === 'idle' || status === 'recording' || status === 'connecting') &&
userInput.length > 0
) {
return (
<button
type="button"
Expand All @@ -105,6 +108,20 @@ function InputPanel({
<div>{i18n.t('common.send')}</div>
</button>
);
} else if (
(status === 'idle' || status === 'recording' || status === 'connecting') &&
userInput.length == 0
) {
return (
<button
type="button"
className="flex flex-row items-center space-x-2 rounded-lg px-4 py-2 font-medium text-white bg-gradient-to-tr from-indigo-500 to-purple-500 transition-colors duration-300 cursor-not-allowed"
onClick={handleSend}
>
<IconSend className="h-5 w-5" />
<div>{i18n.t('common.send')}</div>
</button>
);
} else {
return (
<button
Expand Down Expand Up @@ -133,7 +150,7 @@ function InputPanel({
/>
<div className="flex flex-row space-x-2 justify-end">
{/*<div className="self-end text-gray-700">{i18n.t('common.status')}: {status}</div>*/}
<RecordButton />
{!disableMicrophone && <RecordButton />}
<SendButton />
</div>
</div>
Expand Down

1 comment on commit c52c82f

@vercel
Copy link

@vercel vercel bot commented on c52c82f May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

speechgpt – ./

speechgpt-alpha.vercel.app
speechgpt-hahahumble.vercel.app
speechgpt-git-main-hahahumble.vercel.app

Please sign in to comment.