Skip to content

小田急テーマを追加#5699

Merged
TinyKitten merged 6 commits intodevfrom
feature/odakyu-theme
Mar 27, 2026
Merged

小田急テーマを追加#5699
TinyKitten merged 6 commits intodevfrom
feature/odakyu-theme

Conversation

@TinyKitten
Copy link
Copy Markdown
Member

@TinyKitten TinyKitten commented Mar 27, 2026

Summary

closes #5120

  • 小田急電鉄の車内LCD表示をイメージした新テーマを追加
  • Header: 濃いグレーグラデーション背景 + 路線カラーバー + secondaryDivider
  • LineBoard: 光沢オーバーレイ付きバー、丸型ドット(斜めグラデ+白ボーダー)、小田急用BarTerminal SVG
  • TrainTypeBox: 背景グラデ位置調整 + 光沢オーバーレイ
  • PassChevronTY: グラデーション対応
  • テーマ登録(Theme enum、カラーマップ、設定メニュー、TTS、resolveThemeForLine等)

Test plan

  • npm run typecheck パス
  • npm run lint パス
  • npm test 全146 suites / 1372 tests パス
  • 小田急テーマの表示を目視確認(各駅停車・快速急行・通過駅あり)
  • TOKYO_METRO / TOEI / TY テーマにデグレがないことを確認
  • テーマピッカーから小田急テーマを選択できることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能
    • 小田急テーマを追加:ヘッダー、行板、終端表示、ドットや表示スタイル、設定画面の選択肢に反映。
  • 翻訳
    • 小田急テーマ用の英語・日本語ラベルと説明文を追加。
  • テスト
    • 小田急ヘッダーのレンダリングと挙動を確認するテストを追加。
  • その他
    • テーマ選択、表示情報、音声テキストのテンプレートやマッピングに小田急対応を追加。

TinyKitten and others added 3 commits March 27, 2026 22:30
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the react label Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

小田急テーマ「ODAKYU」を追加。翻訳、テーマ定義、テーマ選択肢、ヘッダー/ライン表示のコンポーネント追加・拡張、TTSテンプレート調整、関連テストを導入しました。

Changes

Cohort / File(s) Summary
翻訳ファイル
assets/translations/en.json, assets/translations/ja.json
英日両言語で odakyuLike(ラベル)と themeDescriptionOdakyu(説明)を追加。
テーマ定義・定数・型
src/models/Theme.ts, src/constants/theme.ts, src/utils/themeInfo.ts, src/utils/theme.ts
APP_THEME.ODAKYU を追加し型に組み込み。テーマ情報(説明キーと画像)を登録、設定画面の選択肢に odakyuLike を追加。
テーマ解決・TTS
src/utils/resolveThemeForLine.ts, src/utils/resolveThemeForLine.test.ts, src/hooks/useTTSText.ts, src/hooks/useBusTTSText.ts
会社名プレフィックスで小田急を ODAKYU に解決するマッピングを追加。該当挙動のユニットテストを追加。TTS テンプレートとフォールバックに ODAKYU を明示的に追加し既存テーマへマップ。
ヘッダー関連
src/components/Header.tsx, src/components/HeaderOdakyu.tsx, src/components/HeaderOdakyu.test.tsx, src/components/HeaderEast/config.ts, src/components/HeaderEast/HeaderEast.tsx
Header に ODAKYU 分岐を追加。HeaderOdakyu を作成して HeaderEast に odakyu 用設定を注入。HeaderEast 設定型に secondaryDividertrainTypeBox のオプションを追加し、HeaderOdakyu のテストを導入。
ライン表示・SVG・ドット
src/components/LineBoard.tsx, src/components/LineBoardEast.tsx, src/components/LineBoard/shared/components/LineDot.tsx, src/components/PassChevronTY.tsx, src/components/BarTerminalEast.tsx, src/components/BarTerminalOdakyu.tsx
LineBoard に ODAKYU 分岐を追加。LineBoardEast/StationNameCellisOdakyu を伝播し、ハイライトオフセット・追加グラデーション・丸型ドット(round)を適用。新コンポーネント BarTerminalOdakyu を追加しハイライトオフセットをパラメータ化。PassChevronTY にグラデーション制御を追加。
表示ボックス(TrainTypeBox)
src/components/TrainTypeBox.tsx
darkenColorfontSizeScale のオプションを追加。色暗化用オーバーレイとフォント倍率の適用を導入。
その他 UI 微調整
src/components/TransfersHeading.tsx
APP_THEME.ODAKYU をケースに追加(既存 Metro スタイルのまま)。

Sequence Diagram(s)

(該当条件に合致しないため省略)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 小田急の青をぽんと塗るよ
新しいテーマ、線路が増えるよ
ヘッダー歌って、ドットは丸く
翻訳揃えてテストもぴょんと通過
さあ画面を跳ねて走ろうね

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR説明は概要を記述していますが、リポジトリの説明テンプレートに従っていません。 テンプレートの各セクション(「変更の種類」「変更内容」「テスト」「関連Issue」など)を含めた形式に修正してください。
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトル「小田急テーマを追加」はこのPRの主な変更内容を明確に表現しており、追加されたOdakyu(小田急)テーマの実装という最重要な変更を適切に要約しています。
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/odakyu-theme

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@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

🧹 Nitpick comments (6)
src/utils/resolveThemeForLine.test.ts (1)

124-130: prefix仕様を直接確認するテストを1件足すと安心です。
startsWith を使っているため、小田急電鉄 のような前方一致ケースも追加すると意図がより固定化できます。

💡 追加テスト例
+  it('小田急電鉄のような前方一致でもODAKYUを返す', () => {
+    expect(
+      resolveThemeForLine(
+        makeLine({ id: 25002, company: makeCompany('小田急電鉄') })
+      )
+    ).toBe(APP_THEME.ODAKYU);
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/resolveThemeForLine.test.ts` around lines 124 - 130, Add a second
test that verifies prefix matching by calling resolveThemeForLine with
makeLine({ id: 25001, company: makeCompany('小田急電鉄') }) and asserting it returns
APP_THEME.ODAKYU; this ensures the startsWith behavior in resolveThemeForLine is
locked down (add a new it block similar to the existing '小田急の路線はODAKYUを返す'
test).
src/components/BarTerminalOdakyu.tsx (1)

14-18: hasTerminus の利用方針を明確化したいです。
Propsで必須ですが現状未使用です。未使用ならAPIから外す、互換目的なら描画分岐で使う、のどちらかに寄せると契約が明確になります。

Also applies to: 27-27

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

In `@src/components/BarTerminalOdakyu.tsx` around lines 14 - 18, Props currently
declares hasTerminus but BarTerminalOdakyu never uses it; decide one of two
fixes and apply it consistently: (A) remove hasTerminus from the Props type and
any callers (or update call sites) if it is truly unused, or (B) keep
hasTerminus for backward compatibility and add a rendering branch inside the
BarTerminalOdakyu component that uses hasTerminus (and barHighlightOffset) to
toggle the terminus marker/visual state (e.g., alter the SVG path/group when
hasTerminus is true); update Prop defaults/types and any tests/callers
accordingly. Ensure you update the Props type and component render logic
(BarTerminalOdakyu) and any places that pass hasTerminus so the API contract is
clear.
src/components/TrainTypeBox.tsx (1)

91-91: fontSizeScale に下限ガードを入れると安全です。
設定値が 0 以下の場合に文字が潰れるため、最小値をクランプしておくと堅牢です。

💡 提案パッチ
 const TrainTypeBox: React.FC<Props> = ({
   trainType,
   localTypePrefix = '',
   nextTrainTypeColor = '#444',
   darkenColor = false,
   fontSizeScale = 1,
 }: Props) => {
+  const safeFontSizeScale = Math.max(0.5, fontSizeScale);
+
@@
-                  fontSize: (isTablet ? 18 * 1.5 : 18) * fontSizeScale,
+                  fontSize: (isTablet ? 18 * 1.5 : 18) * safeFontSizeScale,
@@
-              fontSize: (isTablet ? 18 * 1.5 : 18) * fontSizeScale,
+              fontSize: (isTablet ? 18 * 1.5 : 18) * safeFontSizeScale,

Also applies to: 301-302, 321-322

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

In `@src/components/TrainTypeBox.tsx` at line 91, The prop/variable fontSizeScale
in the TrainTypeBox component can be <= 0 which collapses text; clamp it to a
small positive minimum before use (e.g. const safeFontSizeScale =
Math.max(fontSizeScale ?? 1, 0.1)) and replace direct uses of fontSizeScale with
safeFontSizeScale; apply the same change to the other occurrences referenced
(the other fontSizeScale usages at the spots corresponding to lines ~301-302 and
~321-322) so all calculations (style/font-size computations) use the clamped
value.
src/utils/themeInfo.ts (1)

67-72: TODOコメント: 小田急テーマ用スクリーンショットの差し替え

現在Tokyo Metroのスクリーンショットがプレースホルダーとして使用されています。TODOコメントが残っているので、小田急テーマ専用のスクリーンショットを後で追加する必要があります。

この作業を追跡するためのIssueを作成しましょうか?

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

In `@src/utils/themeInfo.ts` around lines 67 - 72, Replace the Tokyo Metro
placeholder screenshots used for APP_THEME.ODAKYU by adding/committing
Odakyu-specific images and updating the spImage and tabletImage require paths
(and keep descriptionKey: 'themeDescriptionOdakyu'); remove the TODO comment.
Specifically, add new assets (e.g., odakyu-sp.webp and odakyu-tablet.webp) to
the assets/images/themes folder and update the require(...) values for
APP_THEME.ODAKYU's spImage and tabletImage accordingly, then commit and, if
desired, create an issue to track adding finalized screenshots.
src/components/LineBoardEast.tsx (1)

142-143: ハイライト位置の 0.35 は共通化したいです。

renderBarGradients()BarTerminalOdakyu で別管理なので、片方だけ調整するとバー本体と終端 SVG のハイライトがずれます。定数か共通 prop に寄せたいです。

Also applies to: 320-334

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

In `@src/components/LineBoardEast.tsx` around lines 142 - 143, The hard-coded 0.35
highlight value is duplicated between barHighlightOffset, renderBarGradients(),
and BarTerminalOdakyu causing misalignment; extract this magic number into a
single shared constant or prop (e.g., HIGHLIGHT_RATIO or highlightOffset prop)
and replace the literal 0.35 in barHighlightOffset, the gradient generation in
renderBarGradients, and the highlight position used in BarTerminalOdakyu so both
bar body and terminal SVG consume the same source of truth; update
function/component signatures as needed to pass the shared value rather than
keeping separate literals.
src/hooks/useBusTTSText.ts (1)

34-39: ODAKYU の TTS 解決が二重定義です。

resolveTemplateTheme()ODAKYU -> TOKYO_METRO を返すので、ここで足した APP_THEME.ODAKYU の空テンプレートは実行時に参照されません。片方に寄せておくと将来のズレを防げます。

Also applies to: 499-500, 700-700

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

In `@src/hooks/useBusTTSText.ts` around lines 34 - 39, Duplicate definition:
APP_THEME.ODAKYU is added to the theme templates but resolveTemplateTheme()
already maps ODAKYU -> TOKYO_METRO, so the added empty template is never used;
remove the redundant APP_THEME.ODAKYU entry from the theme templates (and the
other duplicated spots referenced) so the mapping is only defined in one place
(resolveTemplateTheme) or alternatively remove the remapping in
resolveTemplateTheme if you prefer the template object to be authoritative —
pick one approach and apply consistently across resolveTemplateTheme and the
template objects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/HeaderOdakyu.test.tsx`:
- Around line 117-127: Update the test that asserts what HeaderOdakyu passes to
TrainTypeBox to also check for the new ODAKYU-specific props: include
darkenColor and fontSizeScale in the expect.objectContaining passed to
toHaveBeenCalledWith for TrainTypeBox in the HeaderOdakyu test (the test that
uses createMockHeaderProps and requires './TrainTypeBox'). Ensure the assertion
verifies the expected values (or defaults) for darkenColor and fontSizeScale
alongside localTypePrefix and nextTrainTypeColor.

---

Nitpick comments:
In `@src/components/BarTerminalOdakyu.tsx`:
- Around line 14-18: Props currently declares hasTerminus but BarTerminalOdakyu
never uses it; decide one of two fixes and apply it consistently: (A) remove
hasTerminus from the Props type and any callers (or update call sites) if it is
truly unused, or (B) keep hasTerminus for backward compatibility and add a
rendering branch inside the BarTerminalOdakyu component that uses hasTerminus
(and barHighlightOffset) to toggle the terminus marker/visual state (e.g., alter
the SVG path/group when hasTerminus is true); update Prop defaults/types and any
tests/callers accordingly. Ensure you update the Props type and component render
logic (BarTerminalOdakyu) and any places that pass hasTerminus so the API
contract is clear.

In `@src/components/LineBoardEast.tsx`:
- Around line 142-143: The hard-coded 0.35 highlight value is duplicated between
barHighlightOffset, renderBarGradients(), and BarTerminalOdakyu causing
misalignment; extract this magic number into a single shared constant or prop
(e.g., HIGHLIGHT_RATIO or highlightOffset prop) and replace the literal 0.35 in
barHighlightOffset, the gradient generation in renderBarGradients, and the
highlight position used in BarTerminalOdakyu so both bar body and terminal SVG
consume the same source of truth; update function/component signatures as needed
to pass the shared value rather than keeping separate literals.

In `@src/components/TrainTypeBox.tsx`:
- Line 91: The prop/variable fontSizeScale in the TrainTypeBox component can be
<= 0 which collapses text; clamp it to a small positive minimum before use (e.g.
const safeFontSizeScale = Math.max(fontSizeScale ?? 1, 0.1)) and replace direct
uses of fontSizeScale with safeFontSizeScale; apply the same change to the other
occurrences referenced (the other fontSizeScale usages at the spots
corresponding to lines ~301-302 and ~321-322) so all calculations
(style/font-size computations) use the clamped value.

In `@src/hooks/useBusTTSText.ts`:
- Around line 34-39: Duplicate definition: APP_THEME.ODAKYU is added to the
theme templates but resolveTemplateTheme() already maps ODAKYU -> TOKYO_METRO,
so the added empty template is never used; remove the redundant APP_THEME.ODAKYU
entry from the theme templates (and the other duplicated spots referenced) so
the mapping is only defined in one place (resolveTemplateTheme) or alternatively
remove the remapping in resolveTemplateTheme if you prefer the template object
to be authoritative — pick one approach and apply consistently across
resolveTemplateTheme and the template objects.

In `@src/utils/resolveThemeForLine.test.ts`:
- Around line 124-130: Add a second test that verifies prefix matching by
calling resolveThemeForLine with makeLine({ id: 25001, company:
makeCompany('小田急電鉄') }) and asserting it returns APP_THEME.ODAKYU; this ensures
the startsWith behavior in resolveThemeForLine is locked down (add a new it
block similar to the existing '小田急の路線はODAKYUを返す' test).

In `@src/utils/themeInfo.ts`:
- Around line 67-72: Replace the Tokyo Metro placeholder screenshots used for
APP_THEME.ODAKYU by adding/committing Odakyu-specific images and updating the
spImage and tabletImage require paths (and keep descriptionKey:
'themeDescriptionOdakyu'); remove the TODO comment. Specifically, add new assets
(e.g., odakyu-sp.webp and odakyu-tablet.webp) to the assets/images/themes folder
and update the require(...) values for APP_THEME.ODAKYU's spImage and
tabletImage accordingly, then commit and, if desired, create an issue to track
adding finalized screenshots.
🪄 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: 517859ff-7288-4955-9f92-6aaac5b44790

📥 Commits

Reviewing files that changed from the base of the PR and between 8f74527 and c7815d8.

📒 Files selected for processing (23)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/BarTerminalEast.tsx
  • src/components/BarTerminalOdakyu.tsx
  • src/components/Header.tsx
  • src/components/HeaderEast/HeaderEast.tsx
  • src/components/HeaderEast/config.ts
  • src/components/HeaderOdakyu.test.tsx
  • src/components/HeaderOdakyu.tsx
  • src/components/LineBoard.tsx
  • src/components/LineBoard/shared/components/LineDot.tsx
  • src/components/LineBoardEast.tsx
  • src/components/PassChevronTY.tsx
  • src/components/TrainTypeBox.tsx
  • src/components/TransfersHeading.tsx
  • src/constants/theme.ts
  • src/hooks/useBusTTSText.ts
  • src/hooks/useTTSText.ts
  • src/models/Theme.ts
  • src/utils/resolveThemeForLine.test.ts
  • src/utils/resolveThemeForLine.ts
  • src/utils/theme.ts
  • src/utils/themeInfo.ts

Comment thread src/components/HeaderOdakyu.test.tsx
TinyKitten and others added 2 commits March 28, 2026 01:59
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

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

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

106-109: trainTypeColor memo の中間変数 base は不要です。

この変更では base 変数に代入して即座に return base しているため、冗長です。元のコードのままで問題ありません。

♻️ 簡略化の提案
 const trainTypeColor = useMemo(() => {
-  const base = trainType?.color ?? '#1f63c6';
-  return base;
+  return trainType?.color ?? '#1f63c6';
 }, [trainType]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/TrainTypeBox.tsx` around lines 106 - 109, The useMemo for
trainTypeColor unnecessarily assigns to an intermediate variable "base";
simplify the callback by returning trainType?.color ?? '#1f63c6' directly.
Update the useMemo in TrainTypeBox (the trainTypeColor constant) to remove the
redundant "base" variable and keep the dependency array as [trainType].
🤖 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/TrainTypeBox.tsx`:
- Around line 106-109: The useMemo for trainTypeColor unnecessarily assigns to
an intermediate variable "base"; simplify the callback by returning
trainType?.color ?? '#1f63c6' directly. Update the useMemo in TrainTypeBox (the
trainTypeColor constant) to remove the redundant "base" variable and keep the
dependency array as [trainType].

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75566c23-3fa1-4308-b0cf-0a57a6421dc5

📥 Commits

Reviewing files that changed from the base of the PR and between 7630768 and 0c09394.

📒 Files selected for processing (5)
  • src/components/BarTerminalOdakyu.tsx
  • src/components/HeaderOdakyu.test.tsx
  • src/components/LineBoardEast.tsx
  • src/components/TrainTypeBox.tsx
  • src/utils/resolveThemeForLine.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/resolveThemeForLine.test.ts
  • src/components/BarTerminalOdakyu.tsx

@TinyKitten TinyKitten merged commit 2ec1270 into dev Mar 27, 2026
6 checks passed
@TinyKitten TinyKitten deleted the feature/odakyu-theme branch March 27, 2026 17:10
@coderabbitai coderabbitai Bot mentioned this pull request Mar 29, 2026
10 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