Refactor TTSButton to use custom Button component and update icons for better UI consistency
This commit is contained in:
14
src/tts.tsx
14
src/tts.tsx
@@ -4,6 +4,8 @@ import { useMemo, useState } from "preact/hooks";
|
|||||||
import { addTotalCost } from "@/utils/totalCost";
|
import { addTotalCost } from "@/utils/totalCost";
|
||||||
import { ChatStore, ChatStoreMessage } from "@/types/chatstore";
|
import { ChatStore, ChatStoreMessage } from "@/types/chatstore";
|
||||||
import { Message, getMessageText } from "@/chatgpt";
|
import { Message, getMessageText } from "@/chatgpt";
|
||||||
|
import { AudioLinesIcon, LoaderCircleIcon } from "lucide-react";
|
||||||
|
import { Button } from "./components/ui/button";
|
||||||
|
|
||||||
interface TTSProps {
|
interface TTSProps {
|
||||||
chatStore: ChatStore;
|
chatStore: ChatStore;
|
||||||
@@ -25,14 +27,16 @@ export function TTSPlay(props: TTSPlayProps) {
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
if (props.chat.audio instanceof Blob) {
|
if (props.chat.audio instanceof Blob) {
|
||||||
return <audio className="w-full" src={src} controls />;
|
return <audio className="w-64" src={src} controls />;
|
||||||
}
|
}
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
export default function TTSButton(props: TTSProps) {
|
export default function TTSButton(props: TTSProps) {
|
||||||
const [generating, setGenerating] = useState(false);
|
const [generating, setGenerating] = useState(false);
|
||||||
return (
|
return (
|
||||||
<button
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const api = props.chatStore.tts_api;
|
const api = props.chatStore.tts_api;
|
||||||
const api_key = props.chatStore.tts_key;
|
const api_key = props.chatStore.tts_key;
|
||||||
@@ -82,10 +86,10 @@ export default function TTSButton(props: TTSProps) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{generating ? (
|
{generating ? (
|
||||||
<span className="loading loading-dots loading-xs"></span>
|
<LoaderCircleIcon className="h-4 w-4 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
<SpeakerWaveIcon className="h-4 w-4" />
|
<AudioLinesIcon className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
</button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user