Open History to see the last commit
1import { useGameStateContext } from "../../contexts/game-state-context"
2import "./ConnectionStatus.css"
3
4/**
5 * Shows connection status when loading or disconnected.
6 * Hidden when connected.
7 */
8export function ConnectionStatus() {
9 const { isLoading, isConnected } = useGameStateContext()
10
11 if (isConnected && !isLoading) {
12 return null
13 }
14
15 return (
16 <div className="connection-status" data-testid="connection-status">
17 {isLoading ? (
18 <div className="connection-status__loading">
19 <span className="connection-status__spinner" />
20 <span>Loading game...</span>
21 </div>
22 ) : (
23 <div className="connection-status__disconnected">
24 <span className="connection-status__dot" />
25 <span>Reconnecting...</span>
26 </div>
27 )}
28 </div>
29 )
30}