mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Make more Simple
This commit is contained in:
@ -1,24 +1,17 @@
|
|||||||
import { memo, ChangeEvent } from 'react';
|
import { Input, 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 {
|
||||||
StringInputFieldTemplate,
|
StringInputFieldTemplate,
|
||||||
StringInputFieldValue,
|
StringInputFieldValue,
|
||||||
} from 'features/nodes/types/types';
|
} from 'features/nodes/types/types';
|
||||||
|
import { ChangeEvent, memo } from 'react';
|
||||||
import { FieldComponentProps } from './types';
|
import { FieldComponentProps } from './types';
|
||||||
|
|
||||||
const FIELD_PADDING = 20;
|
|
||||||
|
|
||||||
const StringInputFieldComponent = (
|
const StringInputFieldComponent = (
|
||||||
props: FieldComponentProps<
|
props: FieldComponentProps<StringInputFieldValue, StringInputFieldTemplate>
|
||||||
StringInputFieldValue,
|
|
||||||
StringInputFieldTemplate
|
|
||||||
> & {
|
|
||||||
nodeWidth: number;
|
|
||||||
}
|
|
||||||
) => {
|
) => {
|
||||||
const { nodeId, field, nodeWidth } = props;
|
const { nodeId, field } = props;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleValueChanged = (
|
const handleValueChanged = (
|
||||||
@ -33,30 +26,10 @@ const StringInputFieldComponent = (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const textareaWidth = nodeWidth - FIELD_PADDING;
|
return field.name.toLowerCase() === 'prompt' ? (
|
||||||
|
<Textarea onChange={handleValueChanged} value={field.value} rows={5} />
|
||||||
const textareaFieldNames = ['prompt', 'text'];
|
) : (
|
||||||
|
<Input onChange={handleValueChanged} value={field.value} />
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{textareaFieldNames.includes(field.name.toLowerCase()) ? (
|
|
||||||
<Textarea
|
|
||||||
style={{
|
|
||||||
height: '150px',
|
|
||||||
width: `${textareaWidth}px`,
|
|
||||||
overflowY: 'auto',
|
|
||||||
}}
|
|
||||||
onChange={handleValueChanged}
|
|
||||||
value={field.value}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Input
|
|
||||||
style={{ width: `${textareaWidth}px` }}
|
|
||||||
onChange={handleValueChanged}
|
|
||||||
value={field.value}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user