import { useState } from 'react'; import { ChevronLeft, ChevronRight, Search, Globe, Rocket } from 'lucide-react'; import type { CelestialBody } from '../types'; interface ProbeListProps { probes: CelestialBody[]; planets: CelestialBody[]; onBodySelect: (body: CelestialBody | null) => void; selectedBody: CelestialBody | null; onResetCamera: () => void; } export function ProbeList({ probes, planets, onBodySelect, selectedBody, onResetCamera }: ProbeListProps) { const [isCollapsed, setIsCollapsed] = useState(false); const [searchTerm, setSearchTerm] = useState(''); // Calculate distance for sorting const calculateDistance = (body: CelestialBody) => { const pos = body.positions[0]; return Math.sqrt(pos.x ** 2 + pos.y ** 2 + pos.z ** 2); }; const processBodies = (list: CelestialBody[]) => { return list .filter(b => (b.name_zh || b.name).toLowerCase().includes(searchTerm.toLowerCase()) && b.type !== 'star' // Exclude Sun from list ) .map(body => ({ body, distance: calculateDistance(body) })) .sort((a, b) => a.distance - b.distance); }; const planetList = processBodies(planets); const probeList = processBodies(probes); return (
{/* Main Content Panel */}
{/* Header & Search */}

天体导航

setSearchTerm(e.target.value)} className="w-full bg-white/5 border border-white/10 rounded-lg pl-9 pr-3 py-2 text-xs text-white placeholder-gray-500 focus:outline-none focus:border-blue-500/50 transition-colors" />
{/* List Content */}
{/* Planets Group */}
{/* text-xs -> text-[10px] */} 行星 ({planetList.length})
{planetList.map(({ body, distance }) => ( onBodySelect(body)} /> ))}
{/* Probes Group */}
{/* text-xs -> text-[10px] */} 探测器 ({probeList.length})
{probeList.map(({ body, distance }) => ( onBodySelect(body)} /> ))}
{/* Toggle Button (Attached to the side) */}
); } function BodyItem({ body, distance, isSelected, onClick }: { body: CelestialBody, distance: number, isSelected: boolean, onClick: () => void }) { const isInactive = body.is_active === false; return ( ); }