Skip to main content

UI Components


HeaderSimplesrc/components/Navbar.tsx

Top navigation bar. Title on left, links on right, hamburger below the xs breakpoint.

Props (HeaderProps)

PropTypeDescription
linksstring[]Nav link labels. links[0] is the initial active link. Must not be emptylinks[0] is accessed unconditionally.
titlestringDisplayed on the left side of the header.

State

FieldTypeDescription
openedbooleanWhether the mobile hamburger menu is open.
activestringCurrently highlighted link label. Init: links[0].

Behavior

  • Clicking a link calls event.preventDefault() and updates active. Navigation is not implemented — this is a visual-only state change.
  • Hamburger is visible only below the xs breakpoint.

Example

<HeaderSimple
links={["Home", "Play", "Leaderboard"]}
title="Code BattleGrounds"
/>

Subgridsrc/components/DifficultyGrid.tsx

Three-column difficulty selection grid (Easy / Medium / Hard). No props.

State

FieldTypeDescription
loadingbooleanWhen true, renders Skeleton placeholders instead of cards. Default: false. Nothing currently sets this to true — it is wired up for future async use.

Card layout

DifficultyDot colorTopics
Easygreen.6Arrays, Strings
Mediumorange.6Math, Hash Maps, Sorts
Hardred.6DSA, Trees, Graphs, Dynamic Programming

Behavior

  • Vote buttons have no onClick handler. Clicks do nothing.

Example

<Subgrid />

PartnerSearchsrc/components/PartnerSearch.tsx

Partner selection UI with a search input and a random-assignment button. No props. Both action handlers are stubs — they only log to console.log.

State

FieldTypeDescription
querystringCurrent value of the username input. Init: "".

Handlers

handleRandom(): void

console.log("Pick a random partner"). No logic implemented.

handleSearch(): void

console.log("Search partner:", query). No logic implemented.

Example

<PartnerSearch />