Refined UI,code logic for improved user experience

This commit is contained in:
2023-06-23 20:07:43 +08:00
parent 8420085fb1
commit 6711506acd
16 changed files with 170 additions and 320 deletions
+31 -15
View File
@@ -22,12 +22,18 @@ import ResetIcon from "../icons/reload.svg";
import ClearIcon from "../icons/clear.svg";
import SettingsIcon from "../icons/chat-settings.svg";
import Image from 'next/image'
import AvatarIcon from "../icons/star/happy.png";
import LightIcon from "../icons/light.svg";
import DarkIcon from "../icons/dark.svg";
import AutoIcon from "../icons/auto.svg";
import BottomIcon from "../icons/bottom.svg";
import StopIcon from "../icons/pause.svg";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPaintbrush, faTrashCan, faCircleHalfStroke } from '@fortawesome/free-solid-svg-icons'
import {
ChatMessage,
SubmitKey,
@@ -174,11 +180,11 @@ function useSubmitHandler() {
if (e.key !== "Enter") return false;
if (e.key === "Enter" && e.nativeEvent.isComposing) return false;
return (
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
(config.submitKey === SubmitKey.ShiftEnter && e.shiftKey) ||
(config.submitKey === SubmitKey.MetaEnter && e.metaKey) ||
(config.submitKey === SubmitKey.Enter &&
(submitKey === SubmitKey.AltEnter && e.altKey) ||
(submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
(submitKey === SubmitKey.ShiftEnter && e.shiftKey) ||
(submitKey === SubmitKey.MetaEnter && e.metaKey) ||
(submitKey === SubmitKey.Enter &&
!e.altKey &&
!e.ctrlKey &&
!e.shiftKey &&
@@ -401,13 +407,19 @@ export function ChatActions(props: {
icon={<BottomIcon />}
/>
)}
{props.hitBottom && (
{/* {props.hitBottom && (
<ChatAction
onClick={props.showPromptModal}
text={Locale.Chat.InputActions.Settings}
icon={<SettingsIcon />}
/>
)}
)} */}
<ChatAction
onClick={() => {}} // todo: add ai painting action
text={Locale.Chat.InputActions.AIPaint}
icon={<FontAwesomeIcon icon={faPaintbrush} />}
/>
<ChatAction
onClick={nextTheme}
@@ -415,7 +427,8 @@ export function ChatActions(props: {
icon={
<>
{theme === Theme.Auto ? (
<AutoIcon />
// <FontAwesomeIcon icon="fa-solid fa-circle-half-stroke" />
<FontAwesomeIcon icon={faCircleHalfStroke} />
) : theme === Theme.Light ? (
<LightIcon />
) : theme === Theme.Dark ? (
@@ -431,17 +444,18 @@ export function ChatActions(props: {
icon={<PromptIcon />}
/>
<ChatAction
{/* <ChatAction
onClick={() => {
navigate(Path.Masks);
}}
text={Locale.Chat.InputActions.Masks}
icon={<MaskIcon />}
/>
/> */}
<ChatAction
text={Locale.Chat.InputActions.Clear}
icon={<ClearIcon />}
// icon={<FontAwesomeIcon icon="fa-regular fa-trash-can" />}
icon={<FontAwesomeIcon icon={faTrashCan} />}
onClick={() => {
chatStore.updateCurrentSession((session) => {
if (session.clearContextIndex === session.messages.length) {
@@ -820,7 +834,8 @@ export function Chat() {
<div className={styles["chat-message-container"]}>
<div className={styles["chat-message-avatar"]}>
{message.role === "user" ? (
<Avatar avatar={config.avatar} />
// <Avatar avatar={config.avatar} />
<Image src={AvatarIcon} alt="Avatar" width={32} height={32} />
) : (
<MaskAvatar mask={session.mask} />
)}
@@ -848,12 +863,12 @@ export function Chat() {
>
{Locale.Chat.Actions.Delete}
</div>
<div
{/* <div
className={styles["chat-message-top-action"]}
onClick={() => onResend(message.id ?? i)}
>
{Locale.Chat.Actions.Retry}
</div>
</div> */}
</>
)}
@@ -930,7 +945,8 @@ export function Chat() {
/>
<IconButton
icon={<SendWhiteIcon />}
text={Locale.Chat.Send}
// text={Locale.Chat.Send}
text=''
className={styles["chat-input-send"]}
type="primary"
onClick={() => doSubmit(userInput)}