Skip to content

Commit ea81df3

Browse files
committed
Remove unused search props, add missing search translations
1 parent 1bc6519 commit ea81df3

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

.changeset/wide-olives-deny.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Remove unused search props, add missing search translations
6+
7+
## Migration
8+
9+
### `core/components/header/index.tsx`
10+
11+
Ensure the following props are passed to the `HeaderSection` navigation prop:
12+
```tsx
13+
searchInputPlaceholder: t('Search.inputPlaceholder'),
14+
searchSubmitLabel: t('Search.submitLabel'),
15+
```
16+
17+
### `core/messages/en.json`
18+
19+
Add the following keys to the `Components.Header.Search` translations:
20+
```json
21+
"somethingWentWrong": "Something went wrong. Please try again.",
22+
"inputPlaceholder": "Search products, categories, brands...",
23+
"submitLabel": "Search"
24+
```
25+
26+
### `core/vibes/soul/primitives/navigation/index.tsx`
27+
28+
Copy all changes from this file:
29+
1. Create `searchSubmitLabel?: string;` property, ensure it is passed into `SearchForm`
30+
2. On the `SearchForm`, remove the `searchCtaLabel = 'View more',` property, as it is unused, and rename `submitLabel` to `searchSubmitLabel`
31+
3. Ensure that `SearchForm` passes `searchSubmitLabel` to the `SearchButton`: `<SubmitButton loading={isPending} submitLabel={searchSubmitLabel} />`
32+
4. Remove the `searchCtaLabel` property from the `SearchResults` component

core/components/header/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ export const Header = async () => {
147147
searchHref: '/search',
148148
searchParamName: 'term',
149149
searchAction: search,
150+
searchInputPlaceholder: t('Search.inputPlaceholder'),
151+
searchSubmitLabel: t('Search.submitLabel'),
150152
links: streamableLinks,
151153
logo,
152154
mobileMenuTriggerLabel: t('toggleNavigation'),

core/messages/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@
445445
"brands": "Brands",
446446
"noSearchResultsTitle": "Sorry, no results for \"{term}\".",
447447
"noSearchResultsSubtitle": "Please try another search.",
448-
"somethingWentWrong": "Something went wrong. Please try again."
448+
"somethingWentWrong": "Something went wrong. Please try again.",
449+
"inputPlaceholder": "Search products, categories, brands...",
450+
"submitLabel": "Search"
449451
}
450452
},
451453
"Footer": {

core/vibes/soul/primitives/navigation/index.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ interface Props<S extends SearchResult> {
111111
searchHref: string;
112112
searchParamName?: string;
113113
searchAction?: SearchAction<S>;
114-
searchCtaLabel?: string;
115114
searchInputPlaceholder?: string;
115+
searchSubmitLabel?: string;
116116
cartLabel?: string;
117117
accountLabel?: string;
118118
openSearchPopupLabel?: string;
@@ -277,8 +277,8 @@ export const Navigation = forwardRef(function Navigation<S extends SearchResult>
277277
searchHref,
278278
searchParamName = 'query',
279279
searchAction,
280-
searchCtaLabel,
281280
searchInputPlaceholder,
281+
searchSubmitLabel,
282282
cartLabel = 'Cart',
283283
accountLabel = 'Profile',
284284
openSearchPopupLabel = 'Open search popup',
@@ -524,10 +524,10 @@ export const Navigation = forwardRef(function Navigation<S extends SearchResult>
524524
<div className="flex max-h-[inherit] flex-col rounded-2xl bg-[var(--nav-search-background,hsl(var(--background)))] shadow-xl ring-1 ring-[var(--nav-search-border,hsl(var(--foreground)/5%))] transition-all duration-200 ease-in-out @4xl:inset-x-0">
525525
<SearchForm
526526
searchAction={searchAction}
527-
searchCtaLabel={searchCtaLabel}
528527
searchHref={searchHref}
529528
searchInputPlaceholder={searchInputPlaceholder}
530529
searchParamName={searchParamName}
530+
searchSubmitLabel={searchSubmitLabel}
531531
/>
532532
</div>
533533
</Popover.Content>
@@ -603,15 +603,13 @@ function SearchForm<S extends SearchResult>({
603603
searchParamName = 'query',
604604
searchHref = '/search',
605605
searchInputPlaceholder = 'Search Products',
606-
searchCtaLabel = 'View more',
607-
submitLabel = 'Submit',
606+
searchSubmitLabel = 'Submit',
608607
}: {
609608
searchAction: SearchAction<S>;
610609
searchParamName?: string;
611610
searchHref?: string;
612-
searchCtaLabel?: string;
613611
searchInputPlaceholder?: string;
614-
submitLabel?: string;
612+
searchSubmitLabel?: string;
615613
}) {
616614
const [query, setQuery] = useState('');
617615
const [isSearching, startSearching] = useTransition();
@@ -672,15 +670,14 @@ function SearchForm<S extends SearchResult>({
672670
type="text"
673671
value={query}
674672
/>
675-
<SubmitButton loading={isPending} submitLabel={submitLabel} />
673+
<SubmitButton loading={isPending} submitLabel={searchSubmitLabel} />
676674
</form>
677675

678676
<SearchResults
679677
emptySearchSubtitle={emptyStateSubtitle}
680678
emptySearchTitle={emptyStateTitle}
681679
errors={form.errors}
682680
query={query}
683-
searchCtaLabel={searchCtaLabel}
684681
searchParamName={searchParamName}
685682
searchResults={searchResults}
686683
stale={isPending}
@@ -715,7 +712,6 @@ function SearchResults({
715712
}: {
716713
query: string;
717714
searchParamName: string;
718-
searchCtaLabel?: string;
719715
emptySearchTitle?: string;
720716
emptySearchSubtitle?: string;
721717
searchResults: SearchResult[] | null;

0 commit comments

Comments
 (0)