Skip to content

Comments

関数からコンポーネントへ#4

Merged
tanahiro2010 merged 6 commits intoSyobosetsu-Proj:masterfrom
tanahiro2010:master
Oct 30, 2025
Merged

関数からコンポーネントへ#4
tanahiro2010 merged 6 commits intoSyobosetsu-Proj:masterfrom
tanahiro2010:master

Conversation

@tanahiro2010
Copy link
Member

@tanahiro2010 tanahiro2010 commented Oct 30, 2025

概要

/src/app/page.tsx のボタン呼び出し方法を、関数呼び出しからコンポーネント呼び出しに変更しました。

変更点

  • GithubButton("Syobosetsu-Proj")<GithubButton sublink="Syobosetsu-Proj" />
  • BookButton("blog", "Blog")<BookButton link="blog">Blog</BookButton>

理由

  • コンポーネントとして扱うことで、propsの受け渡しや型定義をReact的により明確化。
  • 関数として定義されていたUIロジックを/src/components/ui/buttons.tsxに移行し、再利用性と可読性を向上。

その他

  • page.tsxからボタン関連の関数を削除し、buttons.tsxに統合。

Summary by CodeRabbit

リリースノート

  • Refactor

    • ページ内で使用していた個別ボタン実装を共通の UI ボタンコンポーネントへ統合し、レンダリングを JSX コンポーネント化しました(見た目・配置は維持)。
  • New Features

    • 共通の GitHub ボタンとリンク用のブック風ボタンが追加され、再利用性とアクセシビリティが向上しました。
  • Chores

    • package-lock.json を .gitignore に追加しました。

@vercel
Copy link
Contributor

vercel bot commented Oct 30, 2025

@tanahiro2010 is attempting to deploy a commit to the t-b-t-nchos' projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

Walkthrough

ページからローカル定義のボタンを除去し、再利用可能な GithubButtonBookButtonsrc/components/ui/buttons.tsx に移動してインポートで使用するように変更し、.gitignorepackage-lock.json を追加しました。

Changes

Cohort / File(s) 説明
.gitignore への追加
\.gitignore
package-lock.json を無視対象に追加
ページのコンポーネント修正
\src/app/page.tsx``
ローカル定義していた GithubButtonBookButton を削除し、@/components/ui/buttons からインポートした <GithubButton sublink="..."/><BookButton link="...">...</BookButton> を JSX で使用するよう変更
新規 UI コンポーネント
\src/components/ui/buttons.tsx``
export function GithubButton({ sublink }: { sublink: string })export function BookButton({ link, children }: { link: string, children: React.ReactNode }) を追加。アイコン・アクセシビリティ属性・Tailwind クラスを適用したリンクコンポーネントを実装

Sequence Diagram(s)

sequenceDiagram
    participant Page as Page (src/app/page.tsx)
    participant Buttons as UI Buttons (src/components/ui/buttons.tsx)
    participant Browser as Browser

    rect rgb(235,245,255)
    Page->>Buttons: import <GithubButton, BookButton>
    Note right of Page: JSXで配置\n<GithubButton sublink="..."/> 等
    end

    rect rgb(245,255,235)
    Page->>Browser: render page (ボタンコンポーネントを含む)
    Buttons->>Browser: render anchor / Link with icon and label
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 分

  • 注意点:
    • src/app/page.tsx の呼び出しを新しい props 形に正しく移行しているか
    • src/components/ui/buttons.tsx のアクセシビリティ属性(aria 等)とアイコン実装
    • Tailwind クラスや Next.js の Link 使用の互換性

Poem

🐰 ボタンを抱えて跳ねるよ、
新しい家へぴょんと一歩、
小さなアイコンが道しるべ、
再利用の畑で踊る午後、
コードの庭は今日も晴れ ☀️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR のタイトル「関数からコンポーネントへ」(From functions to components)は、変更セットの主要な内容を正確に反映しています。このプルリクエストの中核は、src/app/page.tsx で定義されていたボタン関連のロジックを関数から React コンポーネントに移行し、src/components/ui/buttons.tsx に統合することです。タイトルは簡潔で明確であり、リファクタリングの目的を明確に伝えており、チームメンバーがこの変更内容を素早く理解できる適切な表現になっています。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 885dae7 and afa0dd1.

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Contributor

vercel bot commented Oct 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web-page-v2 Ready Ready Preview Comment Oct 30, 2025 8:12am

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 (1)
src/components/ui/buttons.tsx (1)

3-16: Next.js Imageコンポーネントの使用を検討してください。

セキュリティ属性(target="_blank"rel="noopener noreferrer")は正しく設定されており、アイコンファイルも正常に存在することを確認しました。

改善の余地:

  • Next.jsのImageコンポーネントを使用することで、自動最適化やレイジーローディングの恩恵を受けられます。
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e02cae and b928e2c.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • src/app/page.tsx (2 hunks)
  • src/components/ui/buttons.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/page.tsx (1)
src/components/ui/buttons.tsx (2)
  • GithubButton (3-16)
  • BookButton (18-30)
🔇 Additional comments (3)
.gitignore (1)

12-12: 変更内容に問題ありません。

Yarnを使用しているプロジェクトでは、npmとの競合を避けるためpackage-lock.jsonを無視するのが標準的な慣例です。

src/app/page.tsx (2)

2-2: インポート文は正しく実装されています。

新しいUIコンポーネントのインポートが適切に行われており、パスエイリアス@/も正しく使用されています。


35-36: コンポーネント呼び出しへのリファクタリングが正しく実装されています。

関数呼び出しからJSXコンポーネント構文への変更により、以下の利点が得られています:

  • 型安全性の向上(propsの型チェック)
  • React的な記述による可読性の向上
  • 再利用性の向上

実装は正確で、各コンポーネントに必要なpropsが正しく渡されています。

@tanahiro2010 tanahiro2010 merged commit d2c719c into Syobosetsu-Proj:master Oct 30, 2025
2 of 3 checks passed
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.

1 participant