Only apply Textaera to Prompt

This commit is contained in:
mickr777 2023-07-21 13:17:27 +10:00 committed by GitHub
parent 98b2734240
commit 585520d8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { Textarea } from '@chakra-ui/react'; import { Textarea, Input } from '@chakra-ui/react';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { fieldValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldValueChanged } from 'features/nodes/store/nodesSlice';
import { import {
@ -19,7 +19,9 @@ const StringInputFieldComponent = (
const { nodeId, field, nodeWidth } = props; const { nodeId, field, nodeWidth } = props;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleValueChanged = (e: ChangeEvent<HTMLTextAreaElement>) => { const handleValueChanged = (
e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
dispatch( dispatch(
fieldValueChanged({ fieldValueChanged({
nodeId, nodeId,
@ -32,6 +34,8 @@ const StringInputFieldComponent = (
const textareaWidth = nodeWidth - 20; const textareaWidth = nodeWidth - 20;
return ( return (
<>
{field.name.toLowerCase() === 'prompt' ? (
<Textarea <Textarea
style={{ style={{
height: '150px', height: '150px',
@ -42,6 +46,14 @@ const StringInputFieldComponent = (
onChange={handleValueChanged} onChange={handleValueChanged}
value={field.value} value={field.value}
/> />
) : (
<Input
style={{ width: `${textareaWidth}px` }}
onChange={handleValueChanged}
value={field.value}
/>
)}
</>
); );
}; };