From de683e77abdff57c889b94a42765a7be3f852936 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Tue, 10 Feb 2026 19:13:53 -0800 Subject: [PATCH] Rework styling on the message path info --- frontend/src/components/PathModal.tsx | 116 ++++++++++---------------- 1 file changed, 43 insertions(+), 73 deletions(-) diff --git a/frontend/src/components/PathModal.tsx b/frontend/src/components/PathModal.tsx index 7f0b951..d3120c1 100644 --- a/frontend/src/components/PathModal.tsx +++ b/frontend/src/components/PathModal.tsx @@ -62,56 +62,52 @@ export function PathModal({ open, onClose, paths, senderInfo, contacts, config }
{/* Raw path summary */} -
+
{paths.map((p, index) => { const hops = parsePathHops(p.path); const rawPath = hops.length > 0 ? hops.join('->') : 'direct'; - return
{rawPath}
; + return ( +
+ Path {index + 1}:{' '} + {rawPath} +
+ ); })}
+ {/* Straight-line distance (sender to receiver, same for all routes) */} + {resolvedPaths.length > 0 && + isValidLocation(resolvedPaths[0].resolved.sender.lat, resolvedPaths[0].resolved.sender.lon) && + isValidLocation(resolvedPaths[0].resolved.receiver.lat, resolvedPaths[0].resolved.receiver.lon) && ( +
+ Straight-line distance: + + {formatDistance( + calculateDistance( + resolvedPaths[0].resolved.sender.lat, + resolvedPaths[0].resolved.sender.lon, + resolvedPaths[0].resolved.receiver.lat, + resolvedPaths[0].resolved.receiver.lon + )! + )} + +
+ )} + {resolvedPaths.map((pathData, index) => (
{!hasSinglePath && ( -
- Path {index + 1} — received {formatTime(pathData.received_at)} +
+ Path {index + 1}{' '} + — received {formatTime(pathData.received_at)}
)}
))} - - {/* Straight-line distance shown once for multi-path (same for all routes) */} - {!hasSinglePath && - resolvedPaths.length > 0 && - (() => { - const first = resolvedPaths[0].resolved; - if ( - isValidLocation(first.sender.lat, first.sender.lon) && - isValidLocation(first.receiver.lat, first.receiver.lon) - ) { - return ( -
- Straight-line distance: - - {formatDistance( - calculateDistance( - first.sender.lat, - first.sender.lon, - first.receiver.lat, - first.receiver.lon - )! - )} - -
- ); - } - return null; - })()}
@@ -125,11 +121,9 @@ export function PathModal({ open, onClose, paths, senderInfo, contacts, config } interface PathVisualizationProps { resolved: ResolvedPath; senderInfo: SenderInfo; - /** If true, hide the straight-line distance (shown once at container level for multi-path) */ - hideStraightLine?: boolean; } -function PathVisualization({ resolved, senderInfo, hideStraightLine }: PathVisualizationProps) { +function PathVisualization({ resolved, senderInfo }: PathVisualizationProps) { // Track previous location for each hop to calculate distances // Returns null if previous hop was ambiguous or has invalid location const getPrevLocation = (hopIndex: number): { lat: number | null; lon: number | null } | null => { @@ -205,30 +199,6 @@ function PathVisualization({ resolved, senderInfo, hideStraightLine }: PathVisua
)} - {/* Straight-line distance (when both sender and receiver have coordinates) */} - {!hideStraightLine && - isValidLocation(resolved.sender.lat, resolved.sender.lon) && - isValidLocation(resolved.receiver.lat, resolved.receiver.lon) && ( -
0 - ? 'pt-1' - : 'pt-3 mt-3 border-t border-border' - } - > - Straight-line distance: - - {formatDistance( - calculateDistance( - resolved.sender.lat, - resolved.sender.lon, - resolved.receiver.lat, - resolved.receiver.lon - )! - )} - -
- )}
); } @@ -271,9 +241,12 @@ function PathNode({ {/* Content */}
-
{label}
+
+ {label}:{' '} + {prefix} +
- {name} ({prefix}) + {name} {distance !== null && ( - {formatDistance(distance)} )} @@ -315,20 +288,21 @@ function HopNode({ hop, hopNumber, prevLocation }: HopNodeProps) { {/* Vertical line and dot column */}
-
+
{/* Content */}
-
- Hop {hopNumber} - {isAmbiguous && (ambiguous)} +
+ Hop {hopNumber}:{' '} + {hop.prefix} + {isAmbiguous && (ambiguous)}
{isUnknown ? (
- <UNKNOWN {hop.prefix}> + <UNKNOWN>
) : isAmbiguous ? (
@@ -337,10 +311,7 @@ function HopNode({ hop, hopNumber, prevLocation }: HopNodeProps) { const hasLocation = isValidLocation(contact.lat, contact.lon); return (
- {contact.name || contact.public_key.slice(0, 12)}{' '} - - ({contact.public_key.slice(0, 2).toUpperCase()}) - + {contact.name || contact.public_key.slice(0, 12)} {dist !== null && ( - {formatDistance(dist)} @@ -359,8 +330,7 @@ function HopNode({ hop, hopNumber, prevLocation }: HopNodeProps) {
) : (
- {hop.matches[0].name || hop.matches[0].public_key.slice(0, 12)}{' '} - ({hop.prefix}) + {hop.matches[0].name || hop.matches[0].public_key.slice(0, 12)} {hop.distanceFromPrev !== null && ( - {formatDistance(hop.distanceFromPrev)}