TokenModal component
TheTokenModal component provides a secure interface for users to configure their GitHub Personal Access Token, which increases API rate limits from 60 to 5,000 requests per hour.
Location
Appears as a modal overlay when users click the “Token API” button in the header or the “Add token” hint banner.Props
Current token value from localStorage
Callback function to save or remove the token
Callback function to close the modal
Features
Token input with visibility toggle
Rate limit information
The modal displays a clear comparison of rate limits:- Without token: 60 req/hour
- With token: 5,000 req/hour
Direct GitHub link
read:user, public_repo) in GitHub’s token creation form.
Usage from App.jsx
Implementation details
Source:src/components/TokenModal.jsx
State management:
- Local
valuestate for the input field - Local
showstate for password visibility toggle - Trims whitespace on save
- Save: Calls
onSave(value.trim())and closes modal - Clear: Calls
onSave('')to remove token from localStorage - Cancel: Closes modal without saving changes
Icons used
Fromlucide-react:
X- Close buttonKey- Token iconEye/EyeOff- Visibility toggleExternalLink- GitHub link indicatorInfo- Information box icon