Skip to content

iPadアーチ表示で直通運転時に路線カラーを区間ごとに色分け - #5325

Merged
TinyKitten merged 2 commits into
devfrom
feature/separate-colors-tablet-jy
Feb 18, 2026
Merged

TinyKitten merged 2 commits into
devfrom
feature/separate-colors-tablet-jy

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

Co-Authored-By: Claude Opus 4.6 [email protected]

Summary by CodeRabbit

リリースノート

  • 改善
    • 電車種別に基づく色分割表示を導入し、駅表示で複数色のセグメントが反映されるようになりました。視認性と路線色の表現が向上します。
  • テスト
    • 電車種別取得のテスト用モックを追加し、表示ロジックの安定性を高めました。

@github-actions github-actions Bot added the react label Feb 18, 2026
@coderabbitai

coderabbitai Bot commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

LineBoardYamanotePadがuseCurrentTrainTypeで取得した列車タイプ情報をPadArchへtrainTypeLinesプロップとして渡すようになり、PadArchは駅と列車タイプのライン情報に基づく色分割(ColorSegment)レンダリングを導入しました。

Changes

Cohort / File(s) Summary
LineBoardYamanotePad
src/components/LineBoardYamanotePad.tsx
useCurrentTrainTypeをインポートしtrainType = useCurrentTrainType()を追加、PadArchへtrainTypeLines={trainType?.lines ?? []}を渡すよう変更。
PadArch 色分割レンダリング
src/components/PadArch.tsx
ColorSegment型とcomputeColorSegmentsを追加。プロップにtrainTypeLines: LineNested[]を追加し、駅の色と列車タイプライン色に基づくメモ化された色セグメント配列で複数セグメントのSVG/View描画に変更。既存の単色レンダリングを分割レンダリングへ置換。
テストモック更新
src/components/LineBoardYamanotePad.test.tsx
~/hooksのJestモックにuseCurrentTrainTypeのデフォルト戻り値を追加(null)してテストを安定化。

Sequence Diagram(s)

sequenceDiagram
  participant Hook as useCurrentTrainType
  participant Pad as LineBoardYamanotePad
  participant Arch as PadArch
  Hook->>Pad: trainType (lines)
  Pad->>Arch: props (stations, trainTypeLines, fallbackColor, height)
  Arch->>Arch: computeColorSegments(stations, trainTypeLines, ...)
  Arch->>Arch: render dark layer + main color segments (SVG / Views)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 分

Possibly related PRs

概要(既存文の更新)

LineBoardYamanotePadコンポーネントからuseCurrentTrainTypeフックを呼び出して取得した列車タイプ情報をPadArchコンポーネントにtrainTypeLinesプロップとして渡すようにしました。PadArchコンポーネントではこのデータを使用して、色分割レンダリング機能を実装し、駅の色と列車タイプラインの色に基づいて色付きセグメントを計算・表示するように修正しました。

🐰 ウサギからのお祝いポエム

線路の色を掬うよ、ふわふわと、
trainTypeLines が届けば、セグメントが踊る。
PadArch は筆を取り、色を分けるよ、
ぽかぽか描画で画面が笑う。 🐇🎨

🚥 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 PRタイトルは、iPad アーチ表示における直通運転時の路線カラー区間分け機能という、変更セットの主要な目的を正確に反映しており、具体的で明確である。
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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/separate-colors-tablet-jy

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

@TinyKitten TinyKitten self-assigned this Feb 18, 2026

@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/LineBoardYamanotePad.test.tsx (1)

13-20: モック追加は適切です。

useCurrentTrainTypeのモックがnullを返す設定は、既存テストの動作を維持しつつ、新しいフック依存関係に対応しています。

ただし、trainTypeLinesプロップがPadArchに渡されることを検証するテストケースの追加を検討してください。直通運転時の路線カラー色分け機能をカバーするために、useCurrentTrainTypeが実際のtrainType(linesを含む)を返すケースのテストがあると良いでしょう。

💡 trainTypeLinesのテストケース例
it('trainTypeLinesがPadArchに正しく渡される', () => {
  const { useCurrentTrainType } = require('~/hooks');
  const mockTrainType = {
    id: 1,
    lines: [
      { id: 1, color: '#9acd32' },
      { id: 2, color: '#f15a22' },
    ],
  };
  useCurrentTrainType.mockReturnValue(mockTrainType);

  render(<LineBoardYamanotePad stations={mockStations} />);
  expect(PadArch).toHaveBeenCalledWith(
    expect.objectContaining({
      trainTypeLines: mockTrainType.lines,
    }),
    undefined
  );
});

As per coding guidelines: "Update or add tests relevant to code changes before submitting."

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

In `@src/components/LineBoardYamanotePad.test.tsx` around lines 13 - 20, Add a
unit test in LineBoardYamanotePad.test.tsx that mocks useCurrentTrainType to
return a realistic trainType object (including a lines array) and verifies that
the LineBoardYamanotePad component passes that lines array to PadArch via the
trainTypeLines prop; specifically, require and set
useCurrentTrainType.mockReturnValue(mockTrainType), render(<LineBoardYamanotePad
stations={mockStations} />), and assert PadArch was called with
expect.objectContaining({ trainTypeLines: mockTrainType.lines }); this ensures
the PadArch prop wiring for direct-run line color splitting is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/LineBoardYamanotePad.test.tsx`:
- Around line 13-20: Add a unit test in LineBoardYamanotePad.test.tsx that mocks
useCurrentTrainType to return a realistic trainType object (including a lines
array) and verifies that the LineBoardYamanotePad component passes that lines
array to PadArch via the trainTypeLines prop; specifically, require and set
useCurrentTrainType.mockReturnValue(mockTrainType), render(<LineBoardYamanotePad
stations={mockStations} />), and assert PadArch was called with
expect.objectContaining({ trainTypeLines: mockTrainType.lines }); this ensures
the PadArch prop wiring for direct-run line color splitting is covered.

@TinyKitten
TinyKitten merged commit 5cd5d64 into dev Feb 18, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the feature/separate-colors-tablet-jy branch February 18, 2026 16:51
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