refactor(chat): simplify input send button
This commit is contained in:
@@ -8,38 +8,30 @@
|
||||
* - 默认:粉色背景 + 渐变边缘
|
||||
* - 聚焦 / 激活:完整 primaryGradient(accent → 透明)
|
||||
*
|
||||
* 图标:空输入显示 <Plus />,有内容时显示 <ArrowUp />
|
||||
* 图标:固定显示 <ArrowUp />,按钮只负责发送消息。
|
||||
*/
|
||||
import { ArrowUp, Plus } from "lucide-react";
|
||||
import { ArrowUp } from "lucide-react";
|
||||
|
||||
import styles from "./chat-send-button.module.css";
|
||||
|
||||
export interface ChatSendButtonProps {
|
||||
disabled: boolean;
|
||||
hasContent: boolean;
|
||||
isExpanded?: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function ChatSendButton({
|
||||
disabled,
|
||||
hasContent,
|
||||
isExpanded = false,
|
||||
onClick,
|
||||
}: ChatSendButtonProps) {
|
||||
const Icon = hasContent ? ArrowUp : Plus;
|
||||
const ariaLabel = hasContent ? "Send message" : "Open chat actions";
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`${styles.button} ${disabled ? "" : styles.buttonActive}`}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
aria-expanded={hasContent ? undefined : isExpanded}
|
||||
aria-label={ariaLabel}
|
||||
aria-label="Send message"
|
||||
>
|
||||
<Icon className={styles.icon} size={24} aria-hidden="true" />
|
||||
<ArrowUp className={styles.icon} size={24} aria-hidden="true" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user