Skip to content

Commit 9837dc2

Browse files
committed
Update filter options
1 parent a03708d commit 9837dc2

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

src/components/Feed.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,16 @@ const Feed: React.FC<FeedProps> = memo(({ subreddit, initialTime, initialSort })
191191
/>
192192
</div>
193193

194-
<div className="mb-2">
194+
<div className="mb-4 flex flex-wrap gap-3">
195195
{filterOptions.map((optionGroup, index) =>
196196
optionGroup.label === "Time" && sort !== "top" ? null : (
197197
<div
198-
className="text-black dark:text-gray-400 text-sm mb-2"
198+
className="flex items-center"
199199
key={index}
200200
>
201-
<label className="mr-1 font-medium">{optionGroup.label}</label>
201+
<label className="mr-2 font-medium text-sm text-gray-700 dark:text-gray-300">
202+
{optionGroup.label}
203+
</label>
202204
<select
203205
value={optionGroup.label === "Sort by" ? sort : time}
204206
onChange={(e) => {
@@ -211,7 +213,7 @@ const Feed: React.FC<FeedProps> = memo(({ subreddit, initialTime, initialSort })
211213
break;
212214
}
213215
}}
214-
className="p-1 rounded dark:bg-gray-800 text-black dark:text-gray-400 font-medium"
216+
className="text-sm border border-gray-200 dark:border-gray-600 rounded-md px-1 py-1 font-medium text-gray-800 dark:text-gray-200 dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent"
215217
>
216218
{optionGroup.options.map((option) => (
217219
<option key={option.value} value={option.value}>

src/components/SearchPage.tsx

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,40 @@ const SearchPage: React.FC<SearchPageProps> = memo(({ query, sort: initialSort,
161161
{subreddit ? `r/${subreddit}` : "all subreddits"}
162162
</div>
163163

164-
{filterOptions.map((optionGroup, index) =>
165-
optionGroup.label === "Time" && !["relevance", "top", "comments"].includes(sort) ? null : (
166-
<div className="text-black dark:text-gray-400 text-sm mb-2" key={index}>
167-
<label className="mr-1 font-medium">{optionGroup.label}</label>
168-
<select
169-
value={optionGroup.label === "Sort by" ? sort : time}
170-
onChange={(e) => {
171-
switch (optionGroup.label) {
172-
case "Sort by":
173-
setSort(e.target.value);
174-
break;
175-
case "Time":
176-
setTime(e.target.value);
177-
break;
178-
}
179-
}}
180-
className="p-1 rounded dark:bg-gray-800 text-black dark:text-gray-400 font-medium"
164+
<div className="mb-4 flex flex-wrap gap-3">
165+
{filterOptions.map((optionGroup, index) =>
166+
optionGroup.label === "Time" && !["relevance", "top", "comments"].includes(sort) ? null : (
167+
<div
168+
className="flex items-center"
169+
key={index}
181170
>
182-
{optionGroup.options.map((option) => (
183-
<option key={option.value} value={option.value}>
184-
{option.key}
185-
</option>
186-
))}
187-
</select>
188-
</div>
189-
)
190-
)}
171+
<label className="mr-2 font-medium text-sm text-gray-700 dark:text-gray-300">
172+
{optionGroup.label}
173+
</label>
174+
<select
175+
value={optionGroup.label === "Sort by" ? sort : time}
176+
onChange={(e) => {
177+
switch (optionGroup.label) {
178+
case "Sort by":
179+
setSort(e.target.value);
180+
break;
181+
case "Time":
182+
setTime(e.target.value);
183+
break;
184+
}
185+
}}
186+
className="text-sm border border-gray-200 dark:border-gray-600 rounded-md px-1 py-1 font-medium text-gray-800 dark:text-gray-200 dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent"
187+
>
188+
{optionGroup.options.map((option) => (
189+
<option key={option.value} value={option.value}>
190+
{option.key}
191+
</option>
192+
))}
193+
</select>
194+
</div>
195+
)
196+
)}
197+
</div>
191198

192199
<div className="my-2 w-full">
193200
{!subreddit && searchSubreddits.slice(0, 4).map((subreddit, index) => (

0 commit comments

Comments
 (0)