|
3 | 3 | import {Autocomplete, OverlayTriggerStateContext, Provider, Dialog as RACDialog, DialogProps as RACDialogProps, Tab as RACTab, TabList as RACTabList, TabPanel as RACTabPanel, TabPanelProps as RACTabPanelProps, TabProps as RACTabProps, Tabs as RACTabs, SelectionIndicator, TabRenderProps} from 'react-aria-components'; |
4 | 4 | import {baseColor, focusRing, style} from '@react-spectrum/s2/style' with {type: 'macro'}; |
5 | 5 | import {CloseButton, SearchField, TextContext} from '@react-spectrum/s2'; |
| 6 | +import {ColorSearchSkeleton} from './colorSearchData'; |
6 | 7 | import {ComponentCardView} from './ComponentCardView'; |
7 | 8 | import { |
8 | 9 | getResourceTags, |
| 10 | + LazyColorSearchView, |
9 | 11 | LazyIconSearchView, |
10 | 12 | SearchEmptyState, |
| 13 | + useFilteredColors, |
11 | 14 | useSearchMenuState |
12 | 15 | } from './searchUtils'; |
13 | 16 | import {IconSearchSkeleton, useIconFilter} from './IconSearchView'; |
@@ -237,6 +240,9 @@ function MobileNav({initialTag}: {initialTag?: string}) { |
237 | 240 | isOpen |
238 | 241 | }); |
239 | 242 |
|
| 243 | + const filteredColors = useFilteredColors(searchValue); |
| 244 | + const isColorsSelected = selectedSection === 'colors'; |
| 245 | + |
240 | 246 | let handleSearchFocus = () => { |
241 | 247 | setSearchFocused(true); |
242 | 248 | }; |
@@ -327,25 +333,59 @@ function MobileNav({initialTag}: {initialTag?: string}) { |
327 | 333 | contentClassName={style({display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 8, marginX: 0})} /> |
328 | 334 | </div> |
329 | 335 | </div> |
330 | | - <div key={selectedLibrary + selectedSection} className={style({paddingX: 12, minHeight: 0, flexGrow: 1, overflow: 'clip', display: 'flex', flexDirection: 'column'})}> |
331 | | - {showIcons ? ( |
| 336 | + <div |
| 337 | + key={selectedLibrary + selectedSection} |
| 338 | + className={style({ |
| 339 | + paddingX: 12, |
| 340 | + minHeight: 0, |
| 341 | + flexGrow: 1, |
| 342 | + overflow: 'clip', |
| 343 | + display: 'flex', |
| 344 | + flexDirection: 'column' |
| 345 | + })}> |
| 346 | + {showIcons && ( |
332 | 347 | <Suspense fallback={<IconSearchSkeleton />}> |
333 | | - <LazyIconSearchView |
334 | | - filteredItems={filteredIcons} |
335 | | - listBoxClassName={style({flexGrow: 1, overflow: 'auto', width: '100%', scrollPaddingY: 4})} /> |
| 348 | + <LazyIconSearchView |
| 349 | + filteredItems={filteredIcons} |
| 350 | + listBoxClassName={style({ |
| 351 | + flexGrow: 1, |
| 352 | + overflow: 'auto', |
| 353 | + width: '100%', |
| 354 | + scrollPaddingY: 4 |
| 355 | + })} /> |
336 | 356 | </Suspense> |
337 | | - ) : ( |
| 357 | + )} |
| 358 | + {!showIcons && isColorsSelected && library.id === 'react-spectrum' && ( |
| 359 | + <div |
| 360 | + className={style({ |
| 361 | + flexGrow: 1, |
| 362 | + overflow: 'auto', |
| 363 | + paddingBottom: 16 |
| 364 | + })}> |
| 365 | + <Suspense fallback={<ColorSearchSkeleton />}> |
| 366 | + <LazyColorSearchView |
| 367 | + filteredItems={filteredColors.sections} |
| 368 | + exactMatches={filteredColors.exactMatches} |
| 369 | + closestMatches={filteredColors.closestMatches} /> |
| 370 | + </Suspense> |
| 371 | + </div> |
| 372 | + )} |
| 373 | + {!showIcons && (!isColorsSelected || library.id !== 'react-spectrum') && ( |
338 | 374 | <ComponentCardView |
339 | 375 | currentUrl={currentUrl} |
340 | | - onAction={(key) => { |
| 376 | + onAction={key => { |
341 | 377 | if (key === currentPage.url) { |
342 | 378 | overlayTriggerState?.close(); |
343 | 379 | } |
344 | 380 | }} |
345 | 381 | items={library.id === selectedLibrary ? selectedItems : []} |
346 | 382 | ariaLabel="Pages" |
347 | 383 | size="S" |
348 | | - renderEmptyState={() => <SearchEmptyState searchValue={searchValue} libraryLabel={library.label} />} /> |
| 384 | + renderEmptyState={() => ( |
| 385 | + <SearchEmptyState |
| 386 | + searchValue={searchValue} |
| 387 | + libraryLabel={library.label} /> |
| 388 | + )} /> |
349 | 389 | )} |
350 | 390 | </div> |
351 | 391 | </Autocomplete> |
|
0 commit comments