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

Update badge component #1019

Merged
merged 3 commits into from
Jan 24, 2025
Merged

Update badge component #1019

merged 3 commits into from
Jan 24, 2025

Conversation

almsh
Copy link
Contributor

@almsh almsh commented Jan 23, 2025

Summary by CodeRabbit

Release Notes: Badge Component Update

  • New Features

    • Introduced new badge variants including faded, interactive, and interactive state variants.
    • Added size options for badges (small, medium, large).
  • Improvements

    • Enhanced badge component flexibility with more configurable styling.
    • Improved Storybook documentation for the badge component with new stories and detailed descriptions.
    • Simplified badge variant configuration.
  • Changes

    • Updated badge component across multiple website pages to use new variant and size props.
    • Replaced custom className configurations with a standardized variant system.

Copy link

vercel bot commented Jan 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 7:07pm

Copy link

coderabbitai bot commented Jan 23, 2025

📝 Walkthrough

Walkthrough

This pull request introduces comprehensive updates to the Badge component across multiple files. The changes focus on enhancing the badge's flexibility by adding new variants, size options, and interactive styles. The modifications span the component definition in ui/src/components/badge.tsx, Storybook stories, and multiple website pages that utilize the Badge component, standardizing its implementation and improving its configurability.

Changes

File Change Summary
ui/src/components/badge.tsx - Added size prop to BadgeProps interface
- Expanded badgeVariants with new interactive and size variants
- Updated Badge component to support size configuration
ui/src/stories/badge.stories.tsx - Added new Storybook stories for Badge variants
- Enhanced documentation and prop controls
- Introduced new stories showcasing component capabilities
website/.../(sections)/landing-page.tsx - Changed Badge variant from muted to interactive-muted
website/.../(sections)/our-work.tsx - Updated Badge variant from outline to interactive-outline
website/.../(components)/PartnerBadges.tsx - Refactored Badge styling with new variant and size props
website/.../(components)/PartnerHome.tsx - Replaced class-based Badge styling with variant and size props
website/.../(sections)/selection-process.tsx - Replaced custom Badge classes with size prop

Suggested Labels

website

Suggested Reviewers

  • socialincome-dev
  • mkue
  • ssandino

Possibly Related PRs


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (5)
ui/src/components/badge.tsx (1)

7-34: LGTM! Consider standardizing opacity values.

The variants are well-structured with consistent interactive states. However, opacity values vary between variants (10%, 50%, 100%).

Consider standardizing to:

-				interactive: 'border-transparent bg-primary bg-opacity-10 text-primary hover:bg-opacity-100 hover:text-white focus:ring-2 focus:ring-ring focus:ring-offset-2',
-				'interactive-accent': 'border-transparent bg-accent bg-opacity-50 text-primary hover:bg-opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2',
+				interactive: 'border-transparent bg-primary bg-opacity-20 text-primary hover:bg-opacity-100 hover:text-white focus:ring-2 focus:ring-ring focus:ring-offset-2',
+				'interactive-accent': 'border-transparent bg-accent bg-opacity-20 text-primary hover:bg-opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2',
website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerBadges.tsx (2)

Line range hint 45-59: Consider using interactive variants for consistency.

The badges inside HoverCardContent could use interactive variants for consistent behavior.

-					<Badge variant='faded' className="text-popover-foreground">
+					<Badge variant='interactive' className="text-popover-foreground">
-					<Badge variant="accent" className="bg-opacity-10 text-popover-foreground">
+					<Badge variant="interactive-accent" className="text-popover-foreground">
-					<Badge variant='secondary' className="bg-opacity-10 text-popover-foreground">
+					<Badge variant='interactive-secondary' className="text-popover-foreground">

Line range hint 105-113: TODO comment needs attention.

The TODO comment about HoverCardContent should be addressed.

Would you like me to help implement the HoverCardContent for the FundraiserBadge?

ui/src/stories/badge.stories.tsx (1)

165-168: Document icon size constraints.

Consider adding documentation about recommended icon sizes for each badge size variant.

website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/selection-process.tsx (1)

111-111: Specify badge variant explicitly.

Consider adding a variant prop to make the styling intention clear. For example:

-<Badge size="md">
+<Badge variant="default" size="md">

Also applies to: 145-145

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9fe18c and 7e2ef70.

📒 Files selected for processing (7)
  • ui/src/components/badge.tsx (1 hunks)
  • ui/src/stories/badge.stories.tsx (2 hunks)
  • website/src/app/[lang]/[region]/(website)/about-us/(sections)/landing-page.tsx (2 hunks)
  • website/src/app/[lang]/[region]/(website)/our-work/(sections)/our-work.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerBadges.tsx (4 hunks)
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerHome.tsx (2 hunks)
  • website/src/app/[lang]/[region]/(website)/transparency/recipient-selection/[currency]/(sections)/selection-process.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test website
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (9)
ui/src/components/badge.tsx (2)

38-40: LGTM! Well-typed interface.

The BadgeProps interface correctly extends HTMLAttributes and includes proper typing for the size prop.


42-43: LGTM! Clean implementation.

The Badge component implementation is concise and follows React best practices.

website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerBadges.tsx (1)

24-24: LGTM! Clean size handling.

Good use of the new size prop with conditional logic.

Also applies to: 30-34

website/src/app/[lang]/[region]/(website)/about-us/(sections)/landing-page.tsx (1)

Line range hint 30-34: LGTM! Consistent use of interactive variants.

Both badges correctly use the interactive-muted variant with consistent styling.

Also applies to: 55-59

website/src/app/[lang]/[region]/(website)/our-work/(sections)/our-work.tsx (1)

Line range hint 30-35: LGTM! Appropriate use of interactive-outline variant.

The badge correctly uses the interactive-outline variant for the video trigger.

ui/src/stories/badge.stories.tsx (3)

9-20: Well-structured argTypes configuration!

The configuration provides clear descriptions and appropriate controls for both variant and size props.


53-53: Complete the Figma design link.

The Figma link appears to be truncated. Please provide the complete URL.


Line range hint 61-150: Excellent story coverage!

The stories effectively demonstrate all badge variants, sizes, and common use cases.

website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerHome.tsx (1)

104-104: Correct implementation of the new Badge API!

The badge correctly uses the new variant and size props while maintaining the space-x-2 utility class.

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

🧹 Nitpick comments (4)
ui/src/stories/badge.stories.tsx (4)

66-66: Complete the Figma design link.

The Figma link appears to be truncated.


101-109: Consider using a more semantic className for the container.

The flex container could benefit from a more descriptive className.

-		<div className="flex flex-wrap items-center gap-4">
+		<div className="flex flex-wrap items-center gap-4 badge-sizes-demo">

140-171: Add aria-labels for better accessibility.

Consider adding aria-labels to the badge groups to improve screen reader experience.

-			<div className="flex gap-2">
+			<div className="flex gap-2" aria-label="Status indicators">

219-226: Make icon sizes dynamic based on badge size.

Currently, icons have fixed sizes. Consider adjusting icon sizes based on the badge size prop.

-				<CheckCircleIcon className="mr-1 h-4 w-4" />
+				<CheckCircleIcon className={`mr-1 ${args.size === 'lg' ? 'h-5 w-5' : args.size === 'sm' ? 'h-3 w-3' : 'h-4 w-4'}`} />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e2ef70 and 2df3321.

📒 Files selected for processing (4)
  • ui/src/components/badge.tsx (1 hunks)
  • ui/src/stories/badge.stories.tsx (2 hunks)
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerBadges.tsx (4 hunks)
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerHome.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerHome.tsx
  • website/src/app/[lang]/[region]/(website)/partners/(components)/PartnerBadges.tsx
  • ui/src/components/badge.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test website
  • GitHub Check: Prettify
🔇 Additional comments (5)
ui/src/stories/badge.stories.tsx (5)

9-32: Well-structured argTypes configuration with clear descriptions.

The configuration provides good control options for both variant and size props.


68-71: LGTM! Clean implementation of the Default story.


74-96: Good documentation and implementation of interactive variants.


Line range hint 114-129: Excellent showcase of all available variants.


237-244: Good demonstration of custom styling possibilities.

@mkue
Copy link
Contributor

mkue commented Jan 24, 2025

nice👌

@ssandino, should we update the styling of the colors on the yellow badge? Both, black on yellow and blue on yellow are imo not ideal for readability/accessibility.

@ssandino
Copy link
Member

@mkue yes, I think we can optimize various smaller elements, badges included. Would do this in a future commit (needs some playing around). Now with Storybook this becomes much easier, as we have a view of all different styles and variants.

@almsh almsh merged commit 79b50af into main Jan 24, 2025
16 checks passed
@almsh almsh deleted the almsh/update-badge-component branch January 24, 2025 08:45
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.

3 participants