-
Notifications
You must be signed in to change notification settings - Fork 7
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
[SP2] Carousel 컴포넌트를 만들고 Project Page에서 최근 출시된 프로젝트 목록에 적용 #235
Conversation
@@ -1,11 +1,16 @@ | |||
import styled from '@emotion/styled'; | |||
import { CSSProperties, PropsWithChildren } from 'react'; | |||
import { SerializedStyles } from '@emotion/react'; |
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.
((지금 피쳐랑 큰 관련은 없는 부분입니다))
레이아웃에 moreStyle이라는 프로퍼티를 주었는데, CSSProperties로 들어가면 매번 객체로 들어가는 것이라 좋아 보이지 않아서 css`` 로 넣을 수 있도록 바꿨습니다!!
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.
객체가 매번 새롭게 생성되다 보니 성능상으로 좋지 않아 바꾸신 걸로 이해하면 될까요?
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.
emotion css props 대한 아티클인데 같이 읽어보면 좋을 것 같아요!
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.
객체가 매번 새롭게 생성되다 보니 성능상으로 좋지 않아 바꾸신 걸로 이해하면 될까요?
맞습니다!! 그런데 우영언니가 준 글을 읽어보니 이것 또한 그렇게 좋지는 않은 방법이네요 ..!!
emotion css props 대한 아티클인데 같이 읽어보면 좋을 것 같아요!
음 css 프롭을 styled component로 넘기지 말고 바로 css로 넘기는 방식으로 일단은 개선하겠습니다!!
import { S } from './style'; | ||
|
||
interface CarouselProps { | ||
itemWidth: number; |
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.
프롭 이름 | 하는 일 | 비고 |
---|---|---|
itemWidth | 아이템 너비 | |
stride | 보폭 - 한 번에 넘어가는 페이지 수 | |
leftArrowType | 왼쪽 Arrow의 타입 | 현재는 보여준다 / 안 보여준다 밖에 없지만 나중에 확장 가능! |
rightArrowType | 오른쪽 Arrow의 타입 | 위와 같다 |
overflowType | 넘치는 부분을 어떻게 보여줄 것인가? | 현재는 blur / show 둘 뿐 |
children | React Children |
const [startX, setStartX] = useState(0); | ||
const wrapperRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { |
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.
stride가 달라지면 전체 페이지 수가 달라지므로, 현재 페이지를 0으로 초기화합니다
}; | ||
|
||
const translateX = -currentIndex * itemWidth; | ||
console.log(Array(children.length / stride)); |
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.
머하냐.. 당장 지우겠습니다
|
||
type DeviceType = 'desktop' | 'iOS' | 'Android'; | ||
|
||
export function useDeviceType() { |
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.
접속한 장치 판단하는 훅입니다!
하나 만들어 두었어요~
<PageLayout | ||
showScrollTopButton | ||
moreStyle={css` | ||
overflow-x: hidden; |
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.
캐러셀이 가로로 길어서 overflow-x가 생겨 일단 숨겼습니다!!
import { useDeviceType, useIsDesktop, useIsTablet } from '@src/hooks/useDevice'; | ||
import { CarouselArrowType, CarouselOverflowType } from '@src/lib/types/universal'; | ||
|
||
function RecentProjectListCarousel({ children }: { children: JSX.Element[] }) { |
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.
프로젝트 리스트에 쓰이는 캐러셀의 프롭을 조건에 따라 넘겨주기만 하는 컴포넌트입니다
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.
@@ -1,11 +1,16 @@ | |||
import styled from '@emotion/styled'; | |||
import { CSSProperties, PropsWithChildren } from 'react'; | |||
import { SerializedStyles } from '@emotion/react'; |
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.
객체가 매번 새롭게 생성되다 보니 성능상으로 좋지 않아 바꾸신 걸로 이해하면 될까요?
children: JSX.Element[]; | ||
} | ||
|
||
const Carousel: React.FC<CarouselProps> = ({ |
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.
export default function 컴포넌트명
이 저희 컨벤션입니다! FC를 사용하신 이유가 있을까요?
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.
저의 습관성 rsc 때문에 ...........
고쳐오겠습니다!
const Wrapper = styled(HideScrollbar)` | ||
width: 100%; | ||
position: relative; | ||
`; |
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.
프로젝트 탭에서 스크롤바를 숨기는 이유가 뭔가요? 궁금합니다!
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.
요건 프로젝트 목록이 담겨 있는 캐러셀이라서, overflow-x가 생기게 됩니다! 그럼 가로 방향 스크롤바가 생기게 되는데요..!
디자인 의도는 그것이 아닐 것 같아서 스크롤바를 숨겼어요!!
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.
캐러셀의 스크롤 뿐만이 아니라 페이지의 스크롤까지 같이 없어지는 거 같은데 맞나요..?!
...가 아니군요.. 저희 원래 스크롤이 없는 것 같네요.....? 공홈 초기부터 이렇게 했던 거 같은데 의도된 디자인인가요?
import RecentProjectListCarousel from './Carousel'; | ||
import RecentProjectListItem from './Item'; | ||
|
||
function RecentProjectList() { |
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.
export default를 앞에 붙이는 게 컨벤션인데 이 부분 말고도 거의 모든 컴포넌트에서 안지켜지고 있는 것 같습니다!
사실 저도 스니펫을 쓰는데 export default를 하단에서 해주다 보니 자꾸 깜빡하는 것 같습니다..
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.
그것은 다 고쳐오겠습니다 ㅜㅜㅜ 습관성 rsf 이후 고치질 않았네요..
const deltaX = startX - endX; | ||
|
||
if (deltaX > 50) { | ||
handleNext(); | ||
} else if (deltaX < -50) { | ||
handlePrev(); | ||
} |
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.
혹시 여기 deltaX
와 50
은 어떤 의미인지 설명해주실 수 있나요?
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.
너무 조금 터치하면 넘기지 않으려고 추가한 값들입니다!
deltaX : 터치를 시작한 지점과 끝낸 지점의 x값 차이
50 : 페이지 넘기는 기준이 되는 마진
50은 매직넘버니까 정리해둘게요!!
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.
꽤 복잡한 작업이었을텐데 pr에 설명을 잘 달아줘서 고마워요~
확인했습니다!!
|
||
export function Layout({ children, moreStyle }: PropsWithChildren<{ moreStyle?: CSSProperties }>) { | ||
return <Main style={moreStyle}>{children}</Main>; | ||
export function Layout({ |
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.
suggestion;
컨벤션에 맞게 export default function~
으로 적어주면 좋을 것 같아요!
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.
이것 제가 많이 어겼네요 .. 다 고치겠습니다!!
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.
이건 이번에 추가된게 아니라 저번에 추가된 것이고, 한 번 바꾸면 너무나 많은 파일을 건드리게 되네요 ..
다른 이슈에서 해야 할 것 같습니다!!
@@ -1,11 +1,16 @@ | |||
import styled from '@emotion/styled'; | |||
import { CSSProperties, PropsWithChildren } from 'react'; | |||
import { SerializedStyles } from '@emotion/react'; |
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.
emotion css props 대한 아티클인데 같이 읽어보면 좋을 것 같아요!
border-radius: 10px; | ||
|
||
/* 모바일 뷰 */ | ||
@media (max-width: 765.9px) { |
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.
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.
잘못 주워온 것 같습니다. . 꼼꼼한 확인 감사드려요!!
너무너무 꼼꼼한 리뷰 감사드려요!!
사용해보기 버튼의 경우, 유효한 링크가 있는 경우에만 띄우고 있어요..!!
이런 .. 거의 눈을 감고 개발했네요 ..... 찾아주셔서 정말 감사합니다!! |
Summary
Carousel 컴포넌트를 만들고 Project Page에서 최근 출시된 프로젝트 목록에 적용했습니다
Screenshot
2023-10-25.10.46.33.mov
Comment