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] Spinner 컴포넌트 추가 #69

Merged
merged 4 commits into from
Jan 19, 2025
Merged

[Feat] Spinner 컴포넌트 추가 #69

merged 4 commits into from
Jan 19, 2025

Conversation

kongnayeon
Copy link
Contributor

@kongnayeon kongnayeon commented Jan 17, 2025

관련 이슈

#39

변경 사항

Spinner 컴포넌트 추가했습니다.
lottie를 활용하다 보니 사용 시 매번 dynamic import를 해야 하는 문제가 있어 추후 공통 컴포넌트들 구현이 끝나면 css로 직접 구현해 수정할 예정입니다 ^...^
다른 라이브러리들은 어떻게 동적 임포트 없이 사용하는 건가 싶었는데 다들 직접 구현을 하셨더군요 🗿
접근성을 위해 span 태그의 prop을 받을 수 있도록 했고, 수정 후에는 아래와 같은 형식으로 제공할 예정이에요!

<>
 <span aria-hidden style={{ display: 'contents', visibility: 'hidden' }} inert={undefined}>
          loading...
        </span>
<span>
  <Spinner />
</span>
</>
image

레퍼런스

Summary by CodeRabbit

  • 새로운 기능

    • 로딩 상태를 시각적으로 표현하는 스피너 컴포넌트 추가
    • 검은색과 흰색 두 가지 색상의 스피너 지원
  • 개선 사항

    • UI 라이브러리에 스피너 컴포넌트 통합
    • 동적 컴포넌트 로딩을 통한 성능 최적화

@kongnayeon kongnayeon self-assigned this Jan 17, 2025
Copy link

coderabbitai bot commented Jan 17, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/src/app/page.tsx

Oops! Something went wrong! :(

ESLint: 9.17.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@repo/eslint-config' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

워크스루

이 풀 리퀘스트는 새로운 Spinner 컴포넌트를 도입합니다. UI 라이브러리에 동적 로딩 스피너를 추가하여 사용자 인터페이스의 로딩 상태를 시각적으로 표현할 수 있게 합니다. 컴포넌트는 서버 사이드 렌더링 없이 로드되며, 검은색과 흰색 두 가지 색상 옵션을 제공합니다.

변경 사항

파일 변경 요약
apps/web/src/app/page.tsx Spinner 컴포넌트의 동적 임포트 추가, 두 개의 스피너 인스턴스(검은색, 흰색) 렌더링
packages/ui/package.json Spinner 컴포넌트에 대한 새로운 export 경로 추가
packages/ui/src/components/Spinner/Spinner.tsx 새로운 Spinner 컴포넌트 생성, 색상 커스터마이징 가능한 로딩 스피너 구현

관련 가능성 있는 PR

제안된 레이블

enhancement

제안된 리뷰어

  • minseong0324

토끼의 시

🐰 스피너가 돌아간다, 흰색과 검은색
로딩의 춤을, 부드럽게 그려내네
UI의 마법, 기다림의 예술
코드로 만드는, 사용자의 미소 🌀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ui/src/components/Spinner/Spinner.tsx (1)

26-37: 성능 최적화를 위한 제안

현재 구현은 잘 작동하지만, PR 설명에서 언급된 대로 동적 임포트 이슈가 있습니다. CSS로 구현하는 것이 더 효율적일 것 같습니다.

CSS 기반 구현으로 전환 시, 다음과 같은 이점이 있습니다:

  • 번들 크기 감소
  • 초기 로딩 성능 향상
  • 동적 임포트 제거
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2124a91 and ac5dba0.

📒 Files selected for processing (3)
  • apps/web/src/app/page.tsx (2 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/ui/src/components/Spinner/Spinner.tsx (1 hunks)
🔇 Additional comments (4)
packages/ui/src/components/Spinner/Spinner.tsx (2)

17-19: Props 타입 정의가 잘 구현되었습니다.

타입 안전성을 보장하면서도 필요한 속성만 노출하도록 잘 설계되었습니다.


21-25: JSDoc 문서화가 잘 되어있습니다.

한글로 작성된 명확한 문서화가 되어있어 컴포넌트 사용이 용이합니다.

apps/web/src/app/page.tsx (1)

23-28: 동적 임포트 구현이 적절합니다.

SSR을 비활성화하고 동적으로 임포트하는 방식이 올바르게 구현되었습니다.

packages/ui/package.json (1)

13-13: 패키지 내보내기가 올바르게 구성되었습니다.

Spinner 컴포넌트의 export 경로가 적절하게 설정되었습니다.

Comment on lines 153 to 162
<div
style={{
display: 'flex',
gap: '8px',
backgroundColor: 'grey',
}}
>
<Spinner color="black" />
<Spinner color="white" />
</div>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

스피너 표시를 위한 배경색 개선 필요

현재 배경색이 'grey'로 하드코딩되어 있습니다. 테마 시스템의 색상을 사용하는 것이 좋겠습니다.

다음과 같이 수정을 제안합니다:

-          backgroundColor: 'grey',
+          backgroundColor: 'var(--color-grey-900)',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
style={{
display: 'flex',
gap: '8px',
backgroundColor: 'grey',
}}
>
<Spinner color="black" />
<Spinner color="white" />
</div>
<div
style={{
display: 'flex',
gap: '8px',
backgroundColor: 'var(--color-grey-900)',
}}
>
<Spinner color="black" />
<Spinner color="white" />
</div>


type LottieType = keyof typeof lotties;

const SpinnerColor: Record<'black' | 'white', LottieType> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

'black' | 'white' 를 따로 관리하는게 어떨까요? 고민이 되네요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

색상이 추가될 수도 있으니 따로 빼는 게 좋겠네요!! 수정했어요!

};

export type SpinnerProps = {
color?: keyof typeof SpinnerColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

그러면 keyof typeof 까지 안해도 되지 않을까.. 근데 뭐가 더 좋은 방법일지 모르겠네요

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/ui/src/components/Spinner/Spinner.tsx (2)

12-17: 상수값을 별도의 파일로 분리하는 것을 제안드립니다.

현재 구현은 이전 리뷰 의견을 반영하여 색상 관리를 잘 분리했습니다. 더 나아가 다음과 같은 개선을 제안드립니다:

  • 상수값들을 constants.ts 파일로 분리하여 재사용성과 유지보수성을 높일 수 있습니다.
  • 추후 색상이 추가될 때 한 곳에서 관리가 가능해집니다.
+ // constants.ts
+ export const SPINNER_COLORS = {
+   black: 'loadingBlack',
+   white: 'loadingWhite',
+ } as const;
+ 
+ export type SpinnerColorType = keyof typeof SPINNER_COLORS;

19-21: 타입 정의를 단순화할 수 있습니다.

이전 리뷰 의견처럼 keyof typeof를 사용하지 않고도 타입을 정의할 수 있습니다:

- export type SpinnerProps = {
-   color?: keyof typeof SpinnerColor;
- } & Omit<LottieAnimationProps, 'animationData'>;
+ export type SpinnerProps = {
+   color?: SpinnerColorType;
+ } & Omit<LottieAnimationProps, 'animationData'>;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac5dba0 and 1d465c0.

📒 Files selected for processing (2)
  • apps/web/src/app/page.tsx (2 hunks)
  • packages/ui/src/components/Spinner/Spinner.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/app/page.tsx
🔇 Additional comments (1)
packages/ui/src/components/Spinner/Spinner.tsx (1)

1-8: 코드가 깔끔하고 필요한 import만 포함되어 있습니다!

클라이언트 사이드 렌더링을 위한 'use client' 지시문과 필요한 import문이 잘 구성되어 있습니다.

Copy link
Contributor

@minseong0324 minseong0324 left a comment

Choose a reason for hiding this comment

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

수정사항 확인했어요~! 고생하셨어요

@kongnayeon kongnayeon merged commit 17dee67 into develop Jan 19, 2025
3 of 4 checks passed
@kongnayeon kongnayeon deleted the feat/#895c11ba2 branch January 19, 2025 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants