From db06ee5be9730b6414324eae3e6cb22df58309c7 Mon Sep 17 00:00:00 2001 From: wil Date: Wed, 3 Apr 2024 14:19:28 -0400 Subject: [PATCH] hook up different ui elements to get ready for API hook up --- app/components/ListDropdown.tsx | 11 +++-- app/components/ListSearchDropdown.tsx | 8 +++- .../comps/DialogueTTS/DialogueTTS.tsx | 47 +++++++++++++++++-- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/app/components/ListDropdown.tsx b/app/components/ListDropdown.tsx index 5bb2af5fc3..aeb04875fc 100644 --- a/app/components/ListDropdown.tsx +++ b/app/components/ListDropdown.tsx @@ -1,4 +1,4 @@ -import { Fragment, useState } from 'react' +import { Fragment, useEffect, useState } from 'react' import { Listbox, Transition } from '@headlessui/react' import { faCheck, faChevronDown } from '@fortawesome/pro-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' @@ -6,11 +6,16 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' interface ListDropdownProps { list: {[key: string] : string}[]; + onSelect: (val:string)=>void; } export const ListDropdown = ({ - list + list, onSelect }:ListDropdownProps) => { - const [selected, setSelected] = useState(list[0]) + const [selected, setSelected] = useState(list[0]); + + useEffect(()=>{ + onSelect(Object.values(selected)[0]); + }, [selected]); return ( diff --git a/app/components/ListSearchDropdown.tsx b/app/components/ListSearchDropdown.tsx index cf2756c238..78f9f74b26 100644 --- a/app/components/ListSearchDropdown.tsx +++ b/app/components/ListSearchDropdown.tsx @@ -1,13 +1,14 @@ -import { Fragment, useState } from 'react' +import { Fragment, useState, useEffect } from 'react' import { Combobox, Transition } from '@headlessui/react' import { faCheck, faChevronDown } from '@fortawesome/pro-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' interface ListDropdownProps { list: {[key: string] : string}[]; + onSelect: (val:string)=>void } export const ListSearchDropdown = ({ - list + list, onSelect }:ListDropdownProps) => { const [selected, setSelected] = useState(list[0]) const [query, setQuery] = useState('') @@ -22,6 +23,9 @@ export const ListSearchDropdown = ({ .includes(query.toLowerCase().replace(/\s+/g, '')) ) + useEffect(()=>{ + onSelect(Object.values(selected)[0]); + }, [selected]); return (
diff --git a/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx b/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx index 5f46c5d125..3d4582f499 100644 --- a/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx +++ b/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx @@ -1,5 +1,5 @@ import { useContext, useState } from "react"; -import { faVolume, faShuffle } from "@fortawesome/pro-solid-svg-icons"; +import { faVolume, faShuffle, faPlay } from "@fortawesome/pro-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { AppUiContext } from "../../contexts/AppUiContext"; import { APPUI_ACTION_TYPES } from "../../reducers"; @@ -7,7 +7,6 @@ import { Button, H5, Label, - ListDropdown, ListSearchDropdown, TransitionDialogue, Textarea @@ -21,15 +20,41 @@ const testdata = [ { name: 'Tanya Fox' }, { name: 'Hellen Schmidt' }, ] - +type TtsState = { + voice: string; + text: string; + hasAudio: boolean; +} export const DialogueTTS = ()=>{ const [appUiState, dispatchAppUiState] = useContext(AppUiContext); + const [ttsState, setTtsState] = useState({ + voice:"", + text:"", + hasAudio:false + }); + const handleClose = ()=> { dispatchAppUiState({ type: APPUI_ACTION_TYPES.CLOSE_DIALOGUE_TTS }) }; + const handleTextInput = ( + e: React.ChangeEvent + )=>{ + setTtsState((curr)=>({ + ...curr, + text: e.target.value, + })); + }; + + const handleOnSelect = (val:string)=>{ + setTtsState((curr)=>({ + ...curr, + voices: val, + })); + } + return( { >
- +
@@ -55,8 +80,19 @@ export const DialogueTTS = ()=>{