mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): misc cleanups
This commit is contained in:
parent
ae6db67068
commit
a495c8c156
@ -25,7 +25,7 @@ const NodeHeader = ({ nodeId, isOpen }: Props) => {
|
|||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
h: 8,
|
h: 8,
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontWeight: 600,
|
fontWeight: 500,
|
||||||
color: 'base.700',
|
color: 'base.700',
|
||||||
_dark: { color: 'base.200' },
|
_dark: { color: 'base.200' },
|
||||||
}}
|
}}
|
||||||
|
@ -79,7 +79,7 @@ const NodeTitle = ({ nodeId, title }: Props) => {
|
|||||||
fontSize="sm"
|
fontSize="sm"
|
||||||
sx={{
|
sx={{
|
||||||
p: 0,
|
p: 0,
|
||||||
fontWeight: 'initial',
|
fontWeight: 700,
|
||||||
_focusVisible: {
|
_focusVisible: {
|
||||||
p: 0,
|
p: 0,
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
|
@ -18,10 +18,11 @@ interface Props {
|
|||||||
nodeId: string;
|
nodeId: string;
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
kind: 'input' | 'output';
|
kind: 'input' | 'output';
|
||||||
|
isMissingInput?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FieldTitle = forwardRef((props: Props, ref) => {
|
const FieldTitle = forwardRef((props: Props, ref) => {
|
||||||
const { nodeId, fieldName, kind } = props;
|
const { nodeId, fieldName, kind, isMissingInput = false } = props;
|
||||||
const label = useFieldLabel(nodeId, fieldName);
|
const label = useFieldLabel(nodeId, fieldName);
|
||||||
const fieldTemplateTitle = useFieldTemplateTitle(nodeId, fieldName, kind);
|
const fieldTemplateTitle = useFieldTemplateTitle(nodeId, fieldName, kind);
|
||||||
|
|
||||||
@ -78,7 +79,11 @@ const FieldTitle = forwardRef((props: Props, ref) => {
|
|||||||
<EditablePreview
|
<EditablePreview
|
||||||
sx={{
|
sx={{
|
||||||
p: 0,
|
p: 0,
|
||||||
|
fontWeight: isMissingInput ? 600 : 400,
|
||||||
textAlign: 'left',
|
textAlign: 'left',
|
||||||
|
_hover: {
|
||||||
|
fontWeight: '600 !important',
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
noOfLines={1}
|
noOfLines={1}
|
||||||
/>
|
/>
|
||||||
|
@ -23,7 +23,6 @@ const FieldTooltipContent = ({ nodeId, fieldName, kind }: Props) => {
|
|||||||
const isInputTemplate = isInputFieldTemplate(fieldTemplate);
|
const isInputTemplate = isInputFieldTemplate(fieldTemplate);
|
||||||
const fieldTitle = useMemo(() => {
|
const fieldTitle = useMemo(() => {
|
||||||
if (isInputFieldValue(field)) {
|
if (isInputFieldValue(field)) {
|
||||||
console.log(field, fieldTemplate);
|
|
||||||
if (field.label && fieldTemplate?.title) {
|
if (field.label && fieldTemplate?.title) {
|
||||||
return `${field.label} (${fieldTemplate.title})`;
|
return `${field.label} (${fieldTemplate.title})`;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import { Flex, FormControl, FormLabel, Tooltip } from '@chakra-ui/react';
|
import { Box, Flex, FormControl, FormLabel, Tooltip } from '@chakra-ui/react';
|
||||||
|
import SelectionOverlay from 'common/components/SelectionOverlay';
|
||||||
import { useConnectionState } from 'features/nodes/hooks/useConnectionState';
|
import { useConnectionState } from 'features/nodes/hooks/useConnectionState';
|
||||||
import {
|
import {
|
||||||
useDoesInputHaveValue,
|
useDoesInputHaveValue,
|
||||||
|
useFieldInputKind,
|
||||||
useFieldTemplate,
|
useFieldTemplate,
|
||||||
useIsMouseOverField,
|
useIsMouseOverField,
|
||||||
} from 'features/nodes/hooks/useNodeData';
|
} from 'features/nodes/hooks/useNodeData';
|
||||||
import { HANDLE_TOOLTIP_OPEN_DELAY } from 'features/nodes/types/constants';
|
import { HANDLE_TOOLTIP_OPEN_DELAY } from 'features/nodes/types/constants';
|
||||||
import { PropsWithChildren, memo, useMemo } from 'react';
|
import { PropsWithChildren, memo, useCallback, useMemo, useState } from 'react';
|
||||||
import FieldContextMenu from './FieldContextMenu';
|
import FieldContextMenu from './FieldContextMenu';
|
||||||
import FieldHandle from './FieldHandle';
|
import FieldHandle from './FieldHandle';
|
||||||
import FieldTitle from './FieldTitle';
|
import FieldTitle from './FieldTitle';
|
||||||
import FieldTooltipContent from './FieldTooltipContent';
|
import FieldTooltipContent from './FieldTooltipContent';
|
||||||
import InputFieldRenderer from './InputFieldRenderer';
|
import InputFieldRenderer from './InputFieldRenderer';
|
||||||
import SelectionOverlay from 'common/components/SelectionOverlay';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
@ -22,6 +23,16 @@ interface Props {
|
|||||||
const InputField = ({ nodeId, fieldName }: Props) => {
|
const InputField = ({ nodeId, fieldName }: Props) => {
|
||||||
const fieldTemplate = useFieldTemplate(nodeId, fieldName, 'input');
|
const fieldTemplate = useFieldTemplate(nodeId, fieldName, 'input');
|
||||||
const doesFieldHaveValue = useDoesInputHaveValue(nodeId, fieldName);
|
const doesFieldHaveValue = useDoesInputHaveValue(nodeId, fieldName);
|
||||||
|
const input = useFieldInputKind(nodeId, fieldName);
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
|
const handleMouseOver = useCallback(() => {
|
||||||
|
setIsHovered(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleMouseOut = useCallback(() => {
|
||||||
|
setIsHovered(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isConnected,
|
isConnected,
|
||||||
@ -81,6 +92,7 @@ const InputField = ({ nodeId, fieldName }: Props) => {
|
|||||||
ps: 2,
|
ps: 2,
|
||||||
gap: 2,
|
gap: 2,
|
||||||
h: 'full',
|
h: 'full',
|
||||||
|
w: 'full',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FieldContextMenu nodeId={nodeId} fieldName={fieldName} kind="input">
|
<FieldContextMenu nodeId={nodeId} fieldName={fieldName} kind="input">
|
||||||
@ -97,18 +109,32 @@ const InputField = ({ nodeId, fieldName }: Props) => {
|
|||||||
placement="top"
|
placement="top"
|
||||||
hasArrow
|
hasArrow
|
||||||
>
|
>
|
||||||
<FormLabel sx={{ mb: 0 }}>
|
<FormLabel
|
||||||
|
sx={{
|
||||||
|
mb: 0,
|
||||||
|
width: input === 'connection' ? 'auto' : '25%',
|
||||||
|
flexShrink: 0,
|
||||||
|
flexGrow: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<FieldTitle
|
<FieldTitle
|
||||||
ref={ref}
|
ref={ref}
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
fieldName={fieldName}
|
fieldName={fieldName}
|
||||||
kind="input"
|
kind="input"
|
||||||
|
isMissingInput={isMissingInput}
|
||||||
/>
|
/>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</FieldContextMenu>
|
</FieldContextMenu>
|
||||||
<InputFieldRenderer nodeId={nodeId} fieldName={fieldName} />
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: input === 'connection' ? 'auto' : '75%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<InputFieldRenderer nodeId={nodeId} fieldName={fieldName} />
|
||||||
|
</Box>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
{fieldTemplate.input !== 'direct' && (
|
{fieldTemplate.input !== 'direct' && (
|
||||||
|
@ -98,13 +98,18 @@ const ImageInputFieldComponent = (
|
|||||||
|
|
||||||
export default memo(ImageInputFieldComponent);
|
export default memo(ImageInputFieldComponent);
|
||||||
|
|
||||||
const UploadElement = () => (
|
const UploadElement = memo(() => (
|
||||||
<Text fontSize={16} fontWeight={600}>
|
<Text fontSize={16} fontWeight={600}>
|
||||||
Drop or Upload
|
Drop or Upload
|
||||||
</Text>
|
</Text>
|
||||||
);
|
));
|
||||||
const DropLabel = () => (
|
|
||||||
|
UploadElement.displayName = 'UploadElement';
|
||||||
|
|
||||||
|
const DropLabel = memo(() => (
|
||||||
<Text fontSize={16} fontWeight={600}>
|
<Text fontSize={16} fontWeight={600}>
|
||||||
Drop
|
Drop
|
||||||
</Text>
|
</Text>
|
||||||
);
|
));
|
||||||
|
|
||||||
|
DropLabel.displayName = 'DropLabel';
|
||||||
|
@ -115,9 +115,9 @@ export const useFieldInputKind = (nodeId: string, fieldName: string) => {
|
|||||||
[fieldName, nodeId]
|
[fieldName, nodeId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const fieldType = useAppSelector(selector);
|
const inputKind = useAppSelector(selector);
|
||||||
|
|
||||||
return fieldType;
|
return inputKind;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useFieldType = (
|
export const useFieldType = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user