Skip to content

Commit 2517847

Browse files
authored
reorganize filters layout, allow selecting multiple module types (#1941)
1 parent f2351a7 commit 2517847

2 files changed

Lines changed: 49 additions & 37 deletions

File tree

components/Filters/index.tsx

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,42 @@ export function Filters({ query, style, basePath = '/' }: FiltersProps) {
4343
},
4444
style,
4545
]}>
46-
<View style={styles.container}>
47-
<Headline style={[styles.title, titleColor]}>Platform</Headline>
48-
<View style={styles.optionsContainer}>
49-
{FILTER_PLATFORMS.map(platform => (
50-
<ToggleLink
51-
key={platform.param}
52-
query={pageQuery}
53-
paramName={platform.param}
54-
title={platform.title}
55-
basePath={basePath}
56-
/>
57-
))}
46+
<View style={styles.twoColumns}>
47+
<View
48+
style={[
49+
styles.wrappableContainer,
50+
isSmallScreen && styles.wrappableContainerSmallScreen,
51+
]}>
52+
<Headline style={[styles.title, titleColor]}>Platform</Headline>
53+
<View style={styles.optionsContainer}>
54+
{FILTER_PLATFORMS.map(platform => (
55+
<ToggleLink
56+
key={platform.param}
57+
query={pageQuery}
58+
paramName={platform.param}
59+
title={platform.title}
60+
basePath={basePath}
61+
/>
62+
))}
63+
</View>
64+
</View>
65+
<View
66+
style={[
67+
styles.wrappableContainer,
68+
isSmallScreen && styles.wrappableContainerSmallScreen,
69+
]}>
70+
<Headline style={[styles.title, titleColor]}>Type</Headline>
71+
<View style={styles.optionsContainer}>
72+
{FILTER_TYPE.map(entryType => (
73+
<ToggleLink
74+
key={entryType.param}
75+
query={pageQuery}
76+
paramName={entryType.param}
77+
title={entryType.title}
78+
basePath={basePath}
79+
/>
80+
))}
81+
</View>
5882
</View>
5983
</View>
6084
<View style={styles.container}>
@@ -105,20 +129,6 @@ export function Filters({ query, style, basePath = '/' }: FiltersProps) {
105129
styles.wrappableContainer,
106130
isSmallScreen && styles.wrappableContainerSmallScreen,
107131
]}>
108-
<Headline style={[styles.title, titleColor]}>Type</Headline>
109-
<View style={styles.optionsContainer}>
110-
{FILTER_TYPE.map(entryType => (
111-
<ToggleLink
112-
key={entryType.param}
113-
query={pageQuery}
114-
paramName={entryType.param}
115-
title={entryType.title}
116-
basePath={basePath}
117-
/>
118-
))}
119-
</View>
120-
</View>
121-
<View style={styles.container}>
122132
<Headline style={[styles.titleWithTag, titleColor]}>
123133
Module type
124134
<Tag
@@ -180,7 +190,7 @@ const styles = StyleSheet.create({
180190
fontWeight: 600,
181191
},
182192
titleWithTag: {
183-
marginBottom: 4,
193+
marginBottom: 6,
184194
fontWeight: 600,
185195
},
186196
titleTag: {

util/search.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,18 @@ export function handleFilterLibraries({
226226
return false;
227227
}
228228

229-
if (expoModule && (!library.github.moduleType || library.github.moduleType !== 'expo')) {
230-
return false;
231-
}
232-
233-
if (nitroModule && (!library.github.moduleType || library.github.moduleType !== 'nitro')) {
234-
return false;
235-
}
236-
237-
if (turboModule && (!library.github.moduleType || library.github.moduleType !== 'turbo')) {
238-
return false;
229+
const activeModuleTypeFilters = [
230+
expoModule && 'expo',
231+
nitroModule && 'nitro',
232+
turboModule && 'turbo',
233+
].filter(Boolean);
234+
235+
if (activeModuleTypeFilters.length > 0) {
236+
const type = library.github?.moduleType;
237+
238+
if (!activeModuleTypeFilters.includes(type)) {
239+
return false;
240+
}
239241
}
240242

241243
if (minPopularityValue && minMonthlyDownloadsValue) {

0 commit comments

Comments
 (0)