Skip to content
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

fix: #3371 visibility issue with algolia search icon in navbar #3400

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jyotishpro
Copy link

@jyotishpro jyotishpro commented Nov 16, 2024

Description
fix: #3371

  • Before:

image

  • Now:

image

Related issue(s)
-Fixes #3371

Summary by CodeRabbit

  • New Features

    • Enhanced language selection process with unique language options retrieval.
    • Improved language change handling with local storage support and refined URL construction.
    • Updated mobile navigation menu with a new search button design.
  • Style

    • Updated styling for the SearchButton component, including a new background image from an SVG icon and adjusted class names for consistency.
    • Increased clickable area for the SearchButton in the mobile navigation menu.

These changes enhance user experience by providing better language options and a visually appealing interface.

Copy link

coderabbitai bot commented Nov 16, 2024

Walkthrough

The NavBar component in NavBar.tsx has been enhanced with new functionality for language selection and improved styling. A new method, getUniqueLangs, retrieves unique language options based on the current path, while the changeLanguage function has been updated for better handling of language changes and URL generation. Additionally, styling adjustments have been made to the SearchButton component, including a new background image from an SVG icon. These modifications collectively improve user interaction and visual presentation in the navigation bar.

Changes

File Path Change Summary
components/navigation/NavBar.tsx - Added method: getUniqueLangs()
- Updated method: changeLanguage(locale: string, langPicker: boolean)
- Added variable: const loupeSvg for styling adjustments to SearchButton
components/navigation/MobileNavMenu.tsx - Added variable: const loupeSvg for SVG background in SearchButton
- Increased padding for SearchButton from p-2 to p-4

Assessment against linked issues

Objective Addressed Explanation
Algolia search icon visibility on navbar (#3371)

Possibly related PRs

  • feat: add cursor pointer on selector element #3346: This PR adds a cursor pointer to the language selector, which is directly related to the changes in the changeLanguage function in the main PR, as both involve enhancing the user interface for language selection.

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • akshatnema
  • magicmatatjahu
  • Mayaleeeee
  • asyncapi-bot-eve
  • sambhavgupta0705
  • anshgoyalevil

🐰 In the navbar, a change so bright,
Languages dance, a delightful sight.
With a search icon now bold and clear,
Hop along, all is well, have no fear!
SVG shines, and options abound,
In this lovely space, joy can be found! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Copy link

netlify bot commented Nov 16, 2024

Deploy Preview for asyncapi-website failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 117e2a2
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/6738416103cc140008a169eb

@jyotishpro
Copy link
Author

Fixes #3371

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
components/navigation/NavBar.tsx (1)

43-43: Fix code formatting issues

Several formatting issues were detected by static analysis:

  • Remove trailing spaces and extra blank lines
  • Use single quotes consistently
  • Remove unnecessary trailing commas

Apply these formatting fixes:

- "mr-2 p-3 flex items-center space-x-2 rounded-md opacity-40 text-left text-gray-400 transition duration-150 ease-in-out hover:bg-gray-100 hover:text-gray-500 focus:bg-gray-100 focus:text-gray-500 focus:outline-none"
+ 'mr-2 p-3 flex items-center space-x-2 rounded-md opacity-40 text-left text-gray-400 transition duration-150 ease-in-out hover:bg-gray-100 hover:text-gray-500 focus:bg-gray-100 focus:text-gray-500 focus:outline-none'

- "Open Search"
+ 'Open Search'

  backgroundPosition: 'center left',  // Remove trailing comma

- <IconLoupe/>  // Remove extra spaces and lines
+ <IconLoupe />

Also applies to: 240-240, 242-243, 248-248, 251-254

🧰 Tools
🪛 eslint

[error] 43-43: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 43-44: More than 1 blank line not allowed.

(no-multiple-empty-lines)


[error] 43-44: Delete ⏎··

(prettier/prettier)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 384da22 and 117e2a2.

📒 Files selected for processing (1)
  • components/navigation/NavBar.tsx (4 hunks)
🧰 Additional context used
🪛 eslint
components/navigation/NavBar.tsx

[error] 43-43: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 43-44: More than 1 blank line not allowed.

(no-multiple-empty-lines)


[error] 43-44: Delete ⏎··

(prettier/prettier)


[error] 240-240: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 240-241: Delete ⏎··········

(prettier/prettier)


[error] 242-242: Replace "mr-2·p-3·flex·items-center·space-x-2·rounded-md·opacity-40·text-left·text-gray-400·transition·duration-150·ease-in-out·hover:bg-gray-100·hover:text-gray-500·focus:bg-gray-100·focus:text-gray-500·focus:outline-none" with 'mr-2·p-3·flex·items-center·space-x-2·rounded-md·opacity-40·text-left·text-gray-400·transition·duration-150·ease-in-out·hover:bg-gray-100·hover:text-gray-500·focus:bg-gray-100·focus:text-gray-500·focus:outline-none'

(prettier/prettier)


[error] 242-242: Unexpected usage of doublequote.

(jsx-quotes)


[error] 243-243: Replace "Open·Search" with 'Open·Search'

(prettier/prettier)


[error] 243-243: Unexpected usage of doublequote.

(jsx-quotes)


[error] 248-248: Delete ,

(prettier/prettier)


[error] 248-248: Unexpected trailing comma.

(comma-dangle)


[error] 251-251: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 251-254: Replace ⏎⏎··············<IconLoupe/>⏎·············· with <IconLoupe·/>

(prettier/prettier)


[error] 252-253: More than 1 blank line not allowed.

(no-multiple-empty-lines)


[error] 254-254: Trailing spaces not allowed.

(no-trailing-spaces)

🔇 Additional comments (2)
components/navigation/NavBar.tsx (2)

149-164: LGTM: SVG definition is well-structured

The SVG definition includes proper accessibility attributes and styling parameters.


Line range hint 181-185: LGTM: Mobile search button implementation is correct

The mobile view implementation uses IconLoupe component directly with appropriate styling classes.

components/navigation/NavBar.tsx Outdated Show resolved Hide resolved
@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Nov 16, 2024

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 39
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3400--asyncapi-website.netlify.app/

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 117e2a2 and 28fed46.

📒 Files selected for processing (1)
  • components/navigation/NavBar.tsx (4 hunks)
🧰 Additional context used
🪛 eslint
components/navigation/NavBar.tsx

[error] 43-43: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 43-44: More than 1 blank line not allowed.

(no-multiple-empty-lines)


[error] 43-44: Delete ⏎··

(prettier/prettier)


[error] 240-240: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 240-241: Delete ⏎··········

(prettier/prettier)


[error] 242-242: Replace "mr-2·p-3·flex·items-center·space-x-2·rounded-md·text-left··text-gray-400·transition·duration-150·ease-in-out·hover:bg-gray-100·hover:text-gray-500·focus:bg-gray-100·focus:text-gray-500·focus:outline-none" with 'mr-2·p-3·flex·items-center·space-x-2·rounded-md·text-left··text-gray-400·transition·duration-150·ease-in-out·hover:bg-gray-100·hover:text-gray-500·focus:bg-gray-100·focus:text-gray-500·focus:outline-none'

(prettier/prettier)


[error] 242-242: Unexpected usage of doublequote.

(jsx-quotes)


[error] 243-243: Replace "Open·Search" with 'Open·Search'

(prettier/prettier)


[error] 243-243: Unexpected usage of doublequote.

(jsx-quotes)


[error] 248-248: Delete ,

(prettier/prettier)


[error] 248-248: Unexpected trailing comma.

(comma-dangle)


[error] 250-250: Trailing spaces not allowed.

(no-trailing-spaces)

🔇 Additional comments (1)
components/navigation/NavBar.tsx (1)

149-164: ⚠️ Potential issue

Remove redundant SVG icon definition

The SVG icon definition is redundant since the IconLoupe component is already imported and used. Having both a background image and the IconLoupe component creates duplicate icons.

This issue was previously identified. Please refer to the existing suggestion to simplify the search button implementation.

components/navigation/NavBar.tsx Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
components/navigation/MobileNavMenu.tsx (3)

44-59: SVG implementation looks good, with room for improvement

The SVG implementation is well-structured with proper accessibility attributes and styling. However, consider these improvements:

  1. Move the SVG to a separate file in your icons directory for better maintainability
  2. Make the size configurable through props for better responsiveness

Consider refactoring to:

- const loupeSvg = encodeURIComponent(`...`);
+ import { ReactComponent as LoupeIcon } from '../icons/loupe.svg';

72-79: Search button styling effectively addresses visibility issue

The styling changes successfully improve the search icon's visibility and usability by:

  • Increasing the clickable area with larger padding
  • Ensuring consistent icon size and positioning

Fix the trailing comma in the style object:

    backgroundImage: `url("data:image/svg+xml;charset=utf-8,${loupeSvg}")`,
    backgroundSize: '1.5rem',
    backgroundRepeat: 'no-repeat',
-   backgroundPosition: 'center left',
+   backgroundPosition: 'center left'
🧰 Tools
🪛 eslint

[error] 78-78: Delete ,

(prettier/prettier)


[error] 78-78: Unexpected trailing comma.

(comma-dangle)


81-81: Remove unnecessary whitespace

Since the search icon is now implemented as a background image, the empty line with whitespace between SearchButton tags can be removed.

  <SearchButton
    className='flex items-center space-x-2 rounded-md p-4 text-left text-gray-400 transition duration-150 ease-in-out hover:bg-gray-100 hover:text-gray-500 focus:bg-gray-100 focus:text-gray-500 focus:outline-none'
    aria-label='Open Search'
    style={{
      backgroundImage: `url("data:image/svg+xml;charset=utf-8,${loupeSvg}")`,
      backgroundSize: '1.5rem',
      backgroundRepeat: 'no-repeat',
      backgroundPosition: 'center left'
    }}
  >
-   
  </SearchButton>
🧰 Tools
🪛 eslint

[error] 81-81: Trailing spaces not allowed.

(no-trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 28fed46 and 2cadadf.

📒 Files selected for processing (1)
  • components/navigation/MobileNavMenu.tsx (2 hunks)
🧰 Additional context used
🪛 eslint
components/navigation/MobileNavMenu.tsx

[error] 78-78: Delete ,

(prettier/prettier)


[error] 78-78: Unexpected trailing comma.

(comma-dangle)


[error] 81-81: Trailing spaces not allowed.

(no-trailing-spaces)

🔇 Additional comments (1)
components/navigation/MobileNavMenu.tsx (1)

Line range hint 44-81: Implementation successfully addresses the search icon visibility issue

The changes effectively solve the visibility issue reported in #3371 by:

  1. Implementing a properly sized search icon (24x24)
  2. Ensuring good visibility through proper styling and positioning
  3. Maintaining accessibility with proper ARIA attributes
  4. Increasing the clickable area for better user interaction

The implementation aligns well with the PR objectives and maintains good accessibility standards.

Let's verify the implementation is consistent across the codebase:

✅ Verification successful

Search icon implementation is consistent across the codebase

The implementation in MobileNavMenu.tsx aligns with other search button implementations in the codebase:

  1. The search icon styling (24x24, stroke properties) matches the standard SearchIcon component
  2. The implementation is consistent with other search buttons in:
    • NavBar.tsx (desktop navigation)
    • DocsMobileMenu.tsx (docs mobile menu)
    • AlgoliaSearch.tsx (search functionality component)

All implementations maintain proper accessibility with ARIA labels and consistent styling patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar search button implementations that might need the same fix
rg -l 'SearchButton|SearchIcon' --type tsx

Length of output: 72


Script:

#!/bin/bash
# Check for similar search button implementations that might need the same fix
# Using more generic file extensions and searching for both SearchButton and search-related SVG implementations
rg -l -t ts -t tsx -t jsx -t js 'SearchButton|<svg.*search|loupe'

# Also check for any other SVG implementations with similar attributes
rg -l -t ts -t tsx -t jsx -t js 'stroke="#9CA3AF"|stroke-width="2"|stroke-linecap="round"'

Length of output: 216


Script:

#!/bin/bash
# Search for similar implementations using ripgrep without file type restrictions
rg -l 'SearchButton'
rg -l '<svg[^>]*>(.*?)</svg>' --multiline

# Find all TypeScript/JavaScript files that might contain search-related components
fd -e ts -e tsx -e js -e jsx

Length of output: 13588


Script:

#!/bin/bash
# Check the implementation of SearchButton in other components
rg -A 10 'SearchButton' components/navigation/DocsMobileMenu.tsx components/navigation/NavBar.tsx components/AlgoliaSearch.tsx

# Check for search icon implementations
rg -A 10 'SearchIcon' components/icons/SearchIcon.tsx components/icons/Loupe.tsx

Length of output: 8999

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.

[BUG] algolia search icon not visible on website navbar
2 participants