Skip to content

Commit bc3ab62

Browse files
committed
fix for mobile
1 parent 526885a commit bc3ab62

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

packages/dev/s2-docs/src/MobileSearchMenu.tsx

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
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';
44
import {baseColor, focusRing, style} from '@react-spectrum/s2/style' with {type: 'macro'};
55
import {CloseButton, SearchField, TextContext} from '@react-spectrum/s2';
6+
import {ColorSearchSkeleton} from './colorSearchData';
67
import {ComponentCardView} from './ComponentCardView';
78
import {
89
getResourceTags,
10+
LazyColorSearchView,
911
LazyIconSearchView,
1012
SearchEmptyState,
13+
useFilteredColors,
1114
useSearchMenuState
1215
} from './searchUtils';
1316
import {IconSearchSkeleton, useIconFilter} from './IconSearchView';
@@ -237,6 +240,9 @@ function MobileNav({initialTag}: {initialTag?: string}) {
237240
isOpen
238241
});
239242

243+
const filteredColors = useFilteredColors(searchValue);
244+
const isColorsSelected = selectedSection === 'colors';
245+
240246
let handleSearchFocus = () => {
241247
setSearchFocused(true);
242248
};
@@ -327,25 +333,59 @@ function MobileNav({initialTag}: {initialTag?: string}) {
327333
contentClassName={style({display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 8, marginX: 0})} />
328334
</div>
329335
</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 && (
332347
<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+
})} />
336356
</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') && (
338374
<ComponentCardView
339375
currentUrl={currentUrl}
340-
onAction={(key) => {
376+
onAction={key => {
341377
if (key === currentPage.url) {
342378
overlayTriggerState?.close();
343379
}
344380
}}
345381
items={library.id === selectedLibrary ? selectedItems : []}
346382
ariaLabel="Pages"
347383
size="S"
348-
renderEmptyState={() => <SearchEmptyState searchValue={searchValue} libraryLabel={library.label} />} />
384+
renderEmptyState={() => (
385+
<SearchEmptyState
386+
searchValue={searchValue}
387+
libraryLabel={library.label} />
388+
)} />
349389
)}
350390
</div>
351391
</Autocomplete>

0 commit comments

Comments
 (0)