forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #567 from leedom92/optimize-send-button
refactor: optimize component `IconButton`
This commit is contained in:
commit
74cff2639b
@ -10,6 +10,14 @@
|
|||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
color: rgb(51, 51, 51);
|
||||||
|
|
||||||
|
&[disabled] {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.shadow {
|
.shadow {
|
||||||
|
@ -11,9 +11,10 @@ export function IconButton(props: {
|
|||||||
noDark?: boolean;
|
noDark?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div
|
<button
|
||||||
className={
|
className={
|
||||||
styles["icon-button"] +
|
styles["icon-button"] +
|
||||||
` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
|
` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
|
||||||
@ -22,6 +23,7 @@ export function IconButton(props: {
|
|||||||
}
|
}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
title={props.title}
|
title={props.title}
|
||||||
|
disabled={props.disabled}
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -32,6 +34,6 @@ export function IconButton(props: {
|
|||||||
{props.text && (
|
{props.text && (
|
||||||
<div className={styles["icon-button-text"]}>{props.text}</div>
|
<div className={styles["icon-button-text"]}>{props.text}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,6 @@ export function Chat(props: {
|
|||||||
|
|
||||||
// submit user input
|
// submit user input
|
||||||
const onUserSubmit = () => {
|
const onUserSubmit = () => {
|
||||||
if (userInput.length <= 0) return;
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
chatStore.onUserInput(userInput).then(() => setIsLoading(false));
|
chatStore.onUserInput(userInput).then(() => setIsLoading(false));
|
||||||
setUserInput("");
|
setUserInput("");
|
||||||
@ -680,6 +679,7 @@ export function Chat(props: {
|
|||||||
text={Locale.Chat.Send}
|
text={Locale.Chat.Send}
|
||||||
className={styles["chat-input-send"]}
|
className={styles["chat-input-send"]}
|
||||||
noDark
|
noDark
|
||||||
|
disabled={!userInput}
|
||||||
onClick={onUserSubmit}
|
onClick={onUserSubmit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user