-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#301 best piickle API #304
Changes from 11 commits
74b6483
8b68ef5
b94643f
f4d7b30
341f58d
937f53b
45fe4c3
525b95c
2fafd03
6c38b76
0cf4e16
707ccc0
479d924
7a3a137
edc8fb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
|
||
import * as St from "./styled"; | ||
|
||
export default function LastBestPiickleCard() { | ||
return ( | ||
<St.LastCard> | ||
<St.LastCardContent> | ||
나머지 주제들도 | ||
<br /> | ||
보고 싶다면? | ||
</St.LastCardContent> | ||
<St.LastCardWrapper>나머지 보기</St.LastCardWrapper> | ||
</St.LastCard> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import styled from "styled-components"; | ||
|
||
export const LastCard = styled.div` | ||
position: relative; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
|
||
width: 18rem; | ||
height: 10.6rem; | ||
|
||
border-radius: 0.4rem; | ||
|
||
padding: 0.8rem 1.2rem; | ||
padding-top: 2.1rem; | ||
background: ${({ theme }) => theme.newColors.white}; | ||
`; | ||
|
||
export const LastCardWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
margin-top: 1.2rem; | ||
align-self: flex-end; | ||
|
||
width: 6.9rem; | ||
height: 2.5rem; | ||
|
||
border-radius: 2.9rem; | ||
background: ${({ theme }) => theme.newColors.green}; | ||
|
||
color: ${({ theme }) => theme.newColors.white}; | ||
${({ theme }) => theme.newFonts.btn2} | ||
`; | ||
|
||
export const LastCardContent = styled.p` | ||
margin-top: 0.4rem; | ||
|
||
text-align: left; | ||
|
||
white-space: normal; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 2; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
|
||
${({ theme }) => theme.newFonts.btn1} | ||
color: ${({ theme }) => theme.newColors.gray900}; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { LocationType } from "../../../types/cardCollection"; | ||
import { GTM_CLASS_NAME } from "../../../util/const/gtm"; | ||
import useNavigateCardCollection, { NavigateCardCollectionBestType } from "../hooks/useNavigateCardCollection"; | ||
import useNavigateCardCollection, { NavigateRecentCollectionType } from "../hooks/useNavigateCardCollection"; | ||
import LastBestPiickleCard from "./LastBestPiickleCard"; | ||
import * as St from "./style"; | ||
|
||
interface BestPiickleCardProps { | ||
|
@@ -12,23 +13,24 @@ interface BestPiickleCardProps { | |
idx: number; | ||
canNavigate: boolean; | ||
isLast?: boolean; | ||
locationType: LocationType; | ||
} | ||
|
||
export default function BestPiickleCard(props: BestPiickleCardProps) { | ||
const { bestPiickle, idx, canNavigate, isLast } = props; | ||
const { bestPiickle, idx, canNavigate, isLast, locationType } = props; | ||
const { content, tags } = bestPiickle; | ||
const GTM_IDX_KEY = `mainBestPiickle${idx + 1}`; | ||
|
||
const navigateCardCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBestType; | ||
const navigateCardCollection = useNavigateCardCollection(locationType) as NavigateRecentCollectionType; | ||
|
||
const onClickCard = () => { | ||
const handleClickCard = () => { | ||
if (!canNavigate) return; | ||
navigateCardCollection(idx); | ||
}; | ||
|
||
return ( | ||
<St.Container type="button" className={GTM_CLASS_NAME[GTM_IDX_KEY]} onClick={onClickCard}> | ||
{isLast ? ( | ||
<St.Container type="button" className={GTM_CLASS_NAME[GTM_IDX_KEY]} onClick={handleClickCard}> | ||
{!isLast ? ( | ||
<St.BestPiickleCard className={GTM_CLASS_NAME[GTM_IDX_KEY]}> | ||
<St.TagsWrapper className={GTM_CLASS_NAME[GTM_IDX_KEY]}> | ||
{tags.map((tag: string, i: number) => { | ||
|
@@ -39,14 +41,7 @@ export default function BestPiickleCard(props: BestPiickleCardProps) { | |
<St.PickButtonWrapper className={GTM_CLASS_NAME[GTM_IDX_KEY]}>카드 보기</St.PickButtonWrapper> | ||
</St.BestPiickleCard> | ||
) : ( | ||
<St.LastCard> | ||
<St.Content> | ||
나머지 주제들도 | ||
<br /> | ||
보고 싶다면? | ||
</St.Content> | ||
<St.LastCardButton>나머지 보기</St.LastCardButton> | ||
</St.LastCard> | ||
<LastBestPiickleCard /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 따로 컴포넌트로 빼니까 더 깔끔하네요!-! 구웃 |
||
)} | ||
</St.Container> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import { LocationType } from "../../../types/cardCollection"; | ||
import { HeadingTitle } from "../../../util/main/headingTitles"; | ||
import HeadingTitleContainer from "../../@common/HeadingTitleContainer"; | ||
import useModal from "../../@common/hooks/useModal"; | ||
import useNavigateCardCollection, { | ||
NavigateCardCollectionBookMarkType, | ||
} from "../../@common/hooks/useNavigateCardCollection"; | ||
import LoginModal from "../../@common/LoginModal"; | ||
import { useBestPiickle } from "../../MainPage/hooks/useBestPiickle"; | ||
import RankItem from "./RankItem"; | ||
import * as St from "./style"; | ||
|
||
|
@@ -9,21 +16,30 @@ const rankTitles: HeadingTitle = { | |
}; | ||
|
||
export default function BestPiickleRank() { | ||
const { bestPiickle } = useBestPiickle(); | ||
const { isModalOpen: isLoginModalOpen, toggleModal: toggleLoginModal } = useModal(); | ||
const navigateRankCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBookMarkType; | ||
return ( | ||
<St.RankContainer> | ||
{/* todo : rankitem id 수정*/} | ||
<HeadingTitleContainer headingTitles={rankTitles} paddingVerticalValue={1.6} /> | ||
<RankItem cardId="1" content="상대방의첫인상을기억하나요저는몰라요그냥해그냥해그냥해" rank={1} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={2} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={3} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={4} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={5} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={6} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={7} /> | ||
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={8} /> | ||
{bestPiickle && | ||
[...bestPiickle.data] | ||
.slice(0, 8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋은 의견이에요! 다른 브랜치에서 반영해보겠습니다:) |
||
.map(({ _id, content, isBookmark }, idx) => ( | ||
<RankItem | ||
key={_id} | ||
cardId={_id} | ||
content={content} | ||
rank={idx} | ||
isBookmark={isBookmark} | ||
openLoginModalHandler={toggleLoginModal} | ||
/> | ||
))} | ||
<St.ButtonWrapper> | ||
<St.ContinueButton>이어서 베스트 피클 카드 보기</St.ContinueButton> | ||
<St.ContinueButton onClick={() => navigateRankCollection(8)}>이어서 베스트 피클 카드 보기</St.ContinueButton> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 왜 8인지 몰라서 기능명세서 보고 왔쟈나~ 똑순이!👑👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 나도 처음에 이해안돼서 승헌오빠한테 물어봤어 ㅎㅎ |
||
</St.ButtonWrapper> | ||
|
||
{isLoginModalOpen && <LoginModal closeHandler={toggleLoginModal} contents={"북마크 기능인 마이피클을"} />} | ||
</St.RankContainer> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
import BestPiickleCard from "../../../@common/BestPiickleCard"; | ||
import useDraggingContainer from "../../../@common/hooks/useDraggingContainer"; | ||
import { useBestPiickle } from "../../../MainPage/hooks/useBestPiickle"; | ||
import { recommendListType } from ".."; | ||
import * as St from "./style"; | ||
|
||
interface RecommendProps { | ||
recommendType: string; | ||
recommendList: recommendListType; | ||
} | ||
|
||
export default function RecommendItem(props: RecommendProps) { | ||
const { recommendType } = props; | ||
const { bestPiickle } = useBestPiickle(); | ||
const { recommendList } = props; | ||
const { scrollableContainerProps, isDragging } = useDraggingContainer(); | ||
|
||
return ( | ||
<St.RecommemdItemContainer> | ||
<St.RecommendType>{recommendType}</St.RecommendType> | ||
<St.RecommendType>{recommendList.subtitle}</St.RecommendType> | ||
|
||
{bestPiickle && ( | ||
{recommendList.cards && ( | ||
<St.SliderWrapper {...scrollableContainerProps}> | ||
{bestPiickle && | ||
bestPiickle.data.slice(0, 4).map((bestPiickle, idx) => { | ||
return ( | ||
<BestPiickleCard | ||
key={bestPiickle._id} | ||
bestPiickle={bestPiickle} | ||
idx={idx} | ||
canNavigate={!isDragging} | ||
isLast={idx !== 3} | ||
/> | ||
); | ||
})} | ||
{recommendList.cards.slice(0, 4).map((cards, idx) => { | ||
return ( | ||
<BestPiickleCard | ||
key={cards._id} | ||
bestPiickle={cards} | ||
idx={idx} | ||
canNavigate={!isDragging} | ||
isLast={idx === 3} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 어떤 오류가 생겨서 바뀐건지 궁금하네요!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이거는 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 숫자 const 상수로 선언해서 사용하면 좋을 것 같아요. |
||
locationType={recommendList.locationType} | ||
/> | ||
); | ||
})} | ||
</St.SliderWrapper> | ||
)} | ||
</St.RecommemdItemContainer> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import useSWR from "swr"; | ||
|
||
import { realReq } from "../../../../core/api/common/axios"; | ||
import { PATH } from "../../../../core/api/common/constants"; | ||
import { CardList } from "../../../../types/cardCollection"; | ||
import { PiickleSWRResponse } from "../../../../types/remote/swr"; | ||
|
||
export function useCardsByGender(gender: "남" | "여") { | ||
const { data } = useSWR<PiickleSWRResponse<CardList[]>>( | ||
`${PATH.CARDS_}${PATH.CARDS_GENDER}/${gender}`, | ||
realReq.GET_SWR, | ||
{ | ||
suspense: true, | ||
}, | ||
); | ||
|
||
return { | ||
genderBookmarkedCards: data?.data.data, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import useSWR from "swr"; | ||
|
||
import { realReq } from "../../../../core/api/common/axios"; | ||
import { PATH } from "../../../../core/api/common/constants"; | ||
import { RecentCardList } from "../../../../types/cardCollection"; | ||
import { PiickleSWRResponse } from "../../../../types/remote/swr"; | ||
|
||
export function useRecentlyBookmarked() { | ||
const { data } = useSWR<PiickleSWRResponse<RecentCardList>>(`${PATH.CARDS_}${PATH.CARDS_RECENT}`, realReq.GET_SWR, { | ||
suspense: true, | ||
}); | ||
|
||
return { | ||
recentlyBookmarkedCards: data?.data.data.cardResponseDtos, | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding: 2.9rem 1.2rem 0.8rem
으로 합치면 되겠다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하 감사해요!