A TypeScript library implementation of a Football World Cup Score Board that allows starting games, updating scores, finishing games, and getting a summary of games by total score. The library is framework-agnostic and comes with a React-based demo application showcasing its usage.
- Frontend Framework: React 18
- Language: TypeScript
- Styling: TailwindCSS
- Testing:
- Vitest
- React Testing Library
- Jest DOM
- UI Components:
- Radix UI (Tabs, Slots)
- Shadcn/ui (Cards, Buttons, Inputs)
- Build Tool: Vite
- Package Manager: npm/yarn
src/
├── lib/ # Core business logic
│ ├── ScoreBoard.ts # Main scoreboard logic class
│ ├── ScoreBoard.test.ts # Tests for scoreboard logic
│ ├── types.ts # Type definitions
│ └── utils.ts # Utility functions
│
├── components/
│ ├── ui/ # Reusable UI components
│ │ ├── button.tsx
│ │ ├── input.tsx
│ │ ├── card.tsx
│ │ └── tabs.tsx
│ └── ScoreBoard/
│ ├── index.tsx # Main ScoreBoard component
│ ├── ScoreBoard.test.tsx # Component tests
│ ├── LiveGameCard.tsx
│ ├── SummaryGameCard.tsx
│ ├── useScoreBoard.ts
│ ├── StartGameForm.tsx
│ └── ScoreBoardTitle.tsx
│
└── App.tsx # Root component
The application follows a clear separation of concerns:
- Manages the game state
- Handles game operations (start, update, finish)
- Maintains score tracking
- Provides sorting and filtering capabilities
- Presents the scoreboard interface
- Manages user interactions
- Handles real-time updates
- Provides tab navigation between live games and summary
- Start new games with initial 0-0 score
- Update scores for live games
- Finish games
- View live games
- View summary of finished games sorted by total score
- Responsive design
- Accessible UI components
- Install dependencies:
npm install
- Start the development server:
npm run dev
- Run tests:
npm run test
The project includes comprehensive tests for both:
- Business logic (ScoreBoard class)
- UI components (React Testing Library)
The application is built with accessibility in mind:
- ARIA labels
- Keyboard navigation
- Screen reader support
- Semantic HTML
The project uses:
- TypeScript with strict mode
- ESLint for code quality
- Prettier for code formatting
- Vite for fast development and building
- Path aliases (@/) for clean imports