Skip to content

SWF(refactor): ナビの項目定義と active 判定を共通化し cn() を使う - #816

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1795145909-share-nav-active-path
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1795145909-share-nav-active-path

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

ナビの Blog/About の定義と active 判定を src/lib/navigation.ts にまとめ、クラスの結合を cn() に置き換えました。見た目と動作は変わりません。

Closes #732

Summary

  • これまで HeaderNavItem.astro と FooterNavItem.astro に同じ active 判定があり、HeaderNav.astro と FooterNav.astro には Blog/About の定義が重複していました。
  • navItems と isNavItemActive(path, currentPath) を src/lib/navigation.ts に移しました。判定の式は元のままです(/posts の前方一致も残しています)。
  • テンプレート文字列でのクラス連結を、AGENTS.md の規約どおり cn() に替えました。HeaderNavItem・FooterNavItemのクラス結合をcn()に揃える #732 が挙げた 2 箇所はこの変更で解消します。
  • HeaderNavItem・FooterNavItemのクラス結合をcn()に揃える #732 にある FooterNavItem の text-gray-900 の重複も cn() で解消します。アクティブ時は twMerge が上書きされる text-gray-600 を取り除くので、文字色のクラスは text-gray-900 だけが残ります。
class={cn('uppercase', { 'border-b border-current': isLinkActive })}

出力 HTML の差分

変更前(main)と変更後で pnpm run build:ci を実行し、dist の HTML 48 ファイルを比べました。

  • ナビの差分は空白と、Blog/About がアクティブなフッターリンク 18 ページで text-gray-600 と dark:text-gray-400 が消えたことだけです。cn() の twMerge が、あとに書かれた text-gray-900 / dark:text-white に上書きされるクラスを取り除くためで、適用されるスタイルは同じです。
  • href と aria-current は変わっていません。
  • posts/wishlist-2024-04/ にはビルドごとの外部リンクカード取得による差分がありますが、今回の変更とは関係ありません。この差分と上記の正規化を除くと diff -r は一致しました(exit 0)。

実行結果

pnpm exec vitest run navigation --reporter=verbose

 ✓ isNavItemActive > path "/" at "/" is active: true
 ✓ isNavItemActive > path "/" at "/posts/example/" is active: true
 ✓ isNavItemActive > path "/" at "/posts-other" is active: true
 ✓ isNavItemActive > path "/" at "/about/" is active: false
 ✓ isNavItemActive > path "/about/" at "/about/team/" is active: true
 ✓ isNavItemActive > path "/about/" at "/about-other/" is active: false
 …(全 13 件)
 Test Files  1 passed (1)
      Tests  13 passed (13)
  • pnpm run test:unit: 8 files / 145 tests passed
  • pnpm run lint: 0 errors, 0 warnings
  • pnpm exec playwright test tests/e2e/specs/navigation.spec.ts --project=chromium: 8 passed, 1 skipped(モバイル専用のテスト)

試すコマンド: pnpm exec vitest run navigation && pnpm exec playwright test tests/e2e/specs/navigation.spec.ts --project=chromium

未確認

  • 実画面での目視確認はまだです。QA Engineer の確認結果をこの PR に追記します。

Software Factory opened this PR for Daiki
Implemented in session Share nav active-path logic and use cn()
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8948896c-c24a-4b47-ae33-650bdb722a13

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
blog e813e29 Commit Preview URL

Branch Preview URL
Nov 20 2026, 03:47 AM

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

QA 結果: 合格

ナビゲーションは全12条件で合格しました。Chromium で PR の e813e29 と、origin/main との共通祖先 e693614 を比較しました。

  • 対象はトップ、記事(/posts/nespresso-mold/)、About の3ページです。ライトとダーク、デスクトップ(幅1024 CSS px)とモバイル(幅390 CSS px)で確かめました。
  • トップと記事では Blog、About では About が強調されました。ヘッダーの下線と文字色、フッターの文字色と太さが比較元と一致しました。ナビ部分の画像24組にピクセル差はありませんでした。
  • モバイルでは、メニューを開いてヘッダーを、閉じてフッターを確認しました。
  • ヘッダーとフッターの Blog・About リンクには、比較元にも PR にも aria-current がありません。今回の変更による差ではありません。

不合格の項目はありません。録画は代表的な操作を収めたもので、全条件の比較は別にブラウザーの自動操作で実行しました。

録画

録画(チャプター付き)

現在地表示の比較(左:比較元、右:PR)

ナビ以外で気づいたこと

録画中、記事のリンクカード画像2件で DevTools に 404 が表示されました。新しい Chromium セッションでは再現せず、両ビルドで画像 URL に直接アクセスすると 200 が返りました。原因はわかっていませんが、ナビゲーションへの影響はありませんでした。

Written by Devin

This branch has not been deployed

No deployments
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.

HeaderNavItem・FooterNavItemのクラス結合をcn()に揃える

0 participants