Added search to quicklaunch

This commit is contained in:
Alex Sinelnikov 2023-01-30 10:16:45 +02:00
parent 5af01d2436
commit 4e17628f97
2 changed files with 18 additions and 7 deletions

View File

@ -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",

View File

@ -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);