-
Notifications
You must be signed in to change notification settings - Fork 2
Add LanguageSelector in the navbar #646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for pendulum-pay ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new language selector to the navbar, enabling users to switch between English and Portuguese and have the URL update accordingly.
- Imports and renders
LanguageSelector
alongside existing controls in the navbar. - Introduces a
LanguageSelector
component with dropdown UI, click-outside hook, and path-updating logic. - Adds helper functions (
useClickOutside
,updatePathWithLanguage
) and flag assets.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
frontend/src/components/Navbar/index.tsx | Imported and rendered LanguageSelector with disabled prop |
frontend/src/components/LanguageSelector/index.tsx | Added new LanguageSelector component and associated helpers |
Comments suppressed due to low confidence (2)
frontend/src/components/Navbar/index.tsx:31
- [nitpick] The prop name
networkSelectorDisabled
is specific to network selection. Consider renaming it to a more generic name (e.g.,selectorDisabled
) or introducing a dedicatedlanguageSelectorDisabled
prop to clarify its purpose.
<LanguageSelector disabled={networkSelectorDisabled} />
frontend/src/components/LanguageSelector/index.tsx:111
- There are currently no tests covering
LanguageSelector
behavior (open/close, language switching, URL update). Consider adding unit or integration tests for these scenarios.
export const LanguageSelector = ({ disabled }: { disabled?: boolean }) => {
} | ||
|
||
const LanguageButton = ({ selectedLanguage, isOpen, onClick, disabled }: LanguageButtonProps) => ( | ||
<motion.button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding ARIA attributes (e.g., aria-haspopup='menu'
, aria-expanded
) and keyboard event handling (Enter/Space to toggle, arrow keys to navigate) to improve the dropdown’s accessibility.
Copilot uses AI. Check for mistakes.
}, [callback, ref]); | ||
} | ||
|
||
// Helper function to update path with language |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a JSDoc comment explaining how updatePathWithLanguage
detects existing language segments and replaces or prepends them, to aid future maintainers in understanding the logic.
// Helper function to update path with language | |
/** | |
* Updates the given path to include the specified language segment. | |
* | |
* This function checks if the path already contains a language segment | |
* (e.g., "/en" or "/pt-br"). If a language segment is found, it replaces | |
* it with the new language. If no language segment is found, it prepends | |
* the new language segment to the path. | |
* | |
* @param {string} path - The URL path to update. | |
* @param {Language} language - The language to include in the path. | |
* @returns {string} - The updated path with the specified language segment. | |
*/ |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, great stuff 🚀
No description provided.