-
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/#300 best piickle #301
Changes from 1 commit
2faa5b7
f198e16
d3ec52d
d9025a0
a01fedb
0738f0b
fd99cb4
ecb3ec1
2d12afa
b283cfe
5b41210
4431323
5d57e82
3766a60
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,53 @@ | ||
import { LocationType } from "../../../types/cardCollection"; | ||
import { GTM_CLASS_NAME } from "../../../util/const/gtm"; | ||
import useNavigateCardCollection, { NavigateCardCollectionBestType } from "../hooks/useNavigateCardCollection"; | ||
import * as St from "./style"; | ||
|
||
interface BestPiickleCardProps { | ||
bestPiickle: { | ||
_id: string; | ||
tags: string[]; | ||
content: string; | ||
}; | ||
idx: number; | ||
canNavigate: boolean; | ||
isLast?: boolean; | ||
} | ||
|
||
export default function BestPiickleCard(props: BestPiickleCardProps) { | ||
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 { bestPiickle, idx, canNavigate, isLast } = props; | ||
const { content, tags } = bestPiickle; | ||
const GTM_IDX_KEY = `mainBestPiickle${idx + 1}`; | ||
|
||
const navigateCardCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBestType; | ||
|
||
const onClickCard = () => { | ||
if (!canNavigate) return; | ||
navigateCardCollection(idx); | ||
}; | ||
Comment on lines
+24
to
+27
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.
|
||
|
||
return ( | ||
<St.Container type="button" className={GTM_CLASS_NAME[GTM_IDX_KEY]} onClick={onClickCard}> | ||
{isLast ? ( | ||
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.
|
||
<St.BestPiickleCard className={GTM_CLASS_NAME[GTM_IDX_KEY]}> | ||
<St.TagsWrapper className={GTM_CLASS_NAME[GTM_IDX_KEY]}> | ||
{tags.map((tag: string, i: number) => { | ||
return <St.Tag key={i}>{tag.slice(1)}</St.Tag>; | ||
})} | ||
</St.TagsWrapper> | ||
<St.Content className={GTM_CLASS_NAME[GTM_IDX_KEY]}>{content}</St.Content> | ||
<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> | ||
)} | ||
</St.Container> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import styled from "styled-components"; | ||
|
||
export const Container = styled.button``; | ||
|
||
export const BestPiickleCard = styled.div` | ||
position: relative; | ||
|
||
width: 18rem; | ||
height: 10.6rem; | ||
|
||
padding: 0.8rem 1.2rem; | ||
|
||
border-radius: 0.4rem; | ||
background: ${({ theme }) => theme.newColors.lightgreen2}; | ||
`; | ||
|
||
export const TagsWrapper = styled.ul` | ||
display: flex; | ||
gap: 0.8rem; | ||
`; | ||
|
||
export const Tag = styled.li` | ||
${({ theme }) => theme.newFonts.caption1}; | ||
color: ${({ theme }) => theme.newColors.green}; | ||
`; | ||
|
||
export const Content = 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}; | ||
`; | ||
|
||
export const PickButtonWrapper = styled.div` | ||
margin-top: 1.2rem; | ||
|
||
${({ theme }) => theme.newFonts.btn2}; | ||
color: ${({ theme }) => theme.newColors.gray700}; | ||
|
||
text-align: right; | ||
`; | ||
|
||
export const LastCard = styled(BestPiickleCard)` | ||
display: flex; | ||
flex-direction: column; | ||
|
||
padding-top: 2.1rem; | ||
background: ${({ theme }) => theme.newColors.white}; | ||
`; | ||
|
||
export const LastCardButton = styled.button` | ||
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} | ||
`; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { routePaths } from "../../../core/routes/path"; | ||
import { headingTitles } from "../../../util/main/headingTitles"; | ||
import BestPiickleCard from "../../@common/BestPiickleCard"; | ||
import HeadingTitleContainer from "../../@common/HeadingTitleContainer"; | ||
import useDraggingContainer from "../../@common/hooks/useDraggingContainer"; | ||
import { useBestPiickle } from "../hooks/useBestPiickle"; | ||
import BestPiickleCard from "./BestPiickleCard"; | ||
import St from "./style"; | ||
|
||
export default function BestPiickle() { | ||
|
@@ -23,7 +23,13 @@ export default function BestPiickle() { | |
{bestPiickle && | ||
bestPiickle.data.slice(0, 5).map((bestPiickle, idx) => { | ||
return ( | ||
<BestPiickleCard key={bestPiickle._id} bestPiickle={bestPiickle} idx={idx} canNavigate={!isDragging} /> | ||
<BestPiickleCard | ||
key={bestPiickle._id} | ||
bestPiickle={bestPiickle} | ||
idx={idx} | ||
canNavigate={!isDragging} | ||
isLast={idx !== 5} | ||
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. slice(0, 5) 면 idx가 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.SliderWrapper> | ||
|
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.
(생각해보면 좋을 것 같아요)
last card에 대한 내용을 컴포넌트로 분리해서
LastBestPiickleCard
로 하지 않고,컴포넌트 내에서 last card에 대한 내용을 하는 것이 옳은 인터페이스일까요?
장단점이 뭘까요???
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.
해놓고 리팩토링한다는 걸 깜빡했네요😅
단점은 아무래도 파일이 많아지면서 번들 크기가 증가한다는 것일거고, 경우에 따라 props drilling문제도 생길 것 같아요!
그런데 지금 LastCard는 필요로하는 props가 없으니까 말씀하신대로 컴포넌트를 분리하는 게 좋을 것 같아요:)