Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@
"type": "object",
"required": ["sort"],
"properties": {
"searchHistoryTitle": {
"title": "Search History Title for Search Results Dropdown",
"type": "string",
"default": "History"
},
"searchTopTitle": {
"title": "Search Top Title for Search Results Dropdown",
"type": "string",
"default": "Top search"
},
"searchProductsTitle": {
"title": "Search Products Title for Search Results Dropdown",
"type": "string",
"default": "Suggested products"
},
"placeholder": {
"title": "Placeholder for Search Bar",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions packages/core/cms/faststore/sections.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@
"type": "object",
"required": ["sort"],
"properties": {
"searchHistoryTitle": {
"title": "Search History Title for Search Results Dropdown",
"type": "string",
"default": "History"
},
"searchTopTitle": {
"title": "Search Top Title for Search Results Dropdown",
"type": "string",
"default": "Top search"
},
"searchProductsTitle": {
"title": "Search Products Title for Search Results Dropdown",
"type": "string",
"default": "Suggested products"
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"placeholder": {
"title": "Placeholder for Search Bar",
"type": "string",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/components/navigation/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ function Navbar({
placeholder={searchInput?.placeholder}
sort={searchInput?.sort}
quickOrderSettings={searchInput?.quickOrderSettings}
searchHistoryTitle={searchInput?.searchHistoryTitle}
searchTopTitle={searchInput?.searchTopTitle}
searchProductsTitle={searchInput?.searchProductsTitle}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
/>
)}

Expand Down Expand Up @@ -184,6 +187,9 @@ function Navbar({
quickOrderSettings={searchInput?.quickOrderSettings}
hidden={!searchExpanded}
aria-hidden={!searchExpanded}
searchHistoryTitle={searchInput?.searchHistoryTitle}
searchTopTitle={searchInput?.searchTopTitle}
searchProductsTitle={searchInput?.searchProductsTitle}
/>
)}
{isDesktop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import type {
import { formatSearchPath } from 'src/sdk/search/formatSearchPath'

interface SearchDropdownProps {
searchHistoryTitle?: string
searchTopTitle?: string
searchProductsTitle?: string
sort: SearchState['sort']
quickOrderSettings?: NavbarProps['searchInput']['quickOrderSettings']
[key: string]: any
Expand All @@ -45,6 +48,9 @@ function SearchDropdown({
sort,
quickOrderSettings,
onChangeCustomSearchDropdownVisible,
searchProductsTitle,
searchHistoryTitle,
searchTopTitle,
...otherProps
}: SearchDropdownProps) {
const {
Expand All @@ -53,8 +59,8 @@ function SearchDropdown({

return (
<UISearchDropdown {...otherProps}>
<SearchHistory sort={sort} />
<SearchTop sort={sort} />
<SearchHistory title={searchHistoryTitle} sort={sort} />
<SearchTop title={searchTopTitle} sort={sort} />
<UISearchAutoComplete>
{terms?.map(({ value: suggestion }) => (
<UISearchAutoCompleteTerm
Expand Down Expand Up @@ -96,6 +102,7 @@ function SearchDropdown({
data-af-element={searchId && 'search-autocomplete'}
data-af-onimpression={!!searchId}
data-af-search-id={searchId}
title={searchProductsTitle}
>
{products.map((product, index) => {
const productParsed = product as ProductSummary_ProductFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import {
} from '@faststore/ui'
Comment thread
evander-corebiz marked this conversation as resolved.
import useSearchHistory from 'src/sdk/search/useSearchHistory'

const SearchHistory = ({ ...props }) => {
export interface SearchHistoryProps {
title?: string
[x: string]: any
}
Comment thread
evander-corebiz marked this conversation as resolved.
Outdated

const SearchHistory = ({ title = 'History', ...props }: SearchHistoryProps) => {
const {
values: { onSearchSelection },
} = useSearch()
Expand All @@ -16,7 +21,7 @@ const SearchHistory = ({ ...props }) => {
}

return (
<UISearchHistory title="History" onClear={clearSearchHistory} {...props}>
<UISearchHistory title={title} onClear={clearSearchHistory} {...props}>
{searchHistory.map((item) => (
<UISearchHistoryTerm
key={item.term}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export type SearchInputProps = {
placeholder?: string
quickOrderSettings?: NavbarProps['searchInput']['quickOrderSettings']
sort?: string
searchHistoryTitle?: string
searchTopTitle?: string
searchProductsTitle?: string
} & Omit<UISearchInputFieldProps, 'onSubmit'>

export type SearchInputRef = UISearchInputFieldRef & {
Expand All @@ -77,6 +80,9 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
sort,
placeholder,
quickOrderSettings,
searchHistoryTitle,
searchTopTitle,
searchProductsTitle,
...otherProps
},
ref
Expand Down Expand Up @@ -179,6 +185,9 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
onChangeCustomSearchDropdownVisible={
setCustomSearchDropdownVisibleCondition
}
searchHistoryTitle={searchHistoryTitle}
searchTopTitle={searchTopTitle}
searchProductsTitle={searchProductsTitle}
/>
</Suspense>
)}
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/components/search/SearchTop/SearchTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useTopSearch from 'src/sdk/search/useTopSearch'
const MAX_TOP_SEARCH_TERMS = 5

export interface SearchTopProps extends HTMLAttributes<HTMLDivElement> {
title?: string
/**
* List of top searched items
*/
Expand All @@ -23,7 +24,12 @@ export interface SearchTopProps extends HTMLAttributes<HTMLDivElement> {
sort?: string
}

function SearchTop({ topTerms = [], sort, ...otherProps }: SearchTopProps) {
function SearchTop({
topTerms = [],
sort,
title = 'Top Search',
...otherProps
}: SearchTopProps) {
const {
values: { onSearchSelection },
} = useSearch()
Expand All @@ -38,7 +44,7 @@ function SearchTop({ topTerms = [], sort, ...otherProps }: SearchTopProps) {
}

return (
<UISearchTop title="Top Search" {...otherProps}>
<UISearchTop title={title} {...otherProps}>
{terms.map((term, index) => (
<UISearchTopTerm
key={index}
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/sections/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export interface NavbarProps {
searchInput: {
placeholder?: string
sort: string
searchHistoryTitle?: string
searchTopTitle?: string
searchProductsTitle?: string
quickOrderSettings?: {
quickOrder: boolean
skuMatrix: {
Expand Down