Skip to content

Conversation

@malangcat
Copy link
Contributor

@malangcat malangcat commented May 8, 2025

  • <Grid> 컴포넌트를 추가합니다.

Summary by CodeRabbit

  • 신규 기능

    • 새로운 Grid 컴포넌트가 추가되었습니다. 이제 다양한 그리드 레이아웃을 손쉽게 구성할 수 있습니다.
  • 문서화

    • Grid 컴포넌트 사용법 및 예시가 포함된 문서가 추가되었습니다.
    • 다양한 컬럼 설정 및 레이아웃 예제 컴포넌트가 제공됩니다.
  • 스타일

    • Grid 레이아웃을 위한 새로운 CSS 클래스(.seed-grid)가 추가되었습니다.

- Added Grid component to the React library, allowing for flexible grid layouts.
- Implemented grid properties such as columns and rows for customizable layouts.
- Created example components demonstrating grid usage with both numeric and string column definitions.
- Updated CSS to support grid display and styling.
@changeset-bot
Copy link

changeset-bot bot commented May 8, 2025

🦋 Changeset detected

Latest commit: 1e16c9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@seed-design/react Patch
@seed-design/css Patch
@seed-design/figma Patch
@seed-design/rsbuild-plugin Patch
@seed-design/stackflow Patch
@seed-design/vite-plugin Patch
@seed-design/webpack-plugin Patch
@seed-design/mcp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented May 8, 2025

Walkthrough

이번 변경 사항은 @seed-design/react@seed-design/css 패키지에 새로운 Grid 컴포넌트를 도입하고, 관련 CSS 클래스와 문서, 예제 컴포넌트를 추가합니다. Grid의 사용법과 props에 대한 문서가 추가되었으며, 다양한 레이아웃 예제도 함께 제공됩니다.

Changes

파일/경로 그룹 변경 요약
.changeset/kind-cats-attack.md Grid 컴포넌트 추가에 대한 패키지 변경 로그 추가
docs/components/example/grid-columns-number.tsx
docs/components/example/grid-columns-string.tsx
docs/components/example/grid-preview.tsx
Grid 컴포넌트 예제 React 컴포넌트 3종 추가
docs/content/react/components/(layout)/grid.mdx Grid 컴포넌트의 소개, props, 예제, 사용법을 포함한 문서 파일 추가
packages/css/all.css
packages/css/base.css
packages/css/base.min.css
packages/qvism-preset/src/global.ts
.seed-grid CSS 클래스 추가, 기본 2열 그리드 레이아웃 및 커스텀 프로퍼티 정의
packages/react/src/components/Grid/Grid.tsx Grid 컴포넌트 및 GridProps 타입 신규 구현, columns/rows prop 처리 및 ref 전달 로직 포함
packages/react/src/components/Grid/index.ts Grid 및 GridProps를 외부로 export 하도록 index 파일 추가
packages/react/src/components/index.ts Grid 컴포넌트 전체 export에 추가

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GridComponent
    participant BoxComponent
    participant CSS

    User->>GridComponent: Grid(props: columns, rows, align, justify)
    GridComponent->>BoxComponent: 렌더링 (props, ref, className="seed-grid")
    GridComponent->>CSS: --seed-grid-columns, --seed-grid-rows 커스텀 프로퍼티 적용
    BoxComponent-->>User: 그리드 레이아웃 렌더링
Loading

Poem

🐰
그리드 위에 토끼가 춤을 춰요,
두 줄, 세 줄, 자유롭게 펼쳐요.
seed-grid 클래스 깔끔하게,
예제와 문서도 새로워졌네!
React 세상에 질서가 생겼죠,
토끼도 그리드에서 한 칸 차지해요.
🟦🟦🟦🟦

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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: 2

🧹 Nitpick comments (3)
packages/css/base.css (1)

6-11: deprecated된 CSS 함수 constant() 사용 검토 필요
constant() 함수는 오래된 Safari 전용 문법으로, 최신 브라우저에서 지원 중단될 가능성이 있습니다. 이미 표준 env()를 함께 사용하고 있으므로, constant() 부분을 제거하거나 주석으로 사용 목적을 명확히 하는 방안을 고려해주세요.

🧰 Tools
🪛 Biome (1.9.4)

[error] 6-6: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 8-8: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 9-9: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)

docs/content/react/components/(layout)/grid.mdx (1)

32-41: columns prop의 string 타입 설명이 간결합니다.

문자열을 전달했을 때의 동작을 설명하고 있지만, 예시 값이나 유효한 형식에 대한 추가 설명이 있으면 더 좋을 것 같습니다.

다음과 같이 string 값의 예시를 추가하는 것을 고려해보세요:

- `columns` prop에 string을 전달하면 grid-template-columns가 적용됩니다.
+ `columns` prop에 string을 전달하면 grid-template-columns가 적용됩니다. (예: `"1fr 2fr 1fr"`, `"repeat(3, 200px)"`, `"auto 1fr"` 등)
packages/react/src/components/Grid/Grid.tsx (1)

46-53: CSS 변수 설정 방식에 대한 제안

현재 CSS 변수 설정 방식이 작동하지만, columns나 rows가 undefined인 경우에 대한 처리가 명시적이지 않습니다.

다음과 같이 변수에 더 명확한 기본값을 제공하는 것이 좋을 수 있습니다:

style: {
  "--seed-grid-columns":
-    typeof columns === "number" ? `repeat(${columns}, minmax(0, 1fr))` : columns,
+    typeof columns === "number" ? `repeat(${columns}, minmax(0, 1fr))` : (columns || "none"),
-  "--seed-grid-rows": rows,
+  "--seed-grid-rows": rows || "none",
} as React.CSSProperties,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d936b24 and 1e16c9d.

📒 Files selected for processing (12)
  • .changeset/kind-cats-attack.md (1 hunks)
  • docs/components/example/grid-columns-number.tsx (1 hunks)
  • docs/components/example/grid-columns-string.tsx (1 hunks)
  • docs/components/example/grid-preview.tsx (1 hunks)
  • docs/content/react/components/(layout)/grid.mdx (1 hunks)
  • packages/css/all.css (1 hunks)
  • packages/css/base.css (1 hunks)
  • packages/css/base.min.css (1 hunks)
  • packages/qvism-preset/src/global.ts (1 hunks)
  • packages/react/src/components/Grid/Grid.tsx (1 hunks)
  • packages/react/src/components/Grid/index.ts (1 hunks)
  • packages/react/src/components/index.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
docs/components/example/grid-columns-string.tsx (1)
packages/react/src/components/Grid/Grid.tsx (1)
  • Grid (37-56)
docs/components/example/grid-columns-number.tsx (1)
packages/react/src/components/Grid/Grid.tsx (1)
  • Grid (37-56)
docs/components/example/grid-preview.tsx (1)
packages/react/src/components/Grid/Grid.tsx (1)
  • Grid (37-56)
🪛 Biome (1.9.4)
packages/css/base.min.css

[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (19)
packages/css/base.css (1)

149-155: .seed-grid 클래스가 유연한 그리드 컨테이너를 올바르게 설정합니다
--seed-grid-columns--seed-grid-rows CSS 변수를 활용해 기본 2열 레이아웃을 제공하며, display: grid가 적절히 적용되었습니다.

.changeset/kind-cats-attack.md (1)

1-7: 패치셋 메타 정보 및 설명이 명확합니다
설치할 패키지와 변경 목적이 간결하게 작성되었습니다.

packages/react/src/components/index.ts (1)

22-22: Grid 컴포넌트가 컴포넌트 인덱스에 정상 추가되었습니다
Flex 다음에 알파벳 순서에 맞춰 Grid를 배치하여 일관성을 유지했습니다.

packages/react/src/components/Grid/index.ts (1)

1-1: Grid 컴포넌트 및 GridProps 타입이 재-내보내기 되었습니다
다른 모듈에서 import { Grid } from "@seed-design/react"가 가능하도록 설정되었습니다.

packages/css/base.min.css (1)

1-1: 빌드된 CSS에 .seed-grid 클래스가 포함되었습니다
Minified 파일에도 .seed-grid 정의가 정상적으로 적용되었습니다. (자동 생성 파일이므로 직접 수정하지 마세요)

🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)


[error] 1-1: Unexpected unknown function: constant

Use a known function instead.
See MDN web docs for more details.

(lint/correctness/noUnknownFunction)

docs/components/example/grid-columns-number.tsx (2)

1-2: 컴포넌트 임포트 적절
BoxGrid@seed-design/react에서 가져오는 부분이 올바르며, 필요한 의존성을 정확히 반영하고 있습니다.


5-10: Grid 예제 사용 확인
columns={2}, gap="x2", width="full" 설정을 통해 숫자 기반 컬럼 정의가 올바르게 적용되었으며, 내부 Box 요소들의 스타일도 일관성 있게 지정되었습니다.

docs/components/example/grid-preview.tsx (2)

1-2: 컴포넌트 임포트 확인
BoxGrid@seed-design/react에서 정확히 가져오고 있습니다.


5-10: 기본 Grid 레이아웃 예제 승인
columns={2}, gap="x2", width="full" 설정으로 기본 그리드 동작을 잘 보여주고 있으며, 의도한 대로 작동합니다.

docs/components/example/grid-columns-string.tsx (2)

1-2: 컴포넌트 임포트 확인
BoxGrid를 올바르게 임포트하고 있습니다.


5-10: 문자열 기반 컬럼 정의 적절
columns="2fr 1fr" 사용이 명확하게 예시되어 있으며, 그리드 템플릿을 문자열로 직접 지정하는 방식을 잘 설명합니다.

packages/qvism-preset/src/global.ts (1)

151-158: .seed-grid 글로벌 CSS 클래스 추가 승인
그리드 컨테이너에 display: grid 및 컬럼/행 CSS 커스텀 프로퍼티를 정의한 부분이 적절하며, 기본값 설정도 일관적입니다.

packages/css/all.css (1)

149-155: .seed-grid CSS 클래스 추가 승인
--seed-grid-columns, grid-template-columns, --seed-grid-rows, grid-template-rows, display: grid 설정이 올바르게 반영되어 있으며, 일관된 기본 레이아웃을 제공합니다.

docs/content/react/components/(layout)/grid.mdx (4)

1-4: 문서 제목과 설명이 명확하게 작성되었습니다.

Grid 컴포넌트의 목적과 특징을 간결하게 잘 설명하고 있습니다.


6-13: 예제 컴포넌트 참조가 적절합니다.

ComponentExample 컴포넌트를 사용하여 Grid 컴포넌트의 사용법을 직관적으로 보여주고 있습니다.


15-17: Props 문서화가 잘 되어 있습니다.

react-type-table 컴포넌트를 사용하여 GridProps 타입을 자동으로 문서화하는 접근 방식이 좋습니다.


19-30: columns prop의 number 타입 설명이 명확합니다.

숫자 값을 전달했을 때의 동작을 명확하게 설명하고 있으며, 예제를 통해 시각적으로 보여주고 있습니다.

packages/react/src/components/Grid/Grid.tsx (2)

5-9: display 속성 타입 제한이 명확합니다.

Box 컴포넌트에서 display 속성을 제외하고 재정의하여 Grid 컴포넌트의 목적에 맞게 제한한 것이 좋습니다.


11-19: align과 justify의 속성 정의가 명확합니다.

alignItems와 justifyContent의 shorthand로 명확하게 정의되어 있습니다.

Comment on lines +21 to +35
/**
* Shorthand for `gridTemplateColumns`.
* If number, `repeat({columns}, minmax(0, 1fr))` is applied.
*
* @default 2
*/
columns?: number | string;

/**
* Shorthand for `gridTemplateRows`.
*
* @default undefined
*/
rows?: string;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

columns와 rows 속성 정의에 개선이 필요합니다.

columns와 rows 속성이 잘 정의되어 있으나, columns의 기본값이 JSDoc에는 2로 명시되어 있지만 실제 구현에서는 설정되지 않았습니다.

다음과 같이 기본값을 설정하는 것이 좋겠습니다:

export const Grid = React.forwardRef<HTMLDivElement, GridProps>((props, ref) => {
-  const { align, justify, columns, rows, ...rest } = props;
+  const { align, justify, columns = 2, rows, ...rest } = props;

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

Comment on lines +37 to +56
export const Grid = React.forwardRef<HTMLDivElement, GridProps>((props, ref) => {
const { align, justify, columns, rows, ...rest } = props;

return (
// @ts-expect-error: display: "grid" is not allowed in the Box component
<Box
ref={ref}
alignItems={align}
justifyContent={justify}
{...mergeProps(rest, {
className: "seed-grid",
style: {
"--seed-grid-columns":
typeof columns === "number" ? `repeat(${columns}, minmax(0, 1fr))` : columns,
"--seed-grid-rows": rows,
} as React.CSSProperties,
})}
/>
);
});
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

구현에 몇 가지 개선 사항이 있습니다.

Grid 컴포넌트의 구현이 전반적으로 잘 되어 있으나, 몇 가지 개선할 점이 있습니다:

  1. TypeScript expect-error 주석이 사용되었는데, 이는 근본적인 타입 문제를 해결하기보다 회피하는 방법입니다.
  2. columns가 0이나 음수인 경우에 대한 유효성 검사가 없습니다.

다음과 같이 개선하는 것을 추천합니다:

export const Grid = React.forwardRef<HTMLDivElement, GridProps>((props, ref) => {
-  const { align, justify, columns, rows, ...rest } = props;
+  const { align, justify, columns = 2, rows, display = "grid", ...rest } = props;
+  
+  // columns가 숫자인 경우 0보다 큰지 확인
+  const gridColumns = 
+    typeof columns === "number" 
+      ? columns > 0 
+        ? `repeat(${columns}, minmax(0, 1fr))` 
+        : "none" 
+      : columns;

  return (
-    // @ts-expect-error: display: "grid" is not allowed in the Box component
    <Box
      ref={ref}
      alignItems={align}
      justifyContent={justify}
+      className="seed-grid"
+      style={{
+        display,
+        "--seed-grid-columns": gridColumns,
+        "--seed-grid-rows": rows,
+      } as React.CSSProperties}
-      {...mergeProps(rest, {
-        className: "seed-grid",
-        style: {
-          "--seed-grid-columns":
-            typeof columns === "number" ? `repeat(${columns}, minmax(0, 1fr))` : columns,
-          "--seed-grid-rows": rows,
-        } as React.CSSProperties,
-      })}
+      {...rest}
    />
  );
});

또는 Box 컴포넌트의 타입을 수정하여 display: "grid"를 허용하도록 하는 것이 더 나은 해결책일 수 있습니다.

Committable suggestion skipped: line range outside the PR's diff.

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