@@ -9,12 +9,14 @@ import {
9
9
Configure ,
10
10
useRefinementList ,
11
11
useInstantSearch ,
12
+ Pagination ,
12
13
} from 'react-instantsearch'
13
14
import { liteClient } from 'algoliasearch/lite'
14
15
import { MdClose , MdSearch } from 'react-icons/md'
15
16
import { Link , useRouterState } from '@tanstack/react-router'
16
17
import { useSearchContext } from '~/contexts/SearchContext'
17
18
import { frameworkOptions , libraries } from '~/libraries'
19
+ import { capitalize } from '~/utils/utils'
18
20
19
21
const searchClient = liteClient (
20
22
'FQ0DQ6MA3C' ,
@@ -111,7 +113,7 @@ const Hit = ({ hit, isFocused }: { hit: any; isFocused?: boolean }) => {
111
113
tabIndex = { - 1 }
112
114
ref = { ref }
113
115
>
114
- < div className = "flex items-start gap-4" >
116
+ < article className = "flex items-start gap-4" >
115
117
< div className = "flex-1" >
116
118
< h3 className = "font-bold text-gray-900 dark:text-white" >
117
119
< Highlight attribute = "hierarchy.lvl1" hit = { hit } />
@@ -134,26 +136,26 @@ const Hit = ({ hit, isFocused }: { hit: any; isFocused?: boolean }) => {
134
136
</ p >
135
137
) : null }
136
138
</ div >
137
- < div className = "flex-none" >
138
- { ( ( ) => {
139
- const framework = frameworkOptions . find ( ( f ) =>
140
- hit . url . includes ( `/framework/ ${ f . value } ` )
141
- )
142
- if ( ! framework ) return null
143
-
144
- return (
139
+ { ( ( ) => {
140
+ const framework = frameworkOptions . find ( ( f ) =>
141
+ hit . url . includes ( `/framework/ ${ f . value } ` )
142
+ )
143
+ if ( ! framework ) return null
144
+
145
+ return (
146
+ < div className = "flex-none" >
145
147
< div className = "flex items-center gap-1 text-xs font-black bg-white rounded-xl px-2 py-1 dark:bg-black" >
146
148
< img
147
149
src = { framework . logo }
148
150
alt = { framework . label }
149
151
className = "w-4"
150
152
/>
151
- { framework . label }
153
+ { capitalize ( framework . label ) }
152
154
</ div >
153
- )
154
- } ) ( ) }
155
- </ div >
156
- </ div >
155
+ </ div >
156
+ )
157
+ } ) ( ) }
158
+ </ article >
157
159
</ SafeLink >
158
160
)
159
161
}
@@ -204,7 +206,10 @@ function LibraryRefinement() {
204
206
: 'bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700'
205
207
) }
206
208
>
207
- { item . label } ({ item . count . toLocaleString ( ) } )
209
+ { capitalize ( item . label ) } { ' ' }
210
+ < span className = "tabular-nums" >
211
+ ({ item . count . toLocaleString ( ) } )
212
+ </ span >
208
213
</ button >
209
214
)
210
215
} ) }
@@ -271,7 +276,10 @@ function FrameworkRefinement() {
271
276
: 'bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700'
272
277
) }
273
278
>
274
- { item . label } ({ item . count . toLocaleString ( ) } )
279
+ { capitalize ( item . label ) } { ' ' }
280
+ < span className = "tabular-nums" >
281
+ ({ item . count . toLocaleString ( ) } )
282
+ </ span >
275
283
</ button >
276
284
)
277
285
} ) }
@@ -389,8 +397,8 @@ export function SearchModal() {
389
397
onKeyDown = { handleKeyDown }
390
398
>
391
399
< div className = "min-h-screen text-center" >
392
- < Dialog . Overlay className = "fixed inset-0 bg-black/30" />
393
- < div className = "inline-block w-full max-w-2xl my -8 overflow-hidden text-left align-middle transition-all transform bg-white/80 dark:bg-black/80 shadow-xl rounded-2xl divide-y divide-gray-500/20 backdrop-blur-lg" >
400
+ < Dialog . Overlay className = "fixed inset-0 bg-black/60 xl:bg-black/ 30" />
401
+ < div className = "inline-block w-[98%] xl:w- full max-w-2xl mt -8 overflow-hidden text-left align-middle transition-all transform bg-white/80 dark:bg-black/80 shadow-xl rounded-lg xl:rounded-xl divide-y divide-gray-500/20 backdrop-blur-lg dark:border dark:border-white/20 " >
394
402
< InstantSearch searchClient = { searchClient } indexName = "tanstack" >
395
403
< Configure
396
404
attributesToRetrieve = { [
@@ -419,7 +427,7 @@ export function SearchModal() {
419
427
placeholder = "Search..."
420
428
classNames = { {
421
429
root : 'w-full' ,
422
- form : 'text-2xl flex items-center gap-2 px-4' ,
430
+ form : 'text-xl flex items-center gap-2 px-4' ,
423
431
input :
424
432
'flex-1 p-4 pl-0 outline-none font-bold [&::-webkit-search-cancel-button]:hidden bg-transparent' ,
425
433
submit : 'p-2' ,
@@ -457,7 +465,7 @@ function SearchResults({ focusedIndex }: { focusedIndex: number }) {
457
465
< LibraryRefinement />
458
466
< FrameworkRefinement />
459
467
< div
460
- className = "max-h-[60vh ] overflow-y-auto"
468
+ className = "max-h-[70dvh] lg:max-h-[60dvh ] overflow-y-auto"
461
469
role = "listbox"
462
470
aria-label = "Search results"
463
471
>
@@ -470,6 +478,16 @@ function SearchResults({ focusedIndex }: { focusedIndex: number }) {
470
478
return < Hit hit = { hit } isFocused = { index === focusedIndex } />
471
479
} }
472
480
/>
481
+ < Pagination
482
+ padding = { 2 }
483
+ className = { twMerge (
484
+ 'border-t text-sm dark:border-white/20 px-4 py-3' ,
485
+ '[&>ul]:w-full [&>ul]:flex [&>ul]:justify-center [&>ul]:gap-2 lg:[&>ul]:gap-4' ,
486
+ '[&_li>*]:px-3 [&_li>*]:py-1.5' ,
487
+ '[&_li>span]:cursor-not-allowed' ,
488
+ '[&_.ais-Pagination-item--selected>*]:bg-emerald-500 [&_.ais-Pagination-item--selected>*]:text-white [&_.ais-Pagination-item--selected>*]:rounded-lg'
489
+ ) }
490
+ />
473
491
</ div >
474
492
</ >
475
493
)
0 commit comments