Skip to content

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

Merged
merged 2 commits into from
May 15, 2025
Merged

Conversation

Sharqiewicz
Copy link
Member

No description provided.

@Sharqiewicz Sharqiewicz requested review from a team and Copilot May 15, 2025 14:01
Copy link

netlify bot commented May 15, 2025

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 12a6515
🔍 Latest deploy log https://app.netlify.com/projects/pendulum-pay/deploys/6825f3cc4cf32600085b9575
😎 Deploy Preview https://deploy-preview-646--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@Copilot Copilot AI left a 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 dedicated languageSelectorDisabled 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
Copy link
Preview

Copilot AI May 15, 2025

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
Copy link
Preview

Copilot AI May 15, 2025

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.

Suggested change
// 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.

Copy link
Member

@ebma ebma left a 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 🚀

@Sharqiewicz Sharqiewicz merged commit 9fe2b61 into staging May 15, 2025
5 checks passed
@ebma ebma deleted the feat/language-selector branch May 15, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants