Skip to content

fix: 管理画面の認証ページのbodyクラスをlayout-adminから分離#159

Merged
machida merged 2 commits intomainfrom
feature/admin-auth-layout-class
Mar 27, 2026
Merged

fix: 管理画面の認証ページのbodyクラスをlayout-adminから分離#159
machida merged 2 commits intomainfrom
feature/admin-auth-layout-class

Conversation

@machida
Copy link
Copy Markdown
Owner

@machida machida commented Mar 27, 2026

概要

ログイン・パスワードリセット画面は左メニューが存在しないため、body タグのクラスを layout-admin から layout-admin-auth に変更しました。

変更内容

app/views/layouts/admin.html.erb
content_for(:body_class) が指定されていればそれを使い、なければ従来の layout-admin + テーマカラー等を適用するように変更。

<%# 変更前 %>
<body class="min-h-screen flex flex-col layout-admin ...">

<%# 変更後 %>
<body class="min-h-screen flex flex-col <%= content_for?(:body_class) ? yield(:body_class) : "layout-admin ..." %>">

対象ビュー(3画面)に layout-admin-auth を指定

  • app/views/admin/sessions/new.html.erb(ログイン)
  • app/views/admin/password_resets/new.html.erb(パスワードリセット申請)
  • app/views/admin/password_resets/show.html.erb(新パスワード設定)

実施済みコマンド

bundle exec rails test --exclude "playwright"  # 323 runs, 0 failures

🤖 Generated with Claude Code

Summary by CodeRabbit

リリースノート

  • Style
    • 管理画面の認証ページ(パスワードリセット、ログイン)に専用のCSSクラス設定を追加しました。レイアウトシステムを更新し、ページごとのスタイルカスタマイズに対応する仕組みを導入しました。

ログイン・パスワードリセット画面は左メニューが存在しないため、
layout-adminではなくlayout-admin-authを使用するよう変更。
content_for(:body_class)でビュー側からbodyクラスを指定できるよう
admin.html.erbを改修し、対象の3画面に設定を追加した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Warning

Rate limit exceeded

@machida has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 27c4ffe3-37e8-4d40-8d53-61fdb1477992

📥 Commits

Reviewing files that changed from the base of the PR and between d4fd193 and a3b3835.

📒 Files selected for processing (3)
  • app/assets/tailwind/_utilities.css
  • app/assets/tailwind/components/_admin-body.css
  • app/assets/tailwind/components/_admin-colors.css
📝 Walkthrough

Walkthrough

管理者認証ページテンプレート(パスワードリセット、セッション新規作成)にcontent_for :body_classブロックを追加し、値を"layout-admin-auth"に設定。管理者レイアウトを更新して、このコンテンツブロックの有無を条件に応じて検出し、存在すればそれを使用、なければデフォルト動作にフォールバック。

Changes

Cohort / File(s) Summary
Admin Auth Templates
app/views/admin/password_resets/new.html.erb, app/views/admin/password_resets/show.html.erb, app/views/admin/sessions/new.html.erb
各テンプレートにcontent_for :body_classを追加し、"layout-admin-auth"クラスを指定。レイアウト側での CSS クラス管理の一元化を実現。
Admin Layout
app/views/layouts/admin.html.erb
content_for?(:body_class)の有無を判定。存在する場合はその値を body クラスとして使用、それ以外は従来のデフォルト動作(テーマカラー、ログイン状態に応じたクラス付与)にフォールバック。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~8 minutes

Possibly related PRs

  • Fix markup css #130: 管理者レイアウトの body クラス生成ロジックを同様に変更し、ログイン状態のパディング/クラス制御を扱う
  • Feature/form label styling #10: 管理者認証ビュー(app/views/admin/sessions/new.html.erb など)の変更が重複する関連 PR

Poem

✨ 認証ページに新しい衣装を
body クラスで装いを調える
Tailwind の力、レイアウト側で
スタイル管理、シンプルに統一
Rails の作法に沿いて美しく 🎨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは日本語で記載されており、管理画面の認証ページのbodyクラスをlayout-adminからlayout-admin-authに分離する変更内容と完全に一致しています。変更の主要な目的を明確かつ簡潔に表現しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/admin-auth-layout-class

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.

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/views/admin/password_resets/show.html.erb`:
- Line 2: The page sets content_for :body_class to "layout-admin-auth" but no
corresponding CSS exists, so styles applied to body.layout-admin (color,
background-color, and admin-nav padding offset) are lost; either add a Tailwind
component that defines the .layout-admin-auth rules (mirroring the variables and
offsets used by body.layout-admin) or change the views (e.g., show.html.erb,
sessions/new.html.erb, password_resets/new.html.erb) to reuse the existing
layout-admin class; update the Tailwind components so the design-system CSS
variables (e.g., --color-text-primary, --color-admin-bg-body) and the nav
padding-left offset are applied to .layout-admin-auth if you choose the new
class.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0dc05c1a-befe-461c-99c3-1556b3a63387

📥 Commits

Reviewing files that changed from the base of the PR and between bd34bb3 and d4fd193.

📒 Files selected for processing (4)
  • app/views/admin/password_resets/new.html.erb
  • app/views/admin/password_resets/show.html.erb
  • app/views/admin/sessions/new.html.erb
  • app/views/layouts/admin.html.erb

@@ -1,4 +1,5 @@
<% content_for :title, "新しいパスワードの設定" %>
<% content_for :body_class, "layout-admin-auth" %>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check if layout-admin-auth CSS styles are defined

# Search for layout-admin-auth CSS definitions
rg -n 'layout-admin-auth' --type css

# Also check for any SCSS/CSS files that might define these styles
fd -e css -e scss | xargs grep -l 'layout-admin-auth' 2>/dev/null || echo "No CSS files found with layout-admin-auth"

Repository: machida/mb

Length of output: 95


🏁 Script executed:

# Check if body.layout-admin CSS exists
rg -n 'body\.layout-admin|\.layout-admin' --type css

# Search for layout-admin in CSS/SCSS files
fd -e css -e scss -e tailwind | xargs grep -l 'layout-admin' 2>/dev/null

# Check the admin layout file structure
fd -n 'application.html.erb|admin.*layout' --type f | head -10

Repository: machida/mb

Length of output: 2727


🏁 Script executed:

# Read the specific file being reviewed
cat -n app/views/admin/password_resets/show.html.erb | head -20

# Check for _admin-body.css
fd -n '_admin-body' --type f

Repository: machida/mb

Length of output: 1320


🏁 Script executed:

# Search for content_for :body_class usage patterns across the codebase
rg -A 3 'content_for.*:body_class' --type erb | head -30

Repository: machida/mb

Length of output: 1597


🏁 Script executed:

# Read _admin-body.css to see what styles are defined for body.layout-admin
cat -n app/assets/tailwind/components/_admin-body.css

# Also check _layout.css around line 57
sed -n '50,70p' app/assets/tailwind/components/_layout.css

Repository: machida/mb

Length of output: 606


🏁 Script executed:

# Search for any layout-admin-auth definition in all file types
rg 'layout-admin-auth' -n

Repository: machida/mb

Length of output: 341


layout-admin-auth クラスに対応するCSS定義がありません

body.layout-admin セレクタに定義されている以下のスタイルが適用されなくなります:

  • color: var(--color-text-primary) - テキスト色変数
  • background-color: var(--color-admin-bg-body) - 背景色変数
  • ログイン状態時の管理画面ナビゲーションの padding-left オフセット

Line 4 のラッパー div に bg-sky-50 などのインライン Tailwind クラスがある場合でも、CSS 変数を使用した設計システムの意図が損なわれます。

layout-admin-auth 用の CSS を app/assets/tailwind/components/ に定義するか、既存の layout-admin クラスを再利用してください。このパターンは app/views/admin/sessions/new.html.erbapp/views/admin/password_resets/new.html.erb でも同じ問題を抱えています。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/views/admin/password_resets/show.html.erb` at line 2, The page sets
content_for :body_class to "layout-admin-auth" but no corresponding CSS exists,
so styles applied to body.layout-admin (color, background-color, and admin-nav
padding offset) are lost; either add a Tailwind component that defines the
.layout-admin-auth rules (mirroring the variables and offsets used by
body.layout-admin) or change the views (e.g., show.html.erb,
sessions/new.html.erb, password_resets/new.html.erb) to reuse the existing
layout-admin class; update the Tailwind components so the design-system CSS
variables (e.g., --color-text-primary, --color-admin-bg-body) and the nav
padding-left offset are applied to .layout-admin-auth if you choose the new
class.

layout-admin-authクラスにCSS変数・色・背景色が当たらない問題を修正。
_admin-colors.css/_admin-body.css/_utilities.cssの各セレクタに
.layout-admin-authを追加し、認証ページでもadminのデザイントークンが
継承されるようにした。is--logged-inのnav padding-leftは不要なため除外。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@machida machida merged commit 2c1f596 into main Mar 27, 2026
3 checks passed
@machida machida deleted the feature/admin-auth-layout-class branch March 27, 2026 08:31
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