import { useNMEA } from '../../hooks/useNMEA.js'
import { getApi } from '../../mock/index.js'
import Gauge from '../instruments/Gauge.jsx'
import Compass from '../instruments/Compass.jsx'
import WindRose from '../instruments/WindRose.jsx'
function DataRow({ label, value, unit, highlight }) {
return (
{label}
{value != null ? `${typeof value === 'number' ? value.toFixed(1) : value}` : '—'}
{unit && {unit}}
)
}
export default function InstrumentPanel() {
const nmea = useNMEA()
const isMock = import.meta.env.VITE_USE_MOCK === 'true'
let waypointInfo = null
let allWaypoints = []
if (isMock) {
const api = getApi()
const snapshot = api.signalk.getSnapshot?.()
waypointInfo = snapshot?.currentWaypoint
allWaypoints = snapshot?.waypoints || []
}
return (
{/* Gauges row */}
{/* Waypoint info box (only in mock mode) */}
{isMock && waypointInfo && (
📍 Route & Waypoints
Current:
{waypointInfo.name}
Distance:
{nmea.distanceToWaypoint?.toFixed(2) || '—'} nm
Route:
{allWaypoints.map((wp, i) => (
{i + 1}
))}
)}
{/* Data table */}
{isMock && }
)
}
const styles = {
panel: { display: 'flex', flexDirection: 'column', gap: 16 },
gauges: { display: 'flex', gap: 8, flexWrap: 'wrap', justifyContent: 'center' },
waypointBox: {
background: 'var(--surface)', borderRadius: 'var(--radius)',
border: '1px solid var(--accent)',
padding: 12,
},
waypointTitle: {
fontSize: 12, fontWeight: 700, color: 'var(--accent)',
marginBottom: 8, letterSpacing: '0.05em',
},
waypointInfo: { display: 'flex', flexDirection: 'column', gap: 6 },
waypointRow: {
display: 'flex', justifyContent: 'space-between', alignItems: 'center',
fontSize: 12, color: 'var(--text)',
},
waypointRoute: {
display: 'flex', flexDirection: 'column', gap: 6,
marginTop: 4, paddingTop: 8,
borderTop: '1px solid var(--border)',
},
routeLabel: { fontSize: 11, color: 'var(--muted)' },
waypoints: {
display: 'flex', gap: 6, flexWrap: 'wrap',
},
waypointTag: {
width: 28, height: 28,
display: 'flex', alignItems: 'center', justifyContent: 'center',
borderRadius: 4, fontSize: 11, fontWeight: 600,
transition: 'all 0.2s',
},
table: {
display: 'grid', gridTemplateColumns: '1fr 1fr',
gap: '0 24px', background: 'var(--surface)',
borderRadius: 'var(--radius)', padding: 16,
border: '1px solid var(--border)',
},
row: {
display: 'flex', justifyContent: 'space-between', alignItems: 'center',
padding: '7px 0', borderBottom: '1px solid var(--border)',
transition: 'background 0.2s',
},
label: { fontSize: 12, color: 'var(--muted)' },
value: { fontFamily: 'var(--font-mono)', fontSize: 13, color: 'var(--text)' },
unit: { color: 'var(--muted)', fontSize: 11 },
}