@@ -9,12 +9,14 @@ import {
99 Configure ,
1010 useRefinementList ,
1111 useInstantSearch ,
12+ Pagination ,
1213} from 'react-instantsearch'
1314import { liteClient } from 'algoliasearch/lite'
1415import { MdClose , MdSearch } from 'react-icons/md'
1516import { Link , useRouterState } from '@tanstack/react-router'
1617import { useSearchContext } from '~/contexts/SearchContext'
1718import { frameworkOptions , libraries } from '~/libraries'
19+ import { capitalize } from '~/utils/utils'
1820
1921const searchClient = liteClient (
2022 'FQ0DQ6MA3C' ,
@@ -111,7 +113,7 @@ const Hit = ({ hit, isFocused }: { hit: any; isFocused?: boolean }) => {
111113 tabIndex = { - 1 }
112114 ref = { ref }
113115 >
114- < div className = "flex items-start gap-4" >
116+ < article className = "flex items-start gap-4" >
115117 < div className = "flex-1" >
116118 < h3 className = "font-bold text-gray-900 dark:text-white" >
117119 < Highlight attribute = "hierarchy.lvl1" hit = { hit } />
@@ -134,26 +136,26 @@ const Hit = ({ hit, isFocused }: { hit: any; isFocused?: boolean }) => {
134136 </ p >
135137 ) : null }
136138 </ 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" >
145147 < div className = "flex items-center gap-1 text-xs font-black bg-white rounded-xl px-2 py-1 dark:bg-black" >
146148 < img
147149 src = { framework . logo }
148150 alt = { framework . label }
149151 className = "w-4"
150152 />
151- { framework . label }
153+ { capitalize ( framework . label ) }
152154 </ div >
153- )
154- } ) ( ) }
155- </ div >
156- </ div >
155+ </ div >
156+ )
157+ } ) ( ) }
158+ </ article >
157159 </ SafeLink >
158160 )
159161}
@@ -204,7 +206,10 @@ function LibraryRefinement() {
204206 : 'bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700'
205207 ) }
206208 >
207- { item . label } ({ item . count . toLocaleString ( ) } )
209+ { capitalize ( item . label ) } { ' ' }
210+ < span className = "tabular-nums" >
211+ ({ item . count . toLocaleString ( ) } )
212+ </ span >
208213 </ button >
209214 )
210215 } ) }
@@ -271,7 +276,10 @@ function FrameworkRefinement() {
271276 : 'bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700'
272277 ) }
273278 >
274- { item . label } ({ item . count . toLocaleString ( ) } )
279+ { capitalize ( item . label ) } { ' ' }
280+ < span className = "tabular-nums" >
281+ ({ item . count . toLocaleString ( ) } )
282+ </ span >
275283 </ button >
276284 )
277285 } ) }
@@ -389,8 +397,8 @@ export function SearchModal() {
389397 onKeyDown = { handleKeyDown }
390398 >
391399 < 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 " >
394402 < InstantSearch searchClient = { searchClient } indexName = "tanstack" >
395403 < Configure
396404 attributesToRetrieve = { [
@@ -419,7 +427,7 @@ export function SearchModal() {
419427 placeholder = "Search..."
420428 classNames = { {
421429 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' ,
423431 input :
424432 'flex-1 p-4 pl-0 outline-none font-bold [&::-webkit-search-cancel-button]:hidden bg-transparent' ,
425433 submit : 'p-2' ,
@@ -457,7 +465,7 @@ function SearchResults({ focusedIndex }: { focusedIndex: number }) {
457465 < LibraryRefinement />
458466 < FrameworkRefinement />
459467 < div
460- className = "max-h-[60vh ] overflow-y-auto"
468+ className = "max-h-[70dvh] lg:max-h-[60dvh ] overflow-y-auto"
461469 role = "listbox"
462470 aria-label = "Search results"
463471 >
@@ -470,6 +478,16 @@ function SearchResults({ focusedIndex }: { focusedIndex: number }) {
470478 return < Hit hit = { hit } isFocused = { index === focusedIndex } />
471479 } }
472480 />
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+ />
473491 </ div >
474492 </ >
475493 )
0 commit comments