Skip to content

Commit 27f7cbd

Browse files
TinyKittenclaude
andauthored
PadArchで直通先路線の色が隣接駅から継承されない不具合を修正 (#5345)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9bee012 commit 27f7cbd

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/components/PadArch.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,30 @@ const computeColorSegments = (
6969
}
7070

7171
// station.lines と trainType.lines の路線IDを照合して色を決定
72-
const stationColors = stations.map((s) => {
73-
if (!s) return fallbackColor;
72+
// マッチしない駅は null にして隣接する確定色で埋める
73+
const resolvedColors: (string | null)[] = stations.map((s) => {
74+
if (!s) return null;
7475

7576
for (const ttLine of trainTypeLines) {
7677
if (s.lines?.some((sl) => sl.id === ttLine.id)) {
77-
return ttLine.color ?? fallbackColor;
78+
return ttLine.color ?? null;
7879
}
7980
}
8081

81-
return s.line?.color ?? fallbackColor;
82+
// trainTypeLinesが空なら駅固有の色を使用
83+
return trainTypeLines.length > 0 ? null : (s.line?.color ?? null);
8284
});
8385

86+
// null を隣接する確定色で埋める(前方 → 後方の順)
87+
for (let i = 1; i < resolvedColors.length; i++) {
88+
if (resolvedColors[i] === null) resolvedColors[i] = resolvedColors[i - 1];
89+
}
90+
for (let i = resolvedColors.length - 2; i >= 0; i--) {
91+
if (resolvedColors[i] === null) resolvedColors[i] = resolvedColors[i + 1];
92+
}
93+
94+
const stationColors = resolvedColors.map((c) => c ?? fallbackColor);
95+
8496
// 駅のドットy座標(スクリーン座標)
8597
const dotYs = stations.map((_, i) =>
8698
i === 0 ? height / 30 : (i * height) / 7

0 commit comments

Comments
 (0)