Przeglądaj źródła

feat: improve ChatAction ux

Yidadaa 1 rok temu
rodzic
commit
cbabb9392c

+ 4 - 1
app/components/chat.module.scss

@@ -18,6 +18,7 @@
     align-items: center;
     height: 16px;
     width: var(--icon-width);
+    overflow: hidden;
 
     &:not(:last-child) {
       margin-right: 5px;
@@ -29,14 +30,16 @@
       opacity: 0;
       transform: translateX(-5px);
       transition: all ease 0.3s;
-      transition-delay: 0.1s;
       pointer-events: none;
     }
 
     &:hover {
+      --delay: 0.5s;
       width: var(--full-width);
+      transition-delay: var(--delay);
 
       .text {
+        transition-delay: var(--delay);
         opacity: 1;
         transform: translate(0);
       }

+ 1 - 0
app/components/chat.tsx

@@ -504,6 +504,7 @@ export function ChatActions(props: {
 
       {showModelSelector && (
         <Selector
+          defaultSelectedValue={currentModel}
           items={models.map((m) => ({
             title: m,
             value: m,

+ 16 - 1
app/components/ui-lib.tsx

@@ -443,6 +443,7 @@ export function Selector<T>(props: {
     subTitle?: string;
     value: T;
   }>;
+  defaultSelectedValue?: T;
   onSelection?: (selection: T[]) => void;
   onClose?: () => void;
   multiple?: boolean;
@@ -452,6 +453,7 @@ export function Selector<T>(props: {
       <div className={styles["selector-content"]}>
         <List>
           {props.items.map((item, i) => {
+            const selected = props.defaultSelectedValue === item.value;
             return (
               <ListItem
                 className={styles["selector-item"]}
@@ -462,7 +464,20 @@ export function Selector<T>(props: {
                   props.onSelection?.([item.value]);
                   props.onClose?.();
                 }}
-              ></ListItem>
+              >
+                {selected ? (
+                  <div
+                    style={{
+                      height: 10,
+                      width: 10,
+                      backgroundColor: "var(--primary)",
+                      borderRadius: 10,
+                    }}
+                  ></div>
+                ) : (
+                  <></>
+                )}
+              </ListItem>
             );
           })}
         </List>