Skip to content

練馬春日町の駅名表示幅に余白を追加 - #6087

Merged
TinyKitten merged 2 commits into
devfrom
fix/header-station-name-width-buffer
May 29, 2026
Merged

TinyKitten merged 2 commits into
devfrom
fix/header-station-name-width-buffer

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 29, 2026 •

Copy link
Copy Markdown
Member

概要

駅名表示の測定幅に小さな余白を加え、ネイティブの文字幅計測が日本語グリフをわずかに小さく返す場合でも末尾が欠けにくいようにしました。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • HeaderStationName の描画幅と縮小率計算に、測定幅 + 8px の余白を使うようにしました。
  • 「練馬春日町」へ表示変更した直後だけでなく、再測定後も余白込みの幅で描画することをテストで確認しました。
  • 既存の幅圧縮テストの期待値を、余白込みの計算に合わせて更新しました。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

実行したコマンド:

npx biome check src/components/HeaderStationName.tsx src/components/HeaderStationName.test.tsx
set TZ=UTC&& node_modules\.bin\jest.cmd HeaderStationName.test.tsx --runInBand

補足: Windows cmd では package script 内の TZ=UTC が解釈されないため、対象 Jest は TZ を設定して直接実行しました。

関連Issue

Follow-up: #6084

スクリーンショット(任意)

未取得です。画面上での最終確認は実機または Expo 実行環境で、都営大江戸線の「練馬春日町」表示を確認してください。

Summary by CodeRabbit

リリースノート

  • バグ修正
    • 駅名表示のテキストスケーリング計算を改善し、測定幅にバッファを追加して表示が安定するようにしました。
  • テスト
    • スケーリング挙動に合わせて期待値と検証手順を更新し、レンダー後の再計測を含むケースを追加しました。

Review Change Stack

@TinyKitten TinyKitten self-assigned this May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad755457-918e-46b9-85c2-410bfa5426c2

📥 Commits

Reviewing files that changed from the base of the PR and between 26ac210 and 4933e00.

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

📝 Walkthrough

Walkthrough

HeaderStationName コンポーネントのテキスト幅スケーリング計算に固定バッファ(8)を導入し、新しい renderTextWidth 値に基づいて幅スケール計算と描画幅を更新。すべてのテスト期待値を新しい計算結果に合わせて調整、最後のテストでは再測定検証ステップを追加。

Changes

テキスト幅バッファ導入とスケーリング計算

Layer / File(s) Summary
バッファ定数と renderTextWidth 計算の導入
src/components/HeaderStationName.tsx
MEASURED_TEXT_WIDTH_BUFFER(8)定数を追加し、測定済みテキスト幅にバッファを加えた renderTextWidth を計算するロジックを実装。
幅スケール計算と描画幅への適用
src/components/HeaderStationName.tsx
widthScale 計算を renderTextWidth 基準に更新し、描画領域の幅指定を textWidth から renderTextWidth に切り替え。コンテナ幅が renderTextWidth 以下のとき 1 以下の比率でスケール。
テスト期待値の更新と検証拡張
src/components/HeaderStationName.test.tsx
scaledWrapperStyle の width と transform(scaleX 比率)の期待値を新しい renderTextWidth に基づく値に更新。リレンダー後に textLayout 再発火して計測結果を再検証するステップを追加。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6069: HeaderStationName のスケーリング/レンダリング動作を修正し、transform・clip 関連スタイルと wrapper 幅/transform 期待値を拡張。
  • TrainLCD/MobileApp#6053: HeaderStationName の横圧縮スケーリング基盤に、新しい renderTextWidth バッファ計算ロジックが影響。
  • TrainLCD/MobileApp#6084: HeaderStationName の測定値をスケーリング計算に反映し、リレンダー後の再測定・期待値検証を強化。

Poem

駅名の幅に余裕もたらせ、
バッファ8でゆったり表示、
計測精度で整いたり、
スケーリング計算ぐんぐん進む 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは「練馬春日町の駅名表示幅に余白を追加」で、実装内容(測定幅に8px余白を追加する変更)と完全に関連しており、主要な変更内容を明確に要約しています。
Description check ✅ Passed PR説明は必須セクション(概要、変更の種類、変更内容、テスト)を含み、実装詳細、テスト方法、関連Issueが記載されています。未チェックのテストボックスは補足説明で正当化されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/header-station-name-width-buffer

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

@github-actions github-actions Bot added the react label May 29, 2026
@TinyKitten
TinyKitten marked this pull request as ready for review May 29, 2026 21:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/HeaderStationName.tsx (1)

16-16: ⚡ Quick win

バッファ定数にコメントを追加することを推奨します。

MEASURED_TEXT_WIDTH_BUFFER の値 8 が選ばれた理由(ネイティブの文字幅計測が日本語グリフを小さく返す場合の補正など)をコメントで説明すると、将来のメンテナンス時に役立ちます。

💡 コメント追加例
 const MEASURE_TEXT_WIDTH = 10000;
+// ネイティブの文字幅計測が日本語グリフをわずかに小さく返す場合の余白
 const MEASURED_TEXT_WIDTH_BUFFER = 8;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/HeaderStationName.tsx` at line 16, Add an explanatory comment
for the constant MEASURED_TEXT_WIDTH_BUFFER (value 8) in HeaderStationName.tsx
that states why 8 was chosen and when it’s needed (e.g., to compensate for
native text measurement underestimating Japanese glyph widths or other
font/renderer quirks), include any references to how it interacts with measured
text width logic in the component so future maintainers know the rationale and
when to adjust the value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/components/HeaderStationName.tsx`:
- Line 16: Add an explanatory comment for the constant
MEASURED_TEXT_WIDTH_BUFFER (value 8) in HeaderStationName.tsx that states why 8
was chosen and when it’s needed (e.g., to compensate for native text measurement
underestimating Japanese glyph widths or other font/renderer quirks), include
any references to how it interacts with measured text width logic in the
component so future maintainers know the rationale and when to adjust the value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9ec9b3f-06e6-494f-a778-a090b0f2deb0

📥 Commits

Reviewing files that changed from the base of the PR and between bba55a1 and 26ac210.

📒 Files selected for processing (2)
  • src/components/HeaderStationName.test.tsx
  • src/components/HeaderStationName.tsx

@TinyKitten
TinyKitten merged commit 19d0c49 into dev May 29, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the fix/header-station-name-width-buffer branch May 29, 2026 21:16
@TinyKitten TinyKitten mentioned this pull request May 29, 2026
4 of 9 tasks
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.

1 participant