Skip to content

Commit

Permalink
Merge pull request #553 from StephenMcConnel/BL-13307-ImproveSearchDe…
Browse files Browse the repository at this point in the history
…eperMsg

Improve the UI for empty search and Search Deeper (BL-13307) (#553)
  • Loading branch information
andrew-polk authored Jul 10, 2024
2 parents e81091c + 8ecb369 commit a3e3a12
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/components/ListOfBookGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const ListOfBookGroups: React.FunctionComponent<{
<ul
css={css`
padding-left: 20px;
min-height: 200px;
flex-shrink: 0;
list-style: none;
`}
Expand Down
20 changes: 17 additions & 3 deletions src/components/NoSearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import React from "react";
import { useTrack } from "../analytics/Analytics";
import { FormattedMessage } from "react-intl";
import { useIntl, FormattedMessage } from "react-intl";

// This is displayed when the user types a search and there are no matches.
// It also reports this event to analytics.
export const NoSearchResults: React.FunctionComponent<{ match: string }> = (
props
) => {
useTrack("Search Failed", { match: props.match }, true);
const l10n = useIntl();
const buttonLabel = l10n.formatMessage({
id: "header.searchDeeper",
defaultMessage: "Search Deeper",
});
const message =
"We didn't find an exact match in a title for {searchTerms}. Click {buttonLabel} to search in other fields and with looser matching.";
return (
<div>
<FormattedMessage
id="search.noSearchResults"
defaultMessage="No books in the library match the search {searchString}"
values={{ searchString: props.match }}
defaultMessage={message}
values={{
searchTerms: (
<strong>
<em>{props.match}</em>
</strong>
),
buttonLabel: <em>{buttonLabel}</em>,
}}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/localization/Code Strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"message": "search for books"
},
"search.noSearchResults": {
"description": "",
"message": "No books in the library match the search {searchString}"
"description": "The \"{searchTerms}\" must be left untranslated in the place where the search terms would be substituted for displaying to the user. The \"{buttonLabel}\" must be left untranslated in the place where the label for the \"Search Deeper\" button would be substituted for displaying to the user.",
"message": "We didn't find an exact match in a title for {searchTerms}. Click {buttonLabel} to search in other fields and with looser matching."
},
"search": {
"description": "Priority - Low",
Expand Down

0 comments on commit a3e3a12

Please sign in to comment.