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

feat: Loading 컴포넌트 구현 #89

Merged
merged 9 commits into from
Jan 7, 2024
Merged

feat: Loading 컴포넌트 구현 #89

merged 9 commits into from
Jan 7, 2024

Conversation

newminkyung
Copy link
Member

@newminkyung newminkyung commented Jan 3, 2024

🤔 해결하려는 문제가 무엇인가요?

  • lottie를 사용해서 로딩 컴포넌트를 구현했어요

🎉 어떻게 해결했나요?

1. Lottie 컴포넌트 구현

Lottie 컴포넌트 스토리북

  • lottie-web 설치
  • 스토리북 설정에 staticDir에 public을 추가했어요
    • public/[...path] -> /[...path] 앞에 public 경로 생략하고 사용하면 됩니다

2. Loading 컴포넌트 구현

Loading 컴포넌트 스토리북

  • Lottie에 bandiboodi-loading.json을 넣은 Loading 컴포넌트를 구현했어요

📚 Attachment (Option)

  • 페이지 로딩 처리하는 PR은 따로 분리해서 올리도록 하겠습니다!

@newminkyung newminkyung self-assigned this Jan 3, 2024
@depromeet depromeet deleted a comment from vercel bot Jan 3, 2024
@depromeet depromeet deleted a comment from github-actions bot Jan 3, 2024
Copy link

vercel bot commented Jan 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
amazing3-fe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2024 5:04am

Copy link

github-actions bot commented Jan 3, 2024

@deepbig
Copy link
Collaborator

deepbig commented Jan 4, 2024

@minkyung00 요거 아직 Draft인가요~? 설명은 이미 완료된 것 같아서 질문드립니다~~

@newminkyung newminkyung marked this pull request as ready for review January 4, 2024 02:30
Copy link
Collaborator

@hjy0951 hjy0951 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 민경님!!
json 사용한 방식은 처음 보는데 신기하네용
많이 배워갑니다~! 🙇‍♂️🙇‍♂️🙇‍♂️

Comment on lines +16 to +41
export const Lottie = ({ src, loop = true, autoplay = true, ...props }: LottieProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const animationRef = useRef<AnimationItem>();

useEffect(() => {
if (!containerRef.current) return;

animationRef.current = lottie.loadAnimation({
container: containerRef.current,
loop,
autoplay,
renderer: 'svg',
path: src,
rendererSettings: {
progressiveLoad: true,
hideOnTransparent: true,
},
});

return () => {
animationRef.current?.destroy();
};
}, [autoplay, loop, src]);

return <div ref={containerRef} {...props} />;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

질문이 있습니다!
animationRef를 사용하신 의도가 궁금해요!!

useEffect return시, lottie.detroy()를 사용하면 animationRef를 사용하지 않을 수 있지 않나해서요!

Copy link
Member Author

Choose a reason for hiding this comment

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

lottie.destroy()를 사용하면 모든 Lottie 애니메이션이 destroy 됩니다!

여러 애니메이션이 동시에 존재하면 모든 애니메이션이 destory 되기 때문에
ref.current에 각 애니메이션 객체를 담아서 각각 관리하도록 하였습니다~

Copy link
Member

@Doeunnkimm Doeunnkimm 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
Collaborator

@deepbig deepbig left a comment

Choose a reason for hiding this comment

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

우와ㅏㅏㅏㅏ 충분히 빠르네요~! 굿굿굿굿 감사드립니다~~!!! 👍 💯 👍 💯 👍 💯 👍 💯
image

@@ -0,0 +1,41 @@
'use client';
Copy link
Collaborator

Choose a reason for hiding this comment

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

요기에 use client는 불필요하지 않을까요~~?? atom을 호출하는 feature 또는 상위 함수에서 이미 적용되어 있을 것 같아서요~~

Comment on lines 8 to 10
interface AnimationConfigProps extends Omit<AnimationConfig, 'container'> {
container?: AnimationConfig['container'];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

AnimationConfig에서 container를 optional로 받는 이유가 있을까요?

animationRef에서 container를 직접 입력하고 있는데 props으로 container 값을 전달 받으면 의도하지 않은 container가 사용되거나 충돌이 발생하지는 않나요?

잘 몰라서 질문드립니다~~! 구글 검색으로는 해당 방식으로 사용하는 케이스를 찾을 수 없어서요👀

Copy link
Member Author

Choose a reason for hiding this comment

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

생각해보니 container를 받을 필요가 없네요! 감사합니다~👍

Copy link

github-actions bot commented Jan 7, 2024

@newminkyung newminkyung merged commit 401c49e into main Jan 7, 2024
4 checks passed
@newminkyung newminkyung deleted the feat/loading-lottie branch January 7, 2024 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants