mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 19:33:59 +01:00
style: side chat title input
This commit is contained in:
parent
b080c185f4
commit
5e1745fe0c
|
@ -1,4 +1,4 @@
|
|||
import React, { MouseEventHandler, useEffect, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import useStore from '@store/store';
|
||||
|
||||
import ChatIcon from '@icon/ChatIcon';
|
||||
|
@ -69,6 +69,7 @@ const ChatHistory = ({
|
|||
const [isDelete, setIsDelete] = useState<boolean>(false);
|
||||
const [isEdit, setIsEdit] = useState<boolean>(false);
|
||||
const [_title, _setTitle] = useState<string>(title);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const active = currentChatIndex === chatIndex;
|
||||
|
||||
|
@ -96,6 +97,10 @@ const ChatHistory = ({
|
|||
setIsEdit(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef && inputRef.current) inputRef.current.focus();
|
||||
}, [isEdit]);
|
||||
|
||||
return (
|
||||
<a
|
||||
className={active ? ChatHistoryClass.active : ChatHistoryClass.normal}
|
||||
|
@ -106,23 +111,26 @@ const ChatHistory = ({
|
|||
{isEdit ? (
|
||||
<input
|
||||
type='text'
|
||||
className='text-sm border-none bg-transparent p-0 m-0 w-full mr-0'
|
||||
className='focus:outline-blue-600 text-sm border-none bg-transparent p-0 m-0 w-full'
|
||||
value={_title}
|
||||
onChange={(e) => {
|
||||
_setTitle(e.target.value);
|
||||
}}
|
||||
ref={inputRef}
|
||||
/>
|
||||
) : (
|
||||
_title
|
||||
)}
|
||||
|
||||
<div
|
||||
className={
|
||||
active
|
||||
? ChatHistoryClass.activeGradient
|
||||
: ChatHistoryClass.normalGradient
|
||||
}
|
||||
></div>
|
||||
{isEdit || (
|
||||
<div
|
||||
className={
|
||||
active
|
||||
? ChatHistoryClass.activeGradient
|
||||
: ChatHistoryClass.normalGradient
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{active && (
|
||||
<div className='absolute flex right-1 z-10 text-gray-300 visible'>
|
||||
|
|
Loading…
Reference in a new issue