mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Added search to quicklaunch
This commit is contained in:
parent
5af01d2436
commit
4e17628f97
@ -282,7 +282,8 @@
|
|||||||
},
|
},
|
||||||
"quicklaunch": {
|
"quicklaunch": {
|
||||||
"bookmark": "Bookmark",
|
"bookmark": "Bookmark",
|
||||||
"service": "Service"
|
"service": "Service",
|
||||||
|
"searchGoogle": "Search Google"
|
||||||
},
|
},
|
||||||
"wmo": {
|
"wmo": {
|
||||||
"0-day": "Sunny",
|
"0-day": "Sunny",
|
||||||
@ -432,7 +433,7 @@
|
|||||||
},
|
},
|
||||||
"cloudflared": {
|
"cloudflared": {
|
||||||
"origin_ip": "Origin IP",
|
"origin_ip": "Origin IP",
|
||||||
"status": "Status"
|
"status": "Status"
|
||||||
},
|
},
|
||||||
"proxmoxbackupserver": {
|
"proxmoxbackupserver": {
|
||||||
"datastore_usage": "Datastore",
|
"datastore_usage": "Datastore",
|
||||||
@ -446,4 +447,4 @@
|
|||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"storage": "Storage"
|
"storage": "Storage"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
|
|
||||||
function handleSearchKeyDown(event) {
|
function handleSearchKeyDown(event) {
|
||||||
if (!isOpen) return;
|
if (!isOpen) return;
|
||||||
|
|
||||||
if (event.key === "Escape") {
|
if (event.key === "Escape") {
|
||||||
closeAndReset();
|
closeAndReset();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -50,6 +50,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleItemHover(event) {
|
function handleItemHover(event) {
|
||||||
setCurrentItemIndex(parseInt(event.target?.dataset?.index, 10));
|
setCurrentItemIndex(parseInt(event.target?.dataset?.index, 10));
|
||||||
}
|
}
|
||||||
@ -75,6 +76,15 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
if (searchDescriptions) {
|
if (searchDescriptions) {
|
||||||
newResults = newResults.sort((a, b) => b.priority - a.priority);
|
newResults = newResults.sort((a, b) => b.priority - a.priority);
|
||||||
}
|
}
|
||||||
|
newResults.push(
|
||||||
|
{
|
||||||
|
name: searchString,
|
||||||
|
href: `http://google.com/search?q=${searchString}`,
|
||||||
|
description: t("quicklaunch.searchGoogle"),
|
||||||
|
type: 'service',
|
||||||
|
weight: 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
setResults(newResults);
|
setResults(newResults);
|
||||||
|
|
||||||
@ -82,7 +92,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
setCurrentItemIndex(0);
|
setCurrentItemIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [searchString, servicesAndBookmarks, searchDescriptions]);
|
}, [searchString, servicesAndBookmarks, searchDescriptions, t]);
|
||||||
|
|
||||||
|
|
||||||
const [hidden, setHidden] = useState(true);
|
const [hidden, setHidden] = useState(true);
|
||||||
@ -90,7 +100,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
function handleBackdropClick(event) {
|
function handleBackdropClick(event) {
|
||||||
if (event.target?.tagName === "DIV") closeAndReset();
|
if (event.target?.tagName === "DIV") closeAndReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
searchField.current.focus();
|
searchField.current.focus();
|
||||||
document.body.addEventListener('click', handleBackdropClick);
|
document.body.addEventListener('click', handleBackdropClick);
|
||||||
@ -141,7 +151,7 @@ export default function QuickLaunch({servicesAndBookmarks, searchString, setSear
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col md:flex-row text-left items-baseline mr-4 pointer-events-none">
|
<div className="flex flex-col md:flex-row text-left items-baseline mr-4 pointer-events-none">
|
||||||
<span className="mr-4">{r.name}</span>
|
<span className="mr-4">{r.name}</span>
|
||||||
{r.description &&
|
{r.description &&
|
||||||
<span className="text-xs text-theme-600 text-light">
|
<span className="text-xs text-theme-600 text-light">
|
||||||
{searchDescriptions && r.priority < 2 ? highlightText(r.description) : r.description}
|
{searchDescriptions && r.priority < 2 ? highlightText(r.description) : r.description}
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user