@@ -20,6 +20,7 @@ import SearchItemSkeleton from "@/components/photoFeed/mainFeed/SearchItemSkelet
2020import PhotoCardSkeleton from "@/components/photoFeed/mainFeed/PhotoCardSkeleton" ;
2121import SearchPostSkeleton from "@/components/photoFeed/mainFeed/SearchPostSkeleton" ;
2222import EmptyView from "@/components/common/EmptyView" ;
23+ import Masonry from "react-masonry-css" ;
2324
2425const 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+
4148export 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