-
Notifications
You must be signed in to change notification settings - Fork 2.7k
misc(ui): image/asset tab tooltips, icon to rename board, getting started text #7067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { Input, Text } from '@invoke-ai/ui-library'; | ||
import { Flex, IconButton, Input, Text } from '@invoke-ai/ui-library'; | ||
import { useBoolean } from 'common/hooks/useBoolean'; | ||
import { withResultAsync } from 'common/util/result'; | ||
import { toast } from 'features/toast/toast'; | ||
import type { ChangeEvent, KeyboardEvent } from 'react'; | ||
import { memo, useCallback, useEffect, useRef, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { PiPencilBold } from 'react-icons/pi'; | ||
import { useUpdateBoardMutation } from 'services/api/endpoints/boards'; | ||
import type { BoardDTO } from 'services/api/types'; | ||
|
||
|
@@ -16,6 +17,7 @@ type Props = { | |
export const BoardEditableTitle = memo(({ board, isSelected }: Props) => { | ||
const { t } = useTranslation(); | ||
const isEditing = useBoolean(false); | ||
const [isHovering, setIsHovering] = useState(false); | ||
const [localTitle, setLocalTitle] = useState(board.board_name); | ||
const ref = useRef<HTMLInputElement>(null); | ||
const [updateBoard, updateBoardResult] = useUpdateBoardMutation(); | ||
|
@@ -58,6 +60,14 @@ export const BoardEditableTitle = memo(({ board, isSelected }: Props) => { | |
[board.board_name, isEditing, onBlur] | ||
); | ||
|
||
const handleMouseOver = useCallback(() => { | ||
setIsHovering(true); | ||
}, []); | ||
|
||
const handleMouseOut = useCallback(() => { | ||
setIsHovering(false); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (isEditing.isTrue) { | ||
ref.current?.focus(); | ||
|
@@ -67,17 +77,28 @@ export const BoardEditableTitle = memo(({ board, isSelected }: Props) => { | |
|
||
if (!isEditing.isTrue) { | ||
return ( | ||
<Text | ||
size="sm" | ||
fontWeight="semibold" | ||
userSelect="none" | ||
color={isSelected ? 'base.100' : 'base.300'} | ||
onDoubleClick={isEditing.setTrue} | ||
cursor="text" | ||
minW={16} | ||
> | ||
{localTitle} | ||
</Text> | ||
<Flex alignItems="center" gap={1} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}> | ||
<Text | ||
size="sm" | ||
fontWeight="semibold" | ||
userSelect="none" | ||
color={isSelected ? 'base.100' : 'base.300'} | ||
onDoubleClick={isEditing.setTrue} | ||
cursor="text" | ||
minW={16} | ||
> | ||
{localTitle} | ||
</Text> | ||
{isHovering && ( | ||
<IconButton | ||
aria-label="edit name" | ||
icon={<PiPencilBold />} | ||
size="sm" | ||
variant="ghost" | ||
onClick={isEditing.setTrue} | ||
/> | ||
Comment on lines
+93
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
)} | ||
Comment on lines
+92
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? You can click the board title to edit it. Maybe the trigger to edit a board title should be a single click instead, would that not serve the need better than adding more buttons? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this introduces a race condition (ish) where the icon doesn't disappear. Screen.Recording.2024-10-09.at.6.55.56.am.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I think there's just a typo in the PR description - mentions right-click but it actually means double-click, all good. I'll tidy up the minor issues I've mentioned in a followup or you can if you want |
||
</Flex> | ||
); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gap is a bit too small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.