Skip to main content

UI Components

This document captures the public contract for reusable UI components that own app-level state, socket behavior, or core UI flows.


HeaderSimplesrc/components/Navbar.tsx

Top navigation bar with a brand, optional spectator label, and avatar button that opens the side panel.

Props (HeaderProps)

PropTypeDescription
linksstring[]Nav link labels. links[0] is the initial active link. Must not be empty.
titlestring | undefinedDisplayed on the left side of the header (split by `
isSpectatorboolean?When true, shows a (Spectating) label.

Behavior

  • Clicking a link prevents navigation and only updates the visual active state.
  • Avatar button opens SidePanel.

SidePanelsrc/components/sidebar/SidePanel.tsx

Right-side drawer that hosts PartyBox.

PropTypeDescription
openedbooleanDrawer open state.
onClose() => voidClose handler.

PartyBoxsrc/components/sidebar/PartyBox.tsx

Wraps party slots, friend list, and invite list. Uses PartyContext and FriendshipContext.

Behavior

  • Renders PartySlots and tabbed friend/invite lists.
  • Provides a sign-out button that calls authClient.signOut() and redirects to /login.

PartySlotssrc/components/sidebar/PartySlots.tsx

Visual party roster + join-by-code flow.

Behavior

  • Owner view can copy/reset party code and kick guests.
  • Guest view can leave the party.
  • Join-by-code emits partyJoinByCode and waits for partyJoined.
  • Emits partyKick/partyLeave for owner/guest actions.

FriendsTabsrc/components/sidebar/FriendsTab.tsx

Friend roster with invite and delete actions.

Behavior

  • Emits partyInvite to invite online friends (disabled if party full/offline).
  • Emits friendDelete and updates local list.
  • Sorted by presence (online -> away -> offline).

InvitesTabsrc/components/sidebar/InvitesTab.tsx

Pending party invites + friend requests.

Behavior

  • Emits partyInviteAccept/partyInviteDecline and clears pending state.
  • Emits friendRequestAccept/friendRequestDecline and clears friend request state.

AddFriendBoxsrc/components/sidebar/AddFriendBox.tsx

Friend request input with copy/reset friend code support.

Behavior

  • Emits friendRequest and waits for friendRequestSent.
  • Uses /api/friends PUT to rotate the friend code.

Matchmaking and home

FindLobbySectionsrc/components/home/FindLobbySection.tsx

Matchmaking queue UI. Drives queue state using MatchmakingContext + PartyContext.

Behavior

  • Emits updateQueueSelection (party sync), joinQueue, and leaveQueue.
  • Displays queue status and match found state.

DifficultySectionsrc/components/home/DifficultySection.tsx

Instant room creation UI.

Behavior

  • Calls /api/rooms/create via useCreateRoom.
  • Emits sendGameWithParty when a party guest should be joined to the new room.

JoinGameSectionsrc/components/home/JoinGameSection.tsx

Join-by-ID input. Redirects to /game/[gameID] without validation beyond non-empty.


Home sections — src/components/home/*

HeroSection, HowItWorksSection, LiveDemoSection, and CTASection render the marketing flow and emit PostHog events for CTA interactions.


Game room

TeamSelectsrc/components/TeamSelect.tsx

Team selection UI for the game room.

PropTypeDescription
userIdstringCurrent user ID.
teamsTeamCount[]Team IDs + player counts.
gameRoomIdstringGame room identifier for display and join calls.
onJoined(teamId, role, playerCount) => voidCalled after /api/team/join succeeds.

ProblemBoxsrc/components/ProblemBox.tsx

Problem statement viewer with optional hide button.

PropTypeDescription
problemActiveProblem | nullProblem metadata from /api/rooms or results.
onToggleVisibility() => voidOptional callback to hide the panel.

ChatBoxsrc/components/ChatBox.tsx

Team chat panel backed by Socket.IO.

PropTypeDescription
socketSocketActive socket connection.
roomIdstringTeam room ID.
userNamestringDisplay name for outbound messages.
isSpectatorboolean?Disables sending when true.
roleRole | nullOptional analytics tag.

Behavior

  • Emits requestChatSync on mount.
  • Listens for receiveChatHistory and receiveChat.
  • Emits sendChat for outbound messages and mirrors them locally for instant UI updates.

GameTimersrc/components/GameTimer.tsx

Countdown timer for the match. Exposes getTimeRemainingDisplay() via a ref for submission metadata.


RoleFlipPopupsrc/components/RoleFlipPopup.tsx

Modal shown while the game is in FLIPPING state.


GameTestCasesrc/components/gameTests/GameTestCase.tsx

Single test case editor for testers.

Behavior

  • Emits submitTestCases for single-case runs.
  • Uses computedOutput to display executor results.

NewParameterButtonsrc/components/gameTests/NewParameterButton.tsx

Popover form for creating new input parameters.


Results

AnalysisBoxsrc/components/Analysisbox.tsx

Side-by-side code and runtime metrics from results API.


TestCaseResultsBoxsrc/components/TestCaseResultsBox.tsx

Tabular test results viewer for scoring tests and game-made tests. Computes pass/fail by parsing output types and can report a summary via onSummaryChange.