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: normalized logos of sponsors #3169

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

Conversation

Wck-iipi
Copy link

@Wck-iipi Wck-iipi commented Aug 28, 2024

image
Screen Shot 2024-08-29 at 00 49 25
Screen Shot 2024-08-29 at 00 49 19

Description

  • Normalized logos of sponsors.

Related issue(s)

Fixes #3158

Summary by CodeRabbit

  • New Features

    • Introduced a new ResponsiveImage component for improved image handling across sponsor sections.
    • Replaced standard <img> tags with the ResponsiveImage component in Gold, Silver, and general Sponsors sections.
  • Bug Fixes

    • Updated data-testid attributes to dataTestId for consistency and improved testing capabilities.

Copy link

netlify bot commented Aug 28, 2024

Deploy Preview for asyncapi-website failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 9008f6c
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/670fa4da9e657d00081de58c

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.

@Wck-iipi Wck-iipi changed the title Normalized logos of sponsors fix: Normalized logos of sponsors Aug 28, 2024
@Wck-iipi Wck-iipi changed the title fix: Normalized logos of sponsors fix: normalized logos of sponsors Aug 28, 2024
@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Aug 28, 2024

⚡️ Lighthouse report for the changes in this PR:

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

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

* @param {string} props.className - Additional CSS class names for styling the image.
* @param {string} props.dataTestId - A string for identifying the element during testing.
*/
const ResponsiveImage: React.FC<ResponsiveImageProps> = ({ src, alt, className, dataTestId }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why to create separate component for Responsive images? We can add this property to component of respective category.

Copy link
Author

@Wck-iipi Wck-iipi Aug 29, 2024

Choose a reason for hiding this comment

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

HDI logo size is way too huge as compared to others, so probably we have to built a component that restricts the logo size with fixed dimension.

I thought that creating a component was required? Do you want me to do this without writing a new component or with?

components/sponsors/ResponsiveImage.tsx Outdated Show resolved Hide resolved
@Wck-iipi
Copy link
Author

@akshatnema I have made the changes can you please check this PR. Thanks.

@akshatnema
Copy link
Member

@coderabbitai summarize

Copy link

coderabbitai bot commented Oct 11, 2024

Tip

For best results, initiate chat on the files or code changes.

@akshatnema, here's the summary of the PR:

Fix: Normalized Logos of Sponsors

This pull request addresses issue #3158 by normalizing the logos of sponsors on the AsyncAPI website. The changes ensure that all sponsor logos are adjusted for consistent appearance, improving the overall look and feel of the sponsors section.

@akshatnema
Copy link
Member

@Wck-iipi Please resolve the conflicts in your PR.

@akshatnema
Copy link
Member

akshatnema commented Oct 11, 2024

@coderabbitai full review

Copy link

coderabbitai bot commented Oct 11, 2024

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes involve the introduction of a new ResponsiveImage component to standardize the rendering of sponsor logos across various components. The <img> tags in GoldSponsors.tsx, SilverSponsors.tsx, and Sponsors.tsx have been replaced with the new ResponsiveImage component, which accepts specific attributes for improved responsiveness and consistency. The data-testid attribute has been updated to dataTestId for uniformity.

Changes

File Path Change Summary
components/sponsors/GoldSponsors.tsx Introduced ResponsiveImage, replaced <img> with <ResponsiveImage> using src, alt, className, and dataTestId. Changed data-testid to dataTestId.
components/sponsors/ResponsiveImage.tsx Added ResponsiveImage component with props: src, alt, className, dataTestId. Merged Tailwind CSS classes and returned an <img> element. Added interface and default export.
components/sponsors/SilverSponsors.tsx Introduced ResponsiveImage, replaced <img> with <ResponsiveImage> using src, alt, className, and dataTestId. Changed data-testid to dataTestId. Updated method signature.
components/sponsors/Sponsors.tsx Introduced ResponsiveImage, replaced <img> with <ResponsiveImage> using src, alt, className, and dataTestId. Changed data-testid to dataTestId. Updated method signature.

Assessment against linked issues

Objective Addressed Explanation
Normalize the logos of sponsors (#3158)

🐇 In the meadow, logos shine bright,
With ResponsiveImage, all just right.
No more giants, just a neat view,
Tailwind's magic, making it new!
Hop along, sponsors, in a row,
Together we flourish, watch us grow! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fa4eae3 and 9008f6c.

📒 Files selected for processing (3)
  • components/sponsors/GoldSponsors.tsx (2 hunks)
  • components/sponsors/SilverSponsors.tsx (2 hunks)
  • components/sponsors/Sponsors.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/sponsors/GoldSponsors.tsx
  • components/sponsors/SilverSponsors.tsx
  • components/sponsors/Sponsors.tsx

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

@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 (4)
components/sponsors/ResponsiveImage.tsx (1)

19-23: Minor optimization: Simplify className application.

The component implementation looks good overall. The use of twMerge addresses the previous comment about using tailwind-merge. However, we can slightly simplify the className application.

Consider updating the img element as follows:

return <img src={src} alt={alt} className={classNameMerged} data-testid={dataTestId} />;

This removes the unnecessary template literal, as classNameMerged already contains the merged classes.

components/sponsors/GoldSponsors.tsx (1)

28-33: LGTM: ResponsiveImage component implemented correctly.

The <ResponsiveImage> component is correctly implemented, replacing the <img> tag. This change aligns with the PR objective of normalizing sponsor logos. The src, alt, className, and dataTestId props are appropriately set.

For consistency with React conventions, consider updating the data-testid attribute on the parent <a> tag to also use camelCase (dataTestId):

-            data-testid='GoldSponsors-link'
+            dataTestId='GoldSponsors-link'
components/sponsors/SilverSponsors.tsx (1)

Line range hint 17-37: LGTM: Overall implementation, with a minor suggestion for accessibility

The changes to the SilverSponsors component are well-implemented and focused on the image rendering, which aligns with the PR objective. The overall structure and functionality of the component have been preserved.

As a minor suggestion for improvement, consider adding an aria-label to the sponsor links to enhance accessibility. For example:

 <a
   key={index}
   href={sponsor.website}
   target='_blank'
   className='relative block w-2/3 p-4 text-center sm:w-1/2 md:w-1/3 lg:w-1/4'
   rel='noopener noreferrer'
   data-testid='SilverSponsors-link'
+  aria-label={`Visit ${sponsor.altText}'s website`}
 >

This change would provide more context for screen reader users.

components/sponsors/Sponsors.tsx (1)

28-32: LGTM: ResponsiveImage component implemented correctly.

The <ResponsiveImage> component is correctly implemented, replacing the <img> tag. This change aligns with the PR objectives to normalize sponsor logos. The use of dataTestId follows React naming conventions better than the previous data-testid attribute.

For consistency, consider renaming dataTestId to data-testid in the ResponsiveImage component if it's meant to be used as a DOM attribute. If it's a custom prop, the current naming is fine.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c3f18c5 and f537df6.

📒 Files selected for processing (4)
  • components/sponsors/GoldSponsors.tsx (2 hunks)
  • components/sponsors/ResponsiveImage.tsx (1 hunks)
  • components/sponsors/SilverSponsors.tsx (2 hunks)
  • components/sponsors/Sponsors.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (11)
components/sponsors/ResponsiveImage.tsx (4)

1-2: LGTM: Imports are correct and necessary.

The imports for React and twMerge are appropriate for this component.


11-18: LGTM: Component documentation is clear and comprehensive.

The documentation for the ResponsiveImage component is well-written, following JSDoc standards. It clearly describes the purpose of the component and each of its props.


25-25: LGTM: Export statement is correct.

The default export of the ResponsiveImage component is appropriate and follows standard practices for React components.


1-25: Addressing past review comments.

  1. Regarding the creation of a separate component for responsive images:
    This implementation aligns with the original issue request (normalize the logos of sponsors  #3158) to create a component that restricts logo sizes. It promotes reusability across different sponsor categories.

  2. The suggestion to use tailwind-merge has been successfully implemented in this component.

These changes effectively address the concerns raised in the previous review.

components/sponsors/GoldSponsors.tsx (2)

2-2: LGTM: ResponsiveImage import added correctly.

The import statement for the new ResponsiveImage component is correctly added and necessary for the changes in the component's render method.


28-33: Verify ResponsiveImage behavior with various logo sizes.

The implementation of the ResponsiveImage component looks good and addresses the issue of normalizing sponsor logos. However, it's important to ensure that the component handles different logo sizes correctly.

To verify the behavior, please run the following script to check for any extreme variations in logo dimensions:

This script will help identify any logos that might still be disproportionately sized compared to others.

components/sponsors/SilverSponsors.tsx (3)

1-1: LGTM: New import statement for ResponsiveImage

The addition of the ResponsiveImage import aligns with the PR objective of normalizing sponsor logos. This change suggests a move towards a more standardized approach for rendering images across the application.


Line range hint 1-37: Summary: Changes align with PR objective, with minor suggestions

The changes to the SilverSponsors component successfully implement the ResponsiveImage component, which should lead to more consistent rendering of sponsor logos as per the PR objective. The overall structure and functionality of the component have been preserved.

Next steps:

  1. Verify the impact of changing data-testid to dataTestId on existing tests.
  2. Consider implementing the suggested accessibility improvement by adding aria-label to sponsor links.
  3. If these minor issues are addressed, the changes are ready for approval and merging.

Great work on improving the consistency of sponsor logo rendering!


28-32: Approve ResponsiveImage usage, but verify dataTestId prop

The replacement of the img tag with the ResponsiveImage component is a good change that aligns with the PR objective of normalizing sponsor logos. The props are correctly passed from the sponsor object.

However, the change from data-testid to dataTestId might be a breaking change for existing tests.

Please run the following script to check if there are any occurrences of data-testid in test files that might need updating:

If the script returns any results, consider updating those occurrences to match the new dataTestId prop or ensure that the ResponsiveImage component internally converts dataTestId to data-testid for backwards compatibility.

components/sponsors/Sponsors.tsx (2)

1-1: LGTM: ResponsiveImage import added correctly.

The import statement for ResponsiveImage is correctly placed and uses a relative path, which is consistent with local component imports.


Line range hint 1-52: LGTM: Overall changes align with PR objectives.

The modifications to the Sponsors component are focused and align well with the PR objectives to normalize sponsor logos. The overall structure and functionality of the component remain intact, with the primary change being the image rendering method.

To ensure the ResponsiveImage component is implemented correctly, please run the following verification script:

This script will help verify the correct implementation and usage of the ResponsiveImage component across sponsor-related files.

✅ Verification successful

LGTM: ResponsiveImage component is correctly implemented and utilized.

The ResponsiveImage component exists, its props are properly defined, and it is consistently imported across all sponsor-related components (Sponsors.tsx, SilverSponsors.tsx, and GoldSponsors.tsx). These verifications confirm that the changes align with the PR objectives and maintain the integrity of the Sponsors component.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of ResponsiveImage component

# Test 1: Check if ResponsiveImage component exists
echo "Checking for ResponsiveImage component..."
ast-grep --lang typescript --pattern $'export default function ResponsiveImage($_) {
  $$$
}'

# Test 2: Verify ResponsiveImage props
echo "Verifying ResponsiveImage props..."
ast-grep --lang typescript --pattern $'interface ResponsiveImageProps {
  src: string;
  alt: string;
  className?: string;
  dataTestId?: string;
  $$$
}'

# Test 3: Check usage of ResponsiveImage in other sponsor-related components
echo "Checking usage of ResponsiveImage in other components..."
rg --type typescript 'import.*ResponsiveImage' components/sponsors/

Length of output: 651


Script:

#!/bin/bash
# Description: Re-verify the implementation of ResponsiveImage component with corrected rg command

# Test 1: Check if ResponsiveImage component exists
echo "Checking for ResponsiveImage component..."
ast-grep --lang typescript --pattern $'export default function ResponsiveImage($_) {
  $$$
}'

# Test 2: Verify ResponsiveImage props
echo "Verifying ResponsiveImage props..."
ast-grep --lang typescript --pattern $'interface ResponsiveImageProps {
  src: string;
  alt: string;
  className?: string;
  dataTestId?: string;
  $$$
}'

# Test 3: Check usage of ResponsiveImage in other sponsor-related components
echo "Checking usage of ResponsiveImage in other components..."
rg 'import.*ResponsiveImage' components/sponsors/ --glob '*.ts' --glob '*.tsx'

Length of output: 883

components/sponsors/ResponsiveImage.tsx Outdated Show resolved Hide resolved
@Wck-iipi
Copy link
Author

@akshatnema I have resolved the conflict and made alt a compulsory attribute for accessibility purposes. Please review this PR.

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.

normalize the logos of sponsors
3 participants