From fed970834bf58e65a10aa98517ece5ed0e89c1d6 Mon Sep 17 00:00:00 2001 From: Sean Edmunds Date: Fri, 5 Sep 2025 15:02:57 -0500 Subject: [PATCH] Minor Search updates --- .../homepage/components/Search/Search.tsx | 392 ++++++------------ .../components/RecommendedApplications.tsx | 61 +++ .../components/RecommendedBookmarks.tsx | 98 +++++ .../{ => components}/SearchSelectItem.tsx | 0 4 files changed, 296 insertions(+), 255 deletions(-) create mode 100644 src/pages/homepage/components/Search/components/RecommendedApplications.tsx create mode 100644 src/pages/homepage/components/Search/components/RecommendedBookmarks.tsx rename src/pages/homepage/components/Search/{ => components}/SearchSelectItem.tsx (100%) diff --git a/src/pages/homepage/components/Search/Search.tsx b/src/pages/homepage/components/Search/Search.tsx index 1e241df..b39ca6b 100644 --- a/src/pages/homepage/components/Search/Search.tsx +++ b/src/pages/homepage/components/Search/Search.tsx @@ -8,7 +8,7 @@ import { Text, } from '@mantine/core'; import { useDisclosure, useElementSize } from '@mantine/hooks'; -import { AppItem, HelpModal, WeatherModal } from 'components'; +import { HelpModal, WeatherModal } from 'components'; import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks'; import { useEffect, useState } from 'react'; import * as fa6 from 'react-icons/fa6'; @@ -23,7 +23,9 @@ import type { Provider, SearchHistoryItem, } from 'types'; -import SearchSelectItem from './SearchSelectItem'; +import RecommendedApplications from './components/RecommendedApplications'; +import RecommendedBookmarks from './components/RecommendedBookmarks'; +import SearchSelectItem from './components/SearchSelectItem'; export default function Search({ current, @@ -90,12 +92,12 @@ export default function Search({ } = useCommonHooks(); const [placeholderValue, setPlaceholderValue] = useState(''); const [value, setValue] = useState(0); - const [historyMult, setHistoryMult] = useState(1); + const [historyMultiplier, setHistoryMultiplier] = useState(1); const handleResetSearch = () => { setSearchValue(''); setListIndex(-1); - setHistoryMult(1); + setHistoryMultiplier(1); setProviderLabel(defaultProviderLabel); setProviderURL(defaultProviderURL); }; @@ -310,10 +312,10 @@ export default function Search({ .some((word: string) => word.includes(searchWord)), ); }) - .slice(0, 10 * historyMult), + .slice(0, 10 * historyMultiplier), ]; - if (historyOptions.length >= 10 * historyMult) { + if (historyOptions.length >= 10 * historyMultiplier) { return [ ...historyOptions, { @@ -330,6 +332,72 @@ export default function Search({ return historyOptions; }; + const renderItem: any = (item: any) => { + const Icon = allIcons[item.option.icon]; + return !searchValue.startsWith('!') ? ( + item.option.value === 'load' ? ( + { + e.preventDefault(); + e.stopPropagation(); + setHistoryMultiplier((prev: number) => prev + 1); + }} + > + + {item.option.label} + + + ) : ( + + ) + ) : ( + { + e.preventDefault(); + e.stopPropagation(); + handleAppLaunchItem(item); + }} + > + + Launch + + {Icon && ( + + )} + + {item.option.name} + + + ); + }; + useEffect(() => { if (providerData && providerDataIsFetched) { setProviders(providerData); @@ -368,7 +436,7 @@ export default function Search({ if (historyData && historyDataIsFetched) { setSearchHistory(historyData); if (filteredHistory.length === 0) { - setFilteredHistory(historyData.slice(0, 10 * historyMult)); + setFilteredHistory(historyData.slice(0, 10 * historyMultiplier)); } } }, [historyData, historyDataIsFetched]); @@ -417,10 +485,10 @@ export default function Search({ padding: '.3rem', display: position === 'center' ? 'inline-flex' : 'inline-block', transition: 'margin-top .5s ease', + width: '100%', }} align='center' justify='center' - w={'100%'} >