feat: improve ChatAction ux

This commit is contained in:
Yidadaa 2023-08-02 22:53:36 +08:00
parent 531b3dcf9e
commit cbabb9392c
3 changed files with 21 additions and 2 deletions

View File

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

View File

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

View File

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