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] Flex 컴포넌트, 스토리북 #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

keemsebin
Copy link
Contributor

@keemsebin keemsebin commented Jan 31, 2025

🔥 연관 이슈

🚀 작업 내용

  • Flex 컴포넌트, 스토리북 개발 진행했습니다.

Feb-01-2025 02-15-07

🤔 고민했던 내용

  • gap, width, heightProps에 포함시킬까 하다가 tailwind에서 사용하는 style 체계가 다음 사진과 같고 동적 지원이 어려워서 일부 값은 className을 통해 적용해야 할 것 같습니다.
image
  • Props 키 값으로 alignItemsitems 중 고민했는만, 사용 할 경우 더 짧게 더 낫지 않을까 싶어서 items를 선택했습니다. 다만, 직관성이 다소 떨어질 수 있어 어떤 방향이 더 좋을지 의견 주시면 감사하겠습니다!

Summary by CodeRabbit

  • 새로운 기능

    • 유연한 레이아웃 컨테이너인 Flex 컴포넌트 추가
    • Flexbox 속성을 쉽게 조정할 수 있는 컴포넌트 구현
  • 문서화

    • Storybook에 Flex 컴포넌트 문서 및 기본 스토리 추가
    • 컴포넌트 사용 예시와 속성 설명 제공
  • 개선 사항

    • 방향, 정렬, 래핑 등 다양한 레이아웃 옵션 지원
    • TypeScript 타입 안전성 강화
  • 수출 추가

    • Flex 컴포넌트를 중앙 위치에서 접근 가능하도록 수출 추가

Copy link

coderabbitai bot commented Jan 31, 2025

워크스루

이 풀 리퀘스트는 Flex 컴포넌트와 해당 Storybook 구성을 추가합니다. src/shared/ui/Flex 디렉토리에 새로운 파일들이 생성되었으며, Flex 컴포넌트는 다양한 flexbox 레이아웃 옵션을 제공합니다. Storybook 스토리는 컴포넌트의 기본 사용법과 구성을 보여줍니다.

변경 사항

파일 변경 요약
src/shared/ui/Flex/Flex.tsx Flex 컴포넌트 구현, 다양한 레이아웃 prop 추가
src/shared/ui/Flex/Flex.stories.tsx Flex 컴포넌트를 위한 Storybook 설정 및 기본 스토리 추가
src/shared/ui/Flex/index.ts Flex 컴포넌트 내보내기

연결된 이슈 평가

목표 해결 여부 설명
Flex 컴포넌트
Flex 스토리북

관련 가능성 있는 PR

제안된 라벨

feat

제안된 리뷰어

  • yougyung
  • ujinsim

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eb441b and ee152d1.

📒 Files selected for processing (1)
  • src/shared/ui/Flex/Flex.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/shared/ui/Flex/Flex.tsx

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.

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

github-actions bot commented Jan 31, 2025

Update: 2025년 02월 01일 02시 39분 12초
Storybook 미리보기: https://677a9a76c58a295e9421d3ef-omfpxbuplk.chromatic.com/

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 (4)
src/shared/ui/Flex/Flex.stories.tsx (2)

11-14: 컴포넌트 설명을 더 자세히 보완해주세요.

현재 설명은 기본적인 내용만 포함하고 있습니다. 사용 사례나 주의사항 등을 추가하면 더 유용할 것 같습니다.

예시:

- 'Flex 컴포넌트는 display: flex를 적용해 정렬과 배치를 간편하게 조정할 수 있는 컨테이너입니다.',
+ 'Flex 컴포넌트는 display: flex를 적용해 정렬과 배치를 간편하게 조정할 수 있는 컨테이너입니다. dir, items, justify, wrap 속성을 통해 자식 요소들의 배치를 제어할 수 있으며, className을 통해 추가적인 스타일링이 가능합니다. 반응형 레이아웃 구성에 특히 유용합니다.'

57-63: Basic 스토리의 예제를 더 다양하게 보완해주세요.

현재 예제는 기본적인 사용법만 보여주고 있습니다. 다양한 속성 조합의 예시를 추가하면 컴포넌트의 활용도를 더 잘 이해할 수 있을 것 같습니다.

예시:

  render: (args) => (
-    <Flex {...args} className="w-full">
-      <div className="size-10 bg-red-300">1</div>
-      <div className="size-10 bg-green-300">2</div>
-      <div className="size-10 bg-primary-300">3</div>
-    </Flex>
+    <div className="space-y-4">
+      <Flex {...args} className="w-full gap-2">
+        <div className="size-10 bg-red-300">1</div>
+        <div className="size-10 bg-green-300">2</div>
+        <div className="size-10 bg-primary-300">3</div>
+      </Flex>
+      <Flex {...args} className="w-full h-32 border-2 border-dashed border-gray-300">
+        <div className="p-4 bg-blue-300">반응형</div>
+        <div className="p-4 bg-yellow-300">레이아웃</div>
+      </Flex>
+    </div>
+  ),
src/shared/ui/Flex/Flex.tsx (2)

36-66: gap 속성 지원을 고려해보세요.

현재 gap은 className을 통해 적용해야 하지만, 자주 사용되는 속성이므로 전용 prop으로 제공하면 사용성이 개선될 것 같습니다.

예시:

type Props = {
+ /**
+  * Defines the gap between flex items.
+  * @default 0
+  */
+ gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16;
  // ... 기존 props
};

78-88: 접근성을 위한 role 속성 추가를 고려해보세요.

시맨틱한 의미를 부여하기 위해 role 속성을 추가하면 좋을 것 같습니다.

예시:

  <div
    className={cn(
      'flex',
      DIR[dir],
      ALIGN_ITEMS[items],
      JUSTIFY_CONTENT[justify],
      WRAP[wrap],
      className
    )}
+   role="group"
    {...props}
  >
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9903e02 and 0eb441b.

📒 Files selected for processing (3)
  • src/shared/ui/Flex/Flex.stories.tsx (1 hunks)
  • src/shared/ui/Flex/Flex.tsx (1 hunks)
  • src/shared/ui/Flex/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/shared/ui/Flex/index.ts

Comment on lines +68 to +76
export function Flex({
dir = 'row',
items = 'stretch',
justify = 'start',
wrap = 'nowrap',
className = '',
children,
...props
}: Props) {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

...props의 타입 안전성을 개선해주세요.

현재 ...props의 타입이 명시되어 있지 않아 의도하지 않은 속성이 전달될 수 있습니다.

예시:

- ...props
+ ...props
}: Props & Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props>) {
📝 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
export function Flex({
dir = 'row',
items = 'stretch',
justify = 'start',
wrap = 'nowrap',
className = '',
children,
...props
}: Props) {
export function Flex({
dir = 'row',
items = 'stretch',
justify = 'start',
wrap = 'nowrap',
className = '',
children,
...props
}: Props & Omit<React.HTMLAttributes<HTMLDivElement>, keyof Props>) {

@keemsebin keemsebin added the feat label Jan 31, 2025
Copy link
Collaborator

@yougyung yougyung left a comment

Choose a reason for hiding this comment

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

수고많으셨어요 👍

Props 키 값으로 alignItems와 items 중 고민했는만, 사용 할 경우 더 짧게 더 낫지 않을까 싶어서 items를 선택했습니다. 다만, 직관성이 다소 떨어질 수 있어 어떤 방향이 더 좋을지 의견 주시면 감사하겠습니다!

items로도 유추에 어려움이 없을 것으로 예상해요. 선택해주신 방향대로 진행해도 좋습니다 ☺️

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.

[FEAT] Flex 컴포넌트, 스토리북
2 participants