refactor(search): one super search bar, identical in editor and portal
Drop the per-host placeholder/hint/inputId props — the bar's copy is the shared superSearch.* keys everywhere; a host only supplies its results provider.
This commit is contained in:
@@ -7897,8 +7897,6 @@ title = "Nothing here yet"
|
||||
|
||||
[portal.search]
|
||||
goTo = "Go to"
|
||||
hint = "Type to jump to any portal page"
|
||||
placeholder = "Search Stirling"
|
||||
|
||||
[portal.settings.groups]
|
||||
admin = "Admin"
|
||||
@@ -9723,8 +9721,8 @@ uploadButton = "Upload to Server"
|
||||
|
||||
[superSearch]
|
||||
ariaLabel = "Super search"
|
||||
hint = "Type to search across your files, tools and settings"
|
||||
placeholder = "Search files, tools and settings…"
|
||||
hint = "Type to search"
|
||||
placeholder = "Search Stirling"
|
||||
|
||||
[superSearch.group]
|
||||
files = "Files"
|
||||
|
||||
@@ -7987,8 +7987,6 @@ title = "Nothing here yet"
|
||||
|
||||
[portal.search]
|
||||
goTo = "Go to"
|
||||
hint = "Type to jump to any portal page"
|
||||
placeholder = "Search Stirling"
|
||||
|
||||
[portal.settings.groups]
|
||||
admin = "Admin"
|
||||
@@ -9845,8 +9843,8 @@ uploadButton = "Upload to Server"
|
||||
|
||||
[superSearch]
|
||||
ariaLabel = "Super search"
|
||||
hint = "Type to search across your files, tools and settings"
|
||||
placeholder = "Search files, tools and settings…"
|
||||
hint = "Type to search"
|
||||
placeholder = "Search Stirling"
|
||||
|
||||
[superSearch.group]
|
||||
files = "Files"
|
||||
|
||||
@@ -33,12 +33,6 @@ interface SuperSearchProps {
|
||||
* Processor provider; the portal passes its own destinations provider.
|
||||
*/
|
||||
useResults?: (query: string, active: boolean) => UseSuperSearchResult;
|
||||
/** Override the input placeholder (defaults to the editor copy). */
|
||||
placeholder?: string;
|
||||
/** Override the empty-query hint line (defaults to the editor copy). */
|
||||
hint?: string;
|
||||
/** DOM id for the input — external focus helpers target it. */
|
||||
inputId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,9 +45,6 @@ interface SuperSearchProps {
|
||||
*/
|
||||
export default function SuperSearch({
|
||||
useResults = useSuperSearch,
|
||||
placeholder,
|
||||
hint,
|
||||
inputId = "super-search-input",
|
||||
}: SuperSearchProps = {}) {
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useState("");
|
||||
@@ -190,11 +181,7 @@ export default function SuperSearch({
|
||||
>
|
||||
{!hasQuery && (
|
||||
<div className="super-search-empty">
|
||||
{hint ??
|
||||
t(
|
||||
"superSearch.hint",
|
||||
"Type to search across your files, tools and settings",
|
||||
)}
|
||||
{t("superSearch.hint", "Type to search")}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -254,15 +241,12 @@ export default function SuperSearch({
|
||||
return (
|
||||
<div className="super-search" ref={containerRef} onKeyDown={handleKeyDown}>
|
||||
<TextInput
|
||||
id={inputId}
|
||||
name={inputId}
|
||||
id="super-search-input"
|
||||
name="super-search-input"
|
||||
ref={inputRef}
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={
|
||||
placeholder ??
|
||||
t("superSearch.placeholder", "Search files, tools and settings…")
|
||||
}
|
||||
placeholder={t("superSearch.placeholder", "Search Stirling")}
|
||||
icon={
|
||||
<LocalIcon icon="search-rounded" width="1.1rem" height="1.1rem" />
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SuperSearch from "@app/components/shared/superSearch/SuperSearch";
|
||||
import { usePortalSearchResults } from "@portal/hooks/usePortalSearchResults";
|
||||
import "@portal/components/PortalSearchBar.css";
|
||||
@@ -9,15 +8,9 @@ import "@portal/components/PortalSearchBar.css";
|
||||
* focuses it (the bar registers its own shortcut).
|
||||
*/
|
||||
export function PortalSearchBar() {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="portal-searchbar">
|
||||
<SuperSearch
|
||||
useResults={usePortalSearchResults}
|
||||
placeholder={t("portal.search.placeholder", "Search Stirling")}
|
||||
hint={t("portal.search.hint", "Type to jump to any portal page")}
|
||||
inputId="portal-search-input"
|
||||
/>
|
||||
<SuperSearch useResults={usePortalSearchResults} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user