-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 음식점 카드 리스트 컴포넌트 분리, 로딩 상태 추가 (#199)
- Loading branch information
Showing
5 changed files
with
71 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
frontend/src/components/RestaurantCardList/RestaurantCardList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { styled } from 'styled-components'; | ||
import RestaurantCard from '../RestaurantCard/RestaurantCard'; | ||
import type { RestaurantData, RestaurantListData } from '~/@types/api.types'; | ||
import { FONT_SIZE } from '~/styles/common'; | ||
import RestaurantCardListSkeleton from './RestaurantCardListSkeleton'; | ||
|
||
interface RestaurantCardListProps { | ||
restaurantDataList: RestaurantListData | null; | ||
loading: boolean; | ||
} | ||
|
||
function RestaurantCardList({ restaurantDataList, loading }: RestaurantCardListProps) { | ||
if (!restaurantDataList || loading) return <RestaurantCardListSkeleton />; | ||
|
||
const { content, totalElementsCount } = restaurantDataList; | ||
|
||
return ( | ||
<div> | ||
<StyledCardListHeader>음식점 수 {totalElementsCount} 개</StyledCardListHeader> | ||
<StyledRestaurantCardList> | ||
{content?.map(({ celebs, ...restaurant }: RestaurantData) => ( | ||
<RestaurantCard restaurant={restaurant} celebs={celebs} size={42} onClick={() => {}} /> | ||
))} | ||
</StyledRestaurantCardList> | ||
</div> | ||
); | ||
} | ||
|
||
export default RestaurantCardList; | ||
|
||
const StyledCardListHeader = styled.p` | ||
margin: 3.2rem 2.4rem; | ||
font-size: ${FONT_SIZE.md}; | ||
`; | ||
|
||
const StyledRestaurantCardList = styled.div` | ||
display: grid; | ||
gap: 4rem 2.4rem; | ||
height: 100%; | ||
margin: 0 2.4rem; | ||
grid-template-columns: 1fr 1fr 1fr; | ||
@media screen and (width <= 1240px) { | ||
grid-template-columns: 1fr 1fr; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import RestaurantCardList from './RestaurantCardList'; | ||
|
||
export default RestaurantCardList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters