Skip to content

駅名表示をフォント縮小から横圧縮に変更 - #6066

Merged
TinyKitten merged 3 commits into
devfrom
codex/header-station-name-compression
May 28, 2026
Merged

TinyKitten merged 3 commits into
devfrom
codex/header-station-name-compression

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 28, 2026 •

Copy link
Copy Markdown
Member

概要

駅名が長い場合にフォントサイズを縮小する処理を撤廃し、実際の電車案内のように駅名の横幅を圧縮して表示するように変更しました。

変更の種類

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

変更内容

  • 駅名の実描画幅を測定して、表示領域を超える場合だけ横方向に圧縮する HeaderStationName を追加
  • 各 Header の駅名表示をフォント縮小から横圧縮表示に差し替え
  • 未使用になった駅名縮小ユーティリティと関連テストを削除
  • 長い駅名でも省略記号や過剰な圧縮にならないことを確認するテストを追加

テスト

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

実行コマンド:

npx biome check --unsafe --fix ./src
set TZ=UTC&& npx jest --runInBand src/components/HeaderStationName.test.tsx src/components/HeaderTY.test.tsx src/components/HeaderEast/HeaderEast.test.tsx src/components/HeaderJRKyushu.test.tsx src/components/HeaderSaikyo.test.tsx
npm run typecheck
npm run lint

関連Issue

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

Summary by CodeRabbit

  • Refactor

    • 駅名表示を共通コンポーネントに統一し、各ヘッダーで一貫した表示・配置を実現。
    • コンテナ幅と実テキスト幅に基づく横方向スケーリングでフォントサイズを維持しつつ表示を収めるよう改善。
    • 従来の判定ベースのスケーリングロジックを廃止し、コンテナ左右位置指定を明示化。
  • Tests

    • 駅名表示の計測・圧縮挙動を検証するテストを追加。

Review Change Stack

@TinyKitten TinyKitten self-assigned this May 28, 2026
@github-actions github-actions Bot added the react label May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 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: f814f67d-59d1-47a5-939d-e273b8f7d276

📥 Commits

Reviewing files that changed from the base of the PR and between f9c4c08 and 19fdbbc.

📒 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 を追加し、7 つの Header コンポーネント(E231、E235、East、JL、JRKyushu、JRWest、Saikyo)の駅名表示を HeaderStationName 呼び出しへ置換。calcStationNameMinScale と関連テストは削除され、測定ベースの scaleX で横圧縮する方式に移行しました。

Changes

駅名表示コンポーネント化と Header 統一

Layer / File(s) Summary
HeaderStationName コンポーネント実装
src/components/HeaderStationName.tsx
コンテナ幅とテキスト実幅を計測して widthScale を算出し、表示用 Text に transform: [{ scaleX }] と幅制御を適用する二層レンダリングを実装。TextComponent の差し替えと必要な Props 型を定義。
HeaderStationName ユニットテスト
src/components/HeaderStationName.test.tsx
textLayout と container layout のシミュレーションに基づき、scaleX・width・ellipsizeMode・フォントサイズの期待値を検証する 2 ケースを追加。
Header コンポーネント駅名表示の統一置き換え
src/components/HeaderE231.tsx, src/components/HeaderE235.tsx, src/components/HeaderEast/HeaderEast.tsx, src/components/HeaderJL.tsx, src/components/HeaderJRKyushu.tsx, src/components/HeaderJRWest.tsx, src/components/HeaderSaikyo.tsx
各 Header の Typography / RNAnimated.Text による直描画を HeaderStationName に置換。calcStationNameMinScale の import と minimumFontScale 指定を削除し、TextComponent・text・textStyle を渡す統一パターンへ。いくつかの Header で stationNameContainer に左右制約(left/right: 0)を追加。

Sequence Diagram(s)

sequenceDiagram
  participant Header as Header Component
  participant HSN as HeaderStationName
  participant Measure as Layout Measurement
  participant TextComp as TextComponent (Typography/RNAnimated.Text)
  
  Header->>HSN: text, textStyle, TextComponent
  HSN->>Measure: onLayout (container width)
  Measure-->>HSN: containerWidth
  HSN->>TextComp: render (measure text width)
  TextComp-->>Measure: textLayout event
  Measure-->>HSN: textWidth
  HSN->>HSN: calculate widthScale
  HSN->>TextComp: apply scaleX transform
  TextComp-->>Header: rendered station name
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#5988: Header の駅名表示(minimumFontScale / calcStationNameMinScale)を扱った変更が関連します。
  • TrainLCD/MobileApp#6065: 本 PR の HeaderStationName 置換をリバートして旧方式へ戻す試みが含まれており、同一領域で競合する可能性があります。
  • TrainLCD/MobileApp#6063: station name のレイアウト制御(minWidth/scaleX の振る舞い)に直接関係する変更を含んでおり、挙動に影響します。

"ぼくウサギ、文字を測るよ 🐇
透明な文字で幅を測って、ぴったりにするんだ、
フォントそのまま、横だけぎゅっと compress、
7 つの Header にお引越し完了、
みんなで揃って表示だよ!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR のタイトル「駅名表示をフォント縮小から横圧縮に変更」は、このPRの主要な変更点を明確に反映しており、長い駅名の表示方法をフォント縮小から横圧縮に変更するという中核的な変更を簡潔に要約している。
Description check ✅ Passed PR説明は提供されたテンプレートのほぼすべての主要セクションを完備しており、概要・変更の種類・変更内容・テストチェックリスト・実行コマンドが充実している。テストの実施内容も具体的に記載されている。
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 codex/header-station-name-compression

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.

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/HeaderStationName.test.tsx (1)

5-74: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

afterEach で jest.clearAllMocks() を追加してください。

このテストファイルではモック状態のクリア処理が未定義です。テスト分離のため afterEach(() => jest.clearAllMocks()) を追加してください。As per coding guidelines: "Jest のネットワークと Firebase レイヤーは jest.mock でモック化してください / テストの afterEach で jest.clearAllMocks() を呼び出してください".

💡 Suggested fix
 describe('HeaderStationName', () => {
+  afterEach(() => {
+    jest.clearAllMocks();
+  });
+
   it('keeps the font size and compresses text width when the station name is wider than its container', () => {
🤖 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.test.tsx` around lines 5 - 74, Add a
per-test cleanup to the HeaderStationName test suite by inserting afterEach(()
=> jest.clearAllMocks()) inside the describe('HeaderStationName', ...) block (so
it runs after each it block); this will clear all Jest mocks between tests and
ensure tests like the ones invoking render, fireEvent, UNSAFE_getAllByType and
getAllByText run in isolation.
🤖 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.

Inline comments:
In `@src/components/HeaderStationName.tsx`:
- Around line 97-106: The invisible measurement TextComponent is still exposed
to the accessibility tree causing duplicate screen-reader output; update the
TextComponent (the one using textProps, onLayout={handleTextFallbackLayout},
onTextLayout={handleTextLayout}, style={[textStyle, styles.measureText]}) to
explicitly exclude it from accessibility by adding accessible={false} and
importantForAccessibility='no-hide-descendants' to the component props.

---

Outside diff comments:
In `@src/components/HeaderStationName.test.tsx`:
- Around line 5-74: Add a per-test cleanup to the HeaderStationName test suite
by inserting afterEach(() => jest.clearAllMocks()) inside the
describe('HeaderStationName', ...) block (so it runs after each it block); this
will clear all Jest mocks between tests and ensure tests like the ones invoking
render, fireEvent, UNSAFE_getAllByType and getAllByText run in isolation.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 29d70c02-abab-48cd-8c97-fdb8a8952b4b

📥 Commits

Reviewing files that changed from the base of the PR and between 32ce292 and 2030e45.

📒 Files selected for processing (12)
  • src/components/HeaderE231.tsx
  • src/components/HeaderE235.tsx
  • src/components/HeaderEast/HeaderEast.tsx
  • src/components/HeaderJL.tsx
  • src/components/HeaderJRKyushu.tsx
  • src/components/HeaderJRWest.tsx
  • src/components/HeaderSaikyo.tsx
  • src/components/HeaderStationName.test.tsx
  • src/components/HeaderStationName.tsx
  • src/utils/getStationNameScale.ts
  • src/utils/stationNameScale.test.ts
  • src/utils/stationNameScale.ts
💤 Files with no reviewable changes (3)
  • src/utils/stationNameScale.ts
  • src/utils/stationNameScale.test.ts
  • src/utils/getStationNameScale.ts

Comment thread src/components/HeaderStationName.tsx Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

Fixes Applied Successfully

Fixed 2 file(s) based on 2 CodeRabbit feedback item(s).

Files modified:

  • src/components/HeaderStationName.tsx
  • src/components/HeaderStationName.test.tsx

Commit: f9c4c0809

The latest autofix changes are on the codex/header-station-name-compression branch.

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

Actionable comments posted: 1

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

Inline comments:
In `@src/components/HeaderStationName.tsx`:
- Line 100: In HeaderStationName.tsx change the JSX attribute
importantForAccessibility="no-hide-descendants" to use single quotes per repo
style; locate the JSX element that sets importantForAccessibility (attribute
name: importantForAccessibility) and replace the double-quoted value with a
single-quoted value 'no-hide-descendants' to align with the project's quote
rules.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63b8c45f-5f7d-42f3-a526-0d7b10faccbe

📥 Commits

Reviewing files that changed from the base of the PR and between 2030e45 and f9c4c08.

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

Comment thread src/components/HeaderStationName.tsx Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

Fixes Applied Successfully

Fixed 1 file(s) based on 1 CodeRabbit feedback item(s).

Files modified:

  • src/components/HeaderStationName.tsx

Commit: 19fdbbc17

The latest autofix changes are on the codex/header-station-name-compression branch.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@TinyKitten
TinyKitten merged commit 298e176 into dev May 28, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the codex/header-station-name-compression branch May 28, 2026 11:54
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