-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak search results header; improve
/results
types; prep for proje…
…ct results (#611) * Update results * Improve types * Fix broken test
- Loading branch information
Showing
9 changed files
with
54 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
<h1 | ||
data-test-results-header-text | ||
class="mb-4 text-display-300 font-semibold" | ||
>{{@results.nbHits}} | ||
{{if (eq 1 @results.nbHits) "document" "documents"}} | ||
{{#if @query}} | ||
matching | ||
<mark> | ||
{{@query}} | ||
</mark> | ||
{{/if}} | ||
</h1> | ||
<h2 data-test-results-subhead class="mb-6 text-display-300 font-semibold"> | ||
{{@docResults.nbHits}} | ||
{{if (eq @docResults.nbHits 1) "match" "matches"}} | ||
</h2> | ||
<ol class="divided-list"> | ||
{{#each @results.hits as |doc|}} | ||
{{#each @docResults.hits as |doc|}} | ||
<li data-test-doc-search-result class="group relative"> | ||
<Doc::TileMedium @doc={{doc}} @query={{@query}} /> | ||
</li> | ||
{{/each}} | ||
</ol> | ||
|
||
<Pagination | ||
@currentPage={{(add @results.page 1)}} | ||
@nbPages={{@results.nbPages}} | ||
@currentPage={{(add (or @docResults.page 0) 1)}} | ||
@nbPages={{@docResults.nbPages}} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
import Component from "@glimmer/component"; | ||
import { SearchResponse } from "@algolia/client-search"; | ||
import { HermesDocument } from "hermes/types/document"; | ||
import { capitalize } from "@ember/string"; | ||
|
||
interface ResultsIndexComponentSignature { | ||
Args: { | ||
results: SearchResponse<HermesDocument>; | ||
query: string; | ||
docResults?: SearchResponse<HermesDocument>; | ||
query: string | null; | ||
}; | ||
} | ||
|
||
export default class ResultsIndexComponent extends Component<ResultsIndexComponentSignature> { | ||
get lowercasedQuery(): string { | ||
return this.args.query?.toLowerCase(); | ||
} | ||
|
||
get capitalizedQuery(): string { | ||
return capitalize(this.lowercasedQuery); | ||
} | ||
export default class ResultsIndexComponent extends Component<ResultsIndexComponentSignature> {} | ||
|
||
get queryIsProductName(): boolean { | ||
let hits = this.args.results?.hits as HermesDocument[]; | ||
// Assume at least one of the first 12 hits is a product match for the query. | ||
return hits.some( | ||
(hit) => hit.product?.toLowerCase() === this.lowercasedQuery, | ||
); | ||
declare module "@glint/environment-ember-loose/registry" { | ||
export default interface Registry { | ||
Results: typeof ResultsIndexComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
{{page-title this.pageTitle}} | ||
|
||
<Header::Toolbar @facets={{this.model.facets}} /> | ||
<div class="mb-6"> | ||
<h1 data-test-results-headline class="w-full text-display-500"> | ||
Results | ||
{{#if this.q}} | ||
for | ||
<mark>{{this.q}}</mark> | ||
{{/if}} | ||
</h1> | ||
</div> | ||
|
||
<Results @results={{this.model.results}} @query={{this.q}} /> | ||
<Header::Toolbar @facets={{this.model.docFacets}} /> | ||
|
||
<Results @docResults={{this.model.docResults}} @query={{this.q}} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters