-
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.
Browse files
Browse the repository at this point in the history
* feat: 내 지도 토픽 목록 list 컴포넌트 구현 및 모달 창에 적용 * fix: 내 지도 저장 모달 띄웠을 때 PinDetail 포커스 제거 * refactor: 내 지도 목록 모달 서버 요청 후 데이터 받도록 수정
- Loading branch information
Showing
6 changed files
with
227 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Fragment, useEffect, useState } from 'react'; | ||
import { styled } from 'styled-components'; | ||
import { getApi } from '../../apis/getApi'; | ||
import { ModalMyTopicType } from '../../types/Topic'; | ||
import ModalTopicCard from '../ModalTopicCard'; | ||
|
||
const ModalMyTopicList = () => { | ||
const [myTopics, setMyTopics] = useState<ModalMyTopicType[]>([]); | ||
|
||
const getMyTopicFromServer = async () => { | ||
const serverMyTopic = await getApi<ModalMyTopicType[]>( | ||
'default', | ||
'/members/my/topics', | ||
); | ||
setMyTopics(serverMyTopic); | ||
}; | ||
|
||
useEffect(() => { | ||
getMyTopicFromServer(); | ||
}, []); | ||
|
||
if (!myTopics) return <></>; | ||
|
||
return ( | ||
<ModalMyTopicListWrapper> | ||
{myTopics.map((topic) => ( | ||
<Fragment key={topic.id}> | ||
<ModalTopicCard | ||
topicId={topic.id} | ||
topicImage={topic.image} | ||
topicTitle={topic.name} | ||
topicUpdatedAt={topic.updatedAt} | ||
topicPinCount={topic.pinCount} | ||
/> | ||
</Fragment> | ||
))} | ||
</ModalMyTopicListWrapper> | ||
); | ||
}; | ||
|
||
const ModalMyTopicListWrapper = styled.ul` | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); | ||
grid-row-gap: ${({ theme }) => theme.spacing[5]}; | ||
`; | ||
|
||
export default ModalMyTopicList; |
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,115 @@ | ||
import { styled } from 'styled-components'; | ||
import Text from '../common/Text'; | ||
import useNavigator from '../../hooks/useNavigator'; | ||
import Box from '../common/Box'; | ||
import Image from '../common/Image'; | ||
import { SyntheticEvent } from 'react'; | ||
import Space from '../common/Space'; | ||
import Flex from '../common/Flex'; | ||
import SmallTopicPin from '../../assets/smallTopicPin.svg'; | ||
import SmallTopicStar from '../../assets/smallTopicStar.svg'; | ||
import { DEFAULT_TOPIC_IMAGE } from '../../constants'; | ||
|
||
const FAVORITE_COUNT = 10; | ||
|
||
export interface ModalTopicCardProps { | ||
topicId: number; | ||
topicImage: string; | ||
topicTitle: string; | ||
topicUpdatedAt: string; | ||
topicPinCount: number; | ||
} | ||
|
||
const ModalTopicCard = ({ | ||
topicId, | ||
topicImage, | ||
topicTitle, | ||
topicUpdatedAt, | ||
topicPinCount, | ||
}: ModalTopicCardProps) => { | ||
const { routePage } = useNavigator(); | ||
|
||
const goToSelectedTopic = () => { | ||
routePage(`/topics/${topicId}`, [topicId]); | ||
}; | ||
|
||
return ( | ||
<Wrapper onClick={goToSelectedTopic}> | ||
<Flex position="relative"> | ||
<TopicImage | ||
height="138px" | ||
width="138px" | ||
src={topicImage} | ||
alt="토픽 이미지" | ||
$objectFit="cover" | ||
onError={(e: SyntheticEvent<HTMLImageElement, Event>) => { | ||
e.currentTarget.src = DEFAULT_TOPIC_IMAGE; | ||
}} | ||
/> | ||
|
||
<Box width="192px" padding={1}> | ||
<Box height="52px"> | ||
<Text color="black" $fontSize="default" $fontWeight="bold"> | ||
{topicTitle} | ||
</Text> | ||
</Box> | ||
|
||
<Text color="black" $fontSize="small" $fontWeight="normal"> | ||
토픽 생성자 | ||
</Text> | ||
|
||
<Space size={0} /> | ||
|
||
<Text color="gray" $fontSize="small" $fontWeight="normal"> | ||
{topicUpdatedAt.split('T')[0].replaceAll('-', '.')} 업데이트 | ||
</Text> | ||
|
||
<Space size={0} /> | ||
|
||
<Flex> | ||
<Flex $alignItems="center" width="64px"> | ||
<SmallTopicPin /> | ||
<Space size={0} /> | ||
<Text color="black" $fontSize="extraSmall" $fontWeight="normal"> | ||
{topicPinCount > 999 ? '+999' : topicPinCount}개 | ||
</Text> | ||
</Flex> | ||
<Flex $alignItems="center" width="64px"> | ||
<SmallTopicStar /> | ||
<Space size={0} /> | ||
<Text color="black" $fontSize="extraSmall" $fontWeight="normal"> | ||
{FAVORITE_COUNT > 999 ? '+999' : FAVORITE_COUNT}명 | ||
</Text> | ||
</Flex> | ||
</Flex> | ||
</Box> | ||
</Flex> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const Wrapper = styled.li` | ||
width: 332px; | ||
height: 140px; | ||
cursor: pointer; | ||
border: 1px solid ${({ theme }) => theme.color.gray}; | ||
border-radius: ${({ theme }) => theme.radius.small}; | ||
margin: 0 auto; | ||
`; | ||
|
||
const ButtonWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
position: absolute; | ||
width: 72px; | ||
top: 100px; | ||
left: 60px; | ||
`; | ||
|
||
const TopicImage = styled(Image)` | ||
border-radius: ${({ theme }) => theme.radius.small}; | ||
`; | ||
|
||
export default ModalTopicCard; |
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
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