Skip to content
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

[FE] feat: 캐러셀 구현한 후, 홈 페이지에 적용 #421

Merged
merged 34 commits into from
Aug 19, 2024

Conversation

soosoo22
Copy link
Contributor


🚀 어떤 기능을 구현했나요 ?

  • Carousel 컴포넌트를 구현한 후, 홈 페이지에 적용했습니다.

🔥 어떻게 해결했나요 ?

  • 일단 리뷰 작성 페이지 캐러셀을 활용할려고 했으나 자칫 잘못 건드리면 돌이킬 수 없는 강을 건널 것 같아서😅 캐러셀 컴포넌트를 만들었습니다. 지금은 공통 컴포넌트를 생각하지 않고 만들었으나 추후에 공통 컴포넌트로 리팩하겠습니다.

Carousel 컴포넌트의 pageWidth, pageHeight, gap, offset 속성값을 rem 단위로 전달하고 있습니다.

   <Carousel slides={OVERVIEW_SLIDES} pageWidth={32} pageHeight={40} gap={5} offset={3.6} />

곱하기 10을 한 이유

handleScroll에서 페이지 계산할 때, pageWidthgaprem 단위니까 px 단위로 변환하기 위해 * 10을 했습니다. scrollLeft는 기본적으로 px 단위로 계산을 해줘서, * 10을 안하면 이상한 값이 뜨더라구요.

const Carousel = ({ slides, pageWidth, pageHeight, gap, offset }: CarouselProps) => {
  const [page, setPage] = useState(0);
  const scrollRef = useRef<HTMLDivElement>(null);

  const handleScroll = () => {
    if (scrollRef.current) {
      const scrollLeft = scrollRef.current.scrollLeft;
      const newPage = Math.round(scrollLeft / ((pageWidth + gap) * 10));
      setPage(newPage);
    }
  };

  const scrollToPage = (pageIndex: number) => {
    if (scrollRef.current) {
      scrollRef.current.scrollTo({
        left: (pageWidth + gap) * 10 * pageIndex,
        behavior: 'smooth',
      });
      setPage(pageIndex);
    }
  };

  return (
    // .....
  );
};

export default Carousel;
스크린샷 2024-08-19 오전 2 18 10

📝 어떤 부분에 집중해서 리뷰해야 할까요?

캐러셀 이미지가 한 화면에 하나만 보이게 할지, 아니면 위 사진처럼 일단 나열하는게 좋을지 여러분들은 어떻게 생각하시나요?
일단 카드 크기가 그리 크지 않아서 전자의 방식을 택하면 빈공간이 많아질 것 같아서 사진처럼 일단 나열해서 슬라이드형식으로 넘어가게 구현하긴 했어요.

To. 올리

캐러셀을 도입하면서 OverviewItem이 필요 없어질 것 같은데 삭제해도 괜찮을까요? 올리?
ArrowIcon 이미지도 같이 삭제할 것 같아요.

📚 참고 자료, 할 말

ImxYJL and others added 30 commits August 15, 2024 14:45
@soosoo22 soosoo22 added this to the 4차 스프린트: 최종 milestone Aug 18, 2024
@soosoo22 soosoo22 self-assigned this Aug 18, 2024
@soosoo22 soosoo22 linked an issue Aug 18, 2024 that may be closed by this pull request
1 task
Copy link
Contributor

@ImxYJL ImxYJL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캐러셀 까다로웠을텐데 만드느라 고생 많았어요~~~~

@@ -3,4 +3,5 @@ import styled from '@emotion/styled';
export const HomePage = styled.div`
display: flex;
width: 100vw;
height: calc(100vh - 7rem); // NOTE: 7rem은 Topbar 높이
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 계산식에 들어가는 변수는 따로 변수로 빼는 것도 좋을 것 같아요!

@@ -39,6 +39,7 @@ export const colors: ThemeProperty<CSSProperties['color']> = {
primary: '#7361DF',
primaryHover: '#9082E6',
lightPurple: '#E6E3F6',
palePurple: '#F5F4FF',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@BadaHertz52 BadaHertz52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쑤쑤 🚀🚀🚀🚀 고생했어

Copy link
Contributor

@chysis chysis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용성이 높은 공통 컴포넌트가 될 것 같아요! 고생했어요! 🔥

@chysis chysis merged commit de69f1f into develop Aug 19, 2024
3 checks passed
@donghoony donghoony deleted the fe/feat/397-home-page-carousel branch August 20, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FE] 홈 페이지 캐러셀을 구현한다.
4 participants