Repository navigation
列車種別ボックスをreact-native-svgで実装し直し - #5729
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
📝 WalkthroughWalkthrough3つの訓練型ボックスコンポーネント(TrainTypeBoxE231、TrainTypeBoxJL、TrainTypeBoxJO)がReact Nativeの Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/components/TrainTypeBoxE231.tsx (1)
288-321: キーの重複可能性に注意
key={s_${text}}およびkey={f_${text}}は、同じテキストが複数行に含まれる場合にキーの重複を引き起こす可能性があります。現在の使用パターン(enOverrideのheading/bodyや単一行テキスト)では問題ないと思われますが、将来の拡張を考慮するとインデックスを含めた方が安全です。♻️ 修正案
- <SvgText - key={`s_${text}`} + <SvgText + key={`s_${i}_${text}`}- <SvgText - key={`f_${text}`} + <SvgText + key={`f_${i}_${text}`}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/TrainTypeBoxE231.tsx` around lines 288 - 321, The keys for the two SvgText maps use only text (key={`s_${text}`} and key={`f_${text}`}) which can collide when identical text appears on multiple lines; update the key generation in the lines.map calls (the SvgText elements inside TrainTypeBoxE231) to include the index (i) or another unique identifier (e.g., key={`s_${i}_${text}`} and key={`f_${i}_${text}`}) so each SvgText rendered by the first and second map is guaranteed unique.src/components/TrainTypeBoxJL.tsx (1)
21-27: TrainTypeBoxJOとの共通コードの抽出を検討
BOX_HEIGHT、FONT_SIZE、SKEW_ANGLE、SKEW_SHIFT、SKEW_TRANSFORMの定数、およびfontFamily/fontWeightロジック、adjustedFontSize計算がTrainTypeBoxJOとほぼ同一です。将来のメンテナンス性向上のため、共通ユーティリティまたはカスタムフックへの抽出を検討してもよいかもしれません。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/TrainTypeBoxJL.tsx` around lines 21 - 27, TrainTypeBoxJL内のBOX_HEIGHT、FONT_SIZE、SKEW_ANGLE、SKEW_SHIFT、SKEW_TRANSFORMとfontFamily / fontWeightロジック、adjustedFontSizeの計算はTrainTypeBoxJOと重複しているので、共通のユーティリティ関数またはカスタムフック(例: useTrainTypeBoxStyles)を作成してこれらの定数と計算ロジックを移動してください; 新しい関数はデバイス判定(isTablet)を受け取りBOX_HEIGHT, FONT_SIZE, SKEW_* 値、SKEW_TRANSFORM文字列、fontFamily/fontWeight、そしてadjustedFontSizeを返すようにして、TrainTypeBoxJLとTrainTypeBoxJOからそれを呼び出すように差し替えて重複を削除してください.
🤖 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/TrainTypeBoxJL.tsx`:
- Around line 155-183: The Japanese-character branch in TrainTypeBoxJL (the
chars.map block rendering SvgText) is missing the fontFamily prop and uses
fontWeight inconsistently: add fontFamily={fontFamily} to the SvgText in the
chars branch so the LED theme font is applied (mirror TrainTypeBoxJO), and
replace the hardcoded fontWeight="bold" in the fallback branch with
fontWeight={fontWeight} so both branches use the same fontWeight variable; keep
other props (x, y, fontSize/adjustedFontSize, fill, textAnchor,
alignmentBaseline) unchanged.
In `@src/components/TrainTypeBoxJO.tsx`:
- Around line 159-186: The Japanese-characters branch inside the chars.map
rendering (SvgText instances at lines showing the chars map) omits fontFamily
and the non-Japanese branch hardcodes fontWeight="bold"; update the chars branch
to include fontFamily={fontFamily} so JFDotJiskan24h can apply, and make the
non-Japanese SvgText use the computed fontWeight variable (fontWeight) instead
of the hardcoded "bold" so both branches use consistent weight logic; keep
existing fontSize/adjustedFontSize usage and other props (x, y, fill,
textAnchor, alignmentBaseline, children).
---
Nitpick comments:
In `@src/components/TrainTypeBoxE231.tsx`:
- Around line 288-321: The keys for the two SvgText maps use only text
(key={`s_${text}`} and key={`f_${text}`}) which can collide when identical text
appears on multiple lines; update the key generation in the lines.map calls (the
SvgText elements inside TrainTypeBoxE231) to include the index (i) or another
unique identifier (e.g., key={`s_${i}_${text}`} and key={`f_${i}_${text}`}) so
each SvgText rendered by the first and second map is guaranteed unique.
In `@src/components/TrainTypeBoxJL.tsx`:
- Around line 21-27:
TrainTypeBoxJL内のBOX_HEIGHT、FONT_SIZE、SKEW_ANGLE、SKEW_SHIFT、SKEW_TRANSFORMとfontFamily
/
fontWeightロジック、adjustedFontSizeの計算はTrainTypeBoxJOと重複しているので、共通のユーティリティ関数またはカスタムフック(例:
useTrainTypeBoxStyles)を作成してこれらの定数と計算ロジックを移動してください;
新しい関数はデバイス判定(isTablet)を受け取りBOX_HEIGHT, FONT_SIZE, SKEW_*
値、SKEW_TRANSFORM文字列、fontFamily/fontWeight、そしてadjustedFontSizeを返すようにして、TrainTypeBoxJLとTrainTypeBoxJOからそれを呼び出すように差し替えて重複を削除してください.
🪄 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: 05aabb51-a64c-4778-a313-389e8c4626ba
📒 Files selected for processing (3)
src/components/TrainTypeBoxE231.tsxsrc/components/TrainTypeBoxJL.tsxsrc/components/TrainTypeBoxJO.tsx
Summary
stroke/fill2レイヤー方式に変更transform: skewX(Androidで無視される)をSVG<G transform="skewX(...)">に変更space-evenlyからSVGパーセンテージ座標に変更onLayoutベースで再実装Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
スタイル