Progress component displays a circular progress indicator showing completion percentage. It’s used in the Menu component to visualize how many countries in each region have been visited.
Overview
The Progress component:- Renders an SVG-based circular progress ring
- Displays completion as a percentage (0-100%)
- Supports dark mode theming
- Includes accessibility attributes
- Uses memo for performance optimization
Props
Completion percentage as a decimal between 0 and 1 (e.g., 0.5 = 50%)
Component Signature
Usage Example
Visual Representation
The component renders a 20x20px circular progress indicator:How It Works
SVG Structure
The progress ring consists of two overlapping circles:- Background Circle: Gray circle showing the full ring
- Progress Circle: Orange circle that fills based on completion
Progress Calculation
The progress is displayed using SVG stroke properties:complete = 0→strokeDashoffset = 100→ 0% visiblecomplete = 0.5→strokeDashoffset = 50→ 50% visiblecomplete = 1→strokeDashoffset = 0→ 100% visible
Rotation
The SVG is rotated -90 degrees to start the progress from the top:Styling
The component uses Tailwind CSS for theming:#fd7e14 orange) is consistent with the country highlighting on the globe.
Accessibility
The component includes an accessible title that announces the completion percentage:Performance
The component is wrapped withmemo() to prevent unnecessary re-renders:
Examples
Different Completion States
In Region Headers
The Progress component is typically used in region headers within the Menu:Visual Design
- Size: 20x20 pixels (size-5 in Tailwind)
- Stroke Width: 4px
- Radius: 16 units (in 36x36 viewBox)
- Gap: Small gap between start and end due to
strokeLinecap="round"
Color Scheme
The progress color matches the primary brand color used throughout the application for visual consistency.
| Element | Light Mode | Dark Mode |
|---|---|---|
| Background | text-gray-500 | text-neutral-500 |
| Progress | text-primary (#fd7e14) | text-primary (#fd7e14) |
Dependencies
react- Core React functionality- No external libraries required (pure SVG implementation)
Source Code
Location:src/components/progress.tsx