File tree Expand file tree Collapse file tree 3 files changed +30
-13
lines changed
Angular InstantSearch/query-suggestions/src/app Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Original file line number Diff line number Diff line change 4949 margin-bottom : 2rem ;
5050}
5151
52- .ais-Hits-list {
53- display : grid;
54- grid-template-columns : repeat (4 , 1fr );
55- gap : 20px ;
52+ @media (min-width : 900px ) {
53+ .ais-Hits-list {
54+ display : grid;
55+ grid-template-columns : repeat (4 , 1fr );
56+ gap : 20px ;
57+ }
5658}
Original file line number Diff line number Diff line change @@ -22,12 +22,15 @@ <h1 class="header-title">
2222 < ais-configure [searchParameters] ="searchParameters "> </ ais-configure >
2323 < div class ="search-panel ">
2424 < div class ="search-panel__results ">
25- < ais-hits >
26- < ng-template let-hits =" hits " let-results =" results ">
27- < div *ngIf ="hits.length === 0 ">
28- No results found matching < strong > {{ results? .query }}</ strong > .
25+ < ais-stats >
26+ < ng-template let-state =" state ">
27+ < div *ngIf ="state.nbHits === 0 ">
28+ No hits for < strong > {{ state .query }}</ strong > .
2929 </ div >
30-
30+ </ ng-template >
31+ </ ais-stats >
32+ < ais-hits >
33+ < ng-template let-hits ="hits ">
3134 < ol class ="ais-Hits-list ">
3235 < li class ="ais-Hits-item " *ngFor ="let hit of hits ">
3336 < ais-highlight attribute ="name " [hit] ="hit "> </ ais-highlight >
Original file line number Diff line number Diff line change 1+ import type { Hit } from '@algolia/client-search' ;
12import {
23 Component ,
34 EventEmitter ,
@@ -21,6 +22,16 @@ export type QuerySuggestion = {
2122 category : string | null ;
2223} ;
2324
25+ type QuerySuggestionHit = Hit < {
26+ instant_search ?: {
27+ facets ?: {
28+ exact_matches ?: {
29+ categories ?: ReadonlyArray < { value : string ; count : number } > ;
30+ } ;
31+ } ;
32+ } ;
33+ } > ;
34+
2435@Component ( {
2536 selector : 'app-autocomplete' ,
2637 template : `
@@ -81,12 +92,13 @@ export class AutocompleteComponent extends TypedBaseWidget<
8192 super ( 'AutocompleteComponent' ) ;
8293 }
8394
84- hasCategory ( hit : any ) {
85- return ! ! hit ? .instant_search ?. facets ?. exact_matches ?. categories ?. length ;
95+ hasCategory ( hit : QuerySuggestionHit ) {
96+ return ! ! hit . instant_search ?. facets ?. exact_matches ?. categories ?. length ;
8697 }
8798
88- getCategory ( hit : any ) {
89- const [ category ] = hit . instant_search . facets . exact_matches . categories ;
99+ getCategory ( hit : QuerySuggestionHit ) {
100+ const [ category ] =
101+ hit . instant_search ?. facets ?. exact_matches ?. categories || [ ] ;
90102 return category . value ;
91103 }
92104
You can’t perform that action at this time.
0 commit comments