A11y/add aria labels calculators - #934
Open
thatperplextion wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves client-side UX and accessibility by adding calculator input validation and ARIA attributes, while also standardizing some utilities with clearer JSDoc and replacing blocking alert() error handling with toast notifications.
Changes:
- Added validation + ARIA attributes (including button labels) to BMI and calorie calculators.
- Replaced
alert()calls with a Toast-based notification flow on multiple pages. - Added/expanded JSDoc comments in several utility modules and removed exercise-page debug logging.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/components/CalorieCalculator.jsx | Adds validation + error UI and ARIA attributes for improved accessibility. |
| client/src/components/BMICalculator.jsx | Adds validation + error UI and ARIA attributes; updates calculation flow. |
| client/src/pages/ProductPage.jsx | Replaces alert() error handling with Toast notifications. |
| client/src/pages/HomePage.jsx | Replaces alert() error handling with Toast notifications. |
| client/src/pages/NotesPage.jsx | Replaces empty-title alert() with Toast notification. |
| client/src/pages/ExercisePage.jsx | Removes client-side debug logging and warning noise. |
| client/src/utils/rewardsUtils.js | Adds JSDoc documentation to existing rewards utilities. |
| client/src/utils/normalizeProduct.js | Adds JSDoc documentation to product normalization helper. |
| client/src/utils/getAuthHeaders.js | Adds JSDoc documentation to auth header helper. |
| client/src/utils/formatters.js | Adds JSDoc documentation to the INR currency formatter. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+38
to
+50
| // Validation with reasonable bounds | ||
| if (!w || w < 20 || w > 300) { | ||
| setError("Please enter a valid weight between 20kg and 300kg."); | ||
| return; | ||
| } | ||
| if (!h || h < 50 || h > 250) { | ||
| setError("Please enter a valid height between 50cm and 250cm."); | ||
| return; | ||
| } | ||
| if (!a || a < 10 || a > 100) { | ||
| setError("Please enter a valid age between 10 and 100 years."); | ||
| return; | ||
| } |
| > | ||
| <form onSubmit={handleCalculate} className="space-y-6 sm:space-y-8"> | ||
| {error && ( | ||
| <div className="bg-red-50 border border-red-100 text-red-600 px-4 py-3 rounded-lg text-sm"> |
| > | ||
| <form onSubmit={handleCalculate} className="space-y-6 sm:space-y-8"> | ||
| {error && ( | ||
| <div className="bg-red-50 border border-red-100 text-red-600 px-4 py-3 rounded-lg text-sm"> |
| const navigate = useNavigate(); | ||
|
|
||
| const [product, setProduct] = useState(null); | ||
| const [toast, setToast] = useState({ message: '', type: 'success', visible: false }); |
Comment on lines
+147
to
+148
| setToast({ message: err.message || 'Failed to add to cart', type: 'error', visible: true }); | ||
| setTimeout(() => setToast(prev => ({ ...prev, visible: false })), 3000); |
Comment on lines
+283
to
+284
| setToast({ message: err.message || 'Failed to add to cart', type: 'error', visible: true }); | ||
| setTimeout(() => setToast(prev => ({ ...prev, visible: false })), 3000); |
| * Returns authentication headers for API requests. | ||
| * In development mode, prefers a local dev token if present. | ||
| * Otherwise, uses Firebase authentication token if user is logged in. | ||
| * @returns {Promise<{Content-Type: string, Authorization?: string}>} Headers object with optional Bearer token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 What does this PR do?
A clear summary of the changes made.
🔗 Related Issue
Closes #
🧪 How was this tested?
Describe how you tested your changes (manual steps, screenshots, etc.)
📸 Screenshots (if UI changes)
Before / After screenshots if you changed any UI.
✅ Checklist