@@ -200,13 +200,43 @@ export function useCollaboration(): CollaborationContextValue | null {
200200 return useContext ( CollabCtx ) ;
201201}
202202
203+ /**
204+ * Connection status indicator component.
205+ * Shows the current collaboration connection state with a colored dot and label.
206+ */
207+ export function ConnectionStatusIndicator ( { className } : { className ?: string } ) {
208+ const ctx = useContext ( CollabCtx ) ;
209+ if ( ! ctx ) return null ;
210+
211+ const { connectionState, users } = ctx ;
212+ const stateConfig : Record < string , { color : string ; label : string } > = {
213+ connected : { color : 'bg-green-500' , label : 'Connected' } ,
214+ connecting : { color : 'bg-yellow-500 animate-pulse' , label : 'Connecting…' } ,
215+ disconnected : { color : 'bg-gray-400' , label : 'Disconnected' } ,
216+ error : { color : 'bg-red-500' , label : 'Connection error' } ,
217+ } ;
218+ const { color, label } = stateConfig [ connectionState ] ?? stateConfig . disconnected ;
219+
220+ return (
221+ < div className = { `flex items-center gap-2 text-xs ${ className ?? '' } ` } role = "status" aria-live = "polite" aria-label = { `Collaboration: ${ label } ` } >
222+ < span className = { `inline-block h-2 w-2 rounded-full ${ color } ` } />
223+ < span > { label } </ span >
224+ { connectionState === 'connected' && users . length > 1 && (
225+ < span className = "text-muted-foreground" > ({ users . length } users)</ span >
226+ ) }
227+ </ div >
228+ ) ;
229+ }
230+
203231/**
204232 * Generate a consistent color for a user ID.
205233 */
206234function generateColor ( userId : string ) : string {
207235 const colors = [
208236 '#3b82f6' , '#ef4444' , '#22c55e' , '#f59e0b' ,
209237 '#8b5cf6' , '#ec4899' , '#06b6d4' , '#f97316' ,
238+ '#14b8a6' , '#f43f5e' , '#a855f7' , '#84cc16' ,
239+ '#0ea5e9' , '#e879f9' , '#fb923c' , '#facc15' ,
210240 ] ;
211241 let hash = 0 ;
212242 for ( let i = 0 ; i < userId . length ; i ++ ) {
0 commit comments