Browse Source

refactor: optimize send button

leedom 1 year ago
parent
commit
b7cdea1b82
3 changed files with 12 additions and 2 deletions
  1. 7 0
      app/components/button.module.scss
  2. 4 2
      app/components/button.tsx
  3. 1 0
      app/components/chat.tsx

+ 7 - 0
app/components/button.module.scss

@@ -10,6 +10,13 @@
   transition: all 0.3s ease;
   overflow: hidden;
   user-select: none;
+  outline: none;
+  border: none;
+
+  &[disabled] {
+    cursor: not-allowed;
+    opacity: 0.5;
+  }
 }
 
 .shadow {

+ 4 - 2
app/components/button.tsx

@@ -11,9 +11,10 @@ export function IconButton(props: {
   noDark?: boolean;
   className?: string;
   title?: string;
+  disabled?: boolean;
 }) {
   return (
-    <div
+    <button
       className={
         styles["icon-button"] +
         ` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
@@ -22,6 +23,7 @@ export function IconButton(props: {
       }
       onClick={props.onClick}
       title={props.title}
+      disabled={props.disabled}
       role="button"
     >
       <div
@@ -32,6 +34,6 @@ export function IconButton(props: {
       {props.text && (
         <div className={styles["icon-button-text"]}>{props.text}</div>
       )}
-    </div>
+    </button>
   );
 }

+ 1 - 0
app/components/chat.tsx

@@ -679,6 +679,7 @@ export function Chat(props: {
             text={Locale.Chat.Send}
             className={styles["chat-input-send"]}
             noDark
+            disabled={!userInput}
             onClick={onUserSubmit}
           />
         </div>