mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-30 23:26:39 +08:00
feat: add search box and title above model list
This commit is contained in:
parent
0c3d4462ca
commit
055ac64d89
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
.list {
|
.list {
|
||||||
border: var(--border-in-light);
|
border: var(--border-in-light);
|
||||||
border-radius: 10px;
|
border-radius: 0 0 10px 10px;
|
||||||
box-shadow: var(--card-shadow);
|
box-shadow: var(--card-shadow);
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
animation: slide-in ease 0.3s;
|
animation: slide-in ease 0.3s;
|
||||||
@ -313,11 +313,37 @@
|
|||||||
.selector-item-disabled {
|
.selector-item-disabled {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
.selector-bar {
|
||||||
|
background-color: var(--white);
|
||||||
|
border: solid var(--border-in-light);
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
min-height: 40px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.selector-title {
|
||||||
|
font-size: large;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.selector-search-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px;
|
||||||
|
border-bottom: solid var(--border-in-light);
|
||||||
|
}
|
||||||
|
.selector-search-input {
|
||||||
|
padding: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
flex-grow: 1;
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
.list {
|
.list {
|
||||||
max-height: 90vh;
|
max-height: 50vh;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
@ -336,4 +362,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,12 +507,41 @@ export function Selector<T>(props: {
|
|||||||
props.onClose?.();
|
props.onClose?.();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const [filteredItems, setFilteredItems] = useState([...props.items]);
|
||||||
|
function onSearch(text: string) {
|
||||||
|
setSearchText(text);
|
||||||
|
if (text === "") {
|
||||||
|
setFilteredItems([...props.items]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// filter by items title
|
||||||
|
const newItems = props.items.filter((item) =>
|
||||||
|
item.title.toLowerCase().includes(text.toLowerCase()),
|
||||||
|
);
|
||||||
|
setFilteredItems([...newItems]);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className={styles["selector"]} onClick={() => props.onClose?.()}>
|
<div className={styles["selector"]} onClick={() => props.onClose?.()}>
|
||||||
<div className={styles["selector-content"]}>
|
<div className={styles["selector-content"]}>
|
||||||
|
{/* todo: add searchbox */}
|
||||||
|
<div className={styles["selector-bar"]}>
|
||||||
|
<div className={styles["selector-title"]}>
|
||||||
|
{Locale.UI.SelectorTitle}
|
||||||
|
</div>
|
||||||
|
<div className={styles["selector-search-container"]}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className={styles["selector-search-input"]}
|
||||||
|
placeholder={Locale.UI.Search}
|
||||||
|
autoFocus
|
||||||
|
onInput={(e) => onSearch(e.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<List>
|
<List>
|
||||||
{props.items.map((item, i) => {
|
{filteredItems.length ? (
|
||||||
|
filteredItems.map((item, i) => {
|
||||||
const selected = selectedValues.includes(item.value);
|
const selected = selectedValues.includes(item.value);
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
@ -544,7 +573,13 @@ export function Selector<T>(props: {
|
|||||||
)}
|
)}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
) : (
|
||||||
|
<ListItem
|
||||||
|
title={Locale.UI.NoResults}
|
||||||
|
className={styles["selector-item"]}
|
||||||
|
></ListItem>
|
||||||
|
)}
|
||||||
</List>
|
</List>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -758,6 +758,9 @@ const cn = {
|
|||||||
Import: "导入",
|
Import: "导入",
|
||||||
Sync: "同步",
|
Sync: "同步",
|
||||||
Config: "配置",
|
Config: "配置",
|
||||||
|
Search: "搜索",
|
||||||
|
SelectorTitle: "选择model",
|
||||||
|
NoResults: "没有结果",
|
||||||
},
|
},
|
||||||
Exporter: {
|
Exporter: {
|
||||||
Description: {
|
Description: {
|
||||||
|
@ -764,6 +764,9 @@ const en: LocaleType = {
|
|||||||
Import: "Import",
|
Import: "Import",
|
||||||
Sync: "Sync",
|
Sync: "Sync",
|
||||||
Config: "Config",
|
Config: "Config",
|
||||||
|
Search: "Search",
|
||||||
|
SelectorTitle: "Choose Model",
|
||||||
|
NoResults: "No Results",
|
||||||
},
|
},
|
||||||
Exporter: {
|
Exporter: {
|
||||||
Description: {
|
Description: {
|
||||||
|
Loading…
Reference in New Issue
Block a user