mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 21:23:58 +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 useStore from '@store/store';
|
||||||
|
|
||||||
import ChatIcon from '@icon/ChatIcon';
|
import ChatIcon from '@icon/ChatIcon';
|
||||||
|
@ -69,6 +69,7 @@ const ChatHistory = ({
|
||||||
const [isDelete, setIsDelete] = useState<boolean>(false);
|
const [isDelete, setIsDelete] = useState<boolean>(false);
|
||||||
const [isEdit, setIsEdit] = useState<boolean>(false);
|
const [isEdit, setIsEdit] = useState<boolean>(false);
|
||||||
const [_title, _setTitle] = useState<string>(title);
|
const [_title, _setTitle] = useState<string>(title);
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const active = currentChatIndex === chatIndex;
|
const active = currentChatIndex === chatIndex;
|
||||||
|
|
||||||
|
@ -96,6 +97,10 @@ const ChatHistory = ({
|
||||||
setIsEdit(false);
|
setIsEdit(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef && inputRef.current) inputRef.current.focus();
|
||||||
|
}, [isEdit]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
className={active ? ChatHistoryClass.active : ChatHistoryClass.normal}
|
className={active ? ChatHistoryClass.active : ChatHistoryClass.normal}
|
||||||
|
@ -106,23 +111,26 @@ const ChatHistory = ({
|
||||||
{isEdit ? (
|
{isEdit ? (
|
||||||
<input
|
<input
|
||||||
type='text'
|
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}
|
value={_title}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
_setTitle(e.target.value);
|
_setTitle(e.target.value);
|
||||||
}}
|
}}
|
||||||
|
ref={inputRef}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
_title
|
_title
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{isEdit || (
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
active
|
active
|
||||||
? ChatHistoryClass.activeGradient
|
? ChatHistoryClass.activeGradient
|
||||||
: ChatHistoryClass.normalGradient
|
: ChatHistoryClass.normalGradient
|
||||||
}
|
}
|
||||||
></div>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{active && (
|
{active && (
|
||||||
<div className='absolute flex right-1 z-10 text-gray-300 visible'>
|
<div className='absolute flex right-1 z-10 text-gray-300 visible'>
|
||||||
|
|
Loading…
Reference in a new issue