Skip to content

Commit 1a72380

Browse files
authored
Merge pull request #252 from Finders-Official/feat/photo-feed-search-filter(#228)
[FEAT] ์‚ฌ์ง„์ˆ˜๋‹ค ๊ฒ€์ƒ‰์—์„œ ๋นˆํ™”๋ฉด์— ํ•„ํ„ฐ๋ง ์ถ”๊ฐ€
2 parents 9687860 + 2d4288d commit 1a72380

1 file changed

Lines changed: 60 additions & 44 deletions

File tree

โ€Žsrc/pages/photoFeed/PhotoFeedSearchPage.tsxโ€Ž

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import SearchItemSkeleton from "@/components/photoFeed/mainFeed/SearchItemSkelet
2020
import PhotoCardSkeleton from "@/components/photoFeed/mainFeed/PhotoCardSkeleton";
2121
import SearchPostSkeleton from "@/components/photoFeed/mainFeed/SearchPostSkeleton";
2222
import EmptyView from "@/components/common/EmptyView";
23+
import Masonry from "react-masonry-css";
2324

2425
const FILTER_LABEL: Record<Filter, string> = {
2526
TITLE: "์ œ๋ชฉ๋งŒ",
@@ -38,6 +39,12 @@ const SKELETON_HEIGHTS = [
3839
"h-[340px]",
3940
];
4041

42+
const breakpointColumnsObj = {
43+
default: 2, // ๋””์ž์ธ์ด 2์—ด์ด๋ฉด ๊ณ ์ •์ด ๊ฐ€์žฅ ์•ˆ์ •์ 
44+
768: 2,
45+
1024: 2,
46+
};
47+
4148
export default function PhotoFeedSearchPage() {
4249
const navigate = useNavigate();
4350
const location = useLocation();
@@ -258,58 +265,67 @@ export default function PhotoFeedSearchPage() {
258265
const renderResult = () => {
259266
if (isSearchPending) {
260267
return (
261-
<section className="columns-2 gap-4 md:columns-3 xl:columns-4">
262-
{Array.from({ length: SKELETON_COUNT }).map((_, i) => {
263-
const heightClass = SKELETON_HEIGHTS[i % SKELETON_HEIGHTS.length];
264-
265-
return (
266-
<PhotoCardSkeleton
267-
key={`skeleton-${i}`}
268-
className={heightClass}
269-
/>
270-
);
271-
})}
268+
<section className="mb-20">
269+
<Masonry
270+
breakpointCols={breakpointColumnsObj}
271+
className="my-masonry-grid"
272+
columnClassName="my-masonry-grid_column"
273+
>
274+
{Array.from({ length: SKELETON_COUNT }).map((_, i) => {
275+
const heightClass = SKELETON_HEIGHTS[i % SKELETON_HEIGHTS.length];
276+
277+
return (
278+
<PhotoCardSkeleton
279+
key={`skeleton-${i}`}
280+
className={heightClass}
281+
/>
282+
);
283+
})}
284+
</Masonry>
272285
</section>
273286
);
274287
}
275288

276289
if (isSearchError) return errorResponse();
277290

278-
if (previewList.length === 0) {
279-
return <EmptyView />;
280-
}
281-
282-
if (previewList.length > 0) {
283-
return (
284-
<div className="mt-4 flex flex-col gap-4">
285-
<div className="flex items-center justify-between">
286-
<div className="flex items-center gap-2">
287-
<h2 className="text-[1rem] leading-[155%] font-semibold tracking-[-0.02em] text-neutral-100">
288-
๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ
289-
</h2>
290-
<p className="text-[1rem] font-light text-neutral-100">
291-
{totalCount}๊ฐœ
292-
</p>
293-
</div>
294-
<button
295-
type="button"
296-
onClick={() => {
297-
setBottomSheetOpen(true);
298-
}}
299-
className="flex items-center gap-[6px] text-[0.875rem] leading-[155%] font-normal tracking-[-0.02em] text-neutral-400"
300-
>
301-
<span>{FILTER_LABEL[filter]}</span>
302-
<ChevronLeftIcon className="h-4 w-4 rotate-[-90deg] text-neutral-200" />
303-
</button>
291+
return (
292+
<div className="mt-4 flex flex-col gap-4">
293+
<div className="flex items-center justify-between">
294+
<div className="flex items-center gap-2">
295+
<h2 className="text-[1rem] leading-[155%] font-semibold tracking-[-0.02em] text-neutral-100">
296+
๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ
297+
</h2>
298+
<p className="text-[1rem] font-light text-neutral-100">
299+
{totalCount}๊ฐœ
300+
</p>
304301
</div>
305-
<section className="columns-2 gap-4 md:columns-3 xl:columns-4">
306-
{previewList.map((photo) => (
307-
<PhotoCard key={photo.postId} photo={photo} />
308-
))}
309-
</section>
302+
<button
303+
type="button"
304+
onClick={() => {
305+
setBottomSheetOpen(true);
306+
}}
307+
className="flex items-center gap-[6px] text-[0.875rem] leading-[155%] font-normal tracking-[-0.02em] text-neutral-400"
308+
>
309+
<span>{FILTER_LABEL[filter]}</span>
310+
<ChevronLeftIcon className="h-4 w-4 rotate-[-90deg] text-neutral-200" />
311+
</button>
310312
</div>
311-
);
312-
}
313+
{previewList.length === 0 && <EmptyView />}
314+
{previewList.length > 0 && (
315+
<section className="mb-20">
316+
<Masonry
317+
breakpointCols={breakpointColumnsObj}
318+
className="my-masonry-grid"
319+
columnClassName="my-masonry-grid_column"
320+
>
321+
{previewList.map((photo) => (
322+
<PhotoCard key={photo.postId} photo={photo} />
323+
))}
324+
</Masonry>
325+
</section>
326+
)}
327+
</div>
328+
);
313329
};
314330

315331
const searchBarProps = {

0 commit comments

Comments
ย (0)