import React from 'react' import Icon from '#components/icons/icon' import UI from '#components/ui' import { FC } from 'react' /** * Props for the TextToSpeechControls component. * @interface TextToSpeechControlsProps */ interface TextToSpeechControlsProps { /** Optional label for the controls */ label?: string | React.ReactNode /** Indicates if the text-to-speech is currently speaking */ isSpeaking: boolean /** Indicates if the text-to-speech is paused */ isPaused: boolean /** Function to start speaking */ onSpeak: () => void /** Function to pause speaking */ onPause: () => void /** Function to resume speaking */ onResume: () => void /** Function to cancel speaking */ onCancel: () => void } /** * TTSButtonComponent props * @interface TTSButtonComponentProps */ interface TTSButtonComponentProps { /** The content of the button */ children: React.ReactNode /** Function to call when the button is clicked */ onClick: () => void } /** * TTSButtonComponent is a reusable button component for text-to-speech controls. * @param {TTSButtonComponentProps} props - The component props * @returns {React.ReactElement} The rendered button */ export const TTSButtonComponent: React.FC = ({ children, onClick, }) => { return ( {children} ) } export const TTSButton = React.memo(TTSButtonComponent) /** * TextToSpeechControlsComponent interface extends FC * and includes a TTSButton property. * @interface TextToSpeechControlsComponent * @extends {FC} */ interface TextToSpeechControlsComponent extends FC { /** The TTSButton component used within TextToSpeechControls */ TTSButton: typeof TTSButton } /** * TextToSpeechControls component provides a user interface for controlling text-to-speech functionality. * @param {TextToSpeechControlsProps} props - The component props * @returns {React.ReactElement} The rendered TextToSpeechControls component */ const TextToSpeechControls: TextToSpeechControlsComponent = ({ label, isSpeaking, isPaused, onSpeak, onPause, onResume, onCancel, }) => { const iconSize = 16 return ( {label &&

{label}

} {!isSpeaking && ( )} {isSpeaking && !isPaused && ( )} {isPaused && ( )}
) } TextToSpeechControls.displayName = 'TextToSpeechControls' TextToSpeechControls.TTSButton = TTSButton export default TextToSpeechControls