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

feat(badge): add bordered badge #100

Merged
merged 2 commits into from
Dec 19, 2024
Merged

feat(badge): add bordered badge #100

merged 2 commits into from
Dec 19, 2024

Conversation

MGREMY
Copy link
Collaborator

@MGREMY MGREMY commented Dec 19, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Docs have been added/updated (for bug fixes/features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • CI-related changes
  • Documentation content changes
  • Other... Please describe:

Issue Number

Issue Number: #90

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced bordered badges with multiple color options: primary, blue, red, green, yellow, indigo, purple, and pink.
    • Added a new section in documentation for bordered badges with demonstration.
  • Documentation

    • Updated documentation to include details about the new bordered badge component.

@MGREMY MGREMY linked an issue Dec 19, 2024 that may be closed by this pull request
Copy link

vercel bot commented Dec 19, 2024

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

Name Status Preview Comments Updated (UTC)
flowbite-angular ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 19, 2024 10:34am

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

Walkthrough

This pull request introduces a new bordered badge feature for the Flowbite Angular library. The implementation adds a hasBorder property to the badge component, allowing developers to create badges with borders in various color variants. The changes span multiple files, including documentation, component definition, and theme configuration, to fully support the new bordered badge functionality.

Changes

File Change Summary
apps/docs/docs/components/badge/_bordered.component.html Added multiple <flowbite-badge> instances with [hasBorder]="true" and different color options
apps/docs/docs/components/badge/_bordered.component.ts Created new FlowbiteBorderedComponent with badge demonstration
apps/docs/docs/components/badge/index.md Added "Bordered badge" section in documentation
apps/docs/docs/components/badge/ng-doc.page.ts Imported and added FlowbiteBorderedComponent to demos
libs/flowbite-angular/badge/badge.component.ts Added hasBorder property and injection token
libs/flowbite-angular/badge/badge.theme.service.ts Updated theme service to support border styling
libs/flowbite-angular/badge/badge.theme.ts Extended badge theme to include border-related properties and styles
apps/docs/docs/components/badge/_default.component.ts Corrected CSS class spacing in the host property
apps/docs/docs/components/badge/_icon-only.component.ts Corrected CSS class spacing in the host property
apps/docs/docs/components/badge/_icon.component.ts Corrected CSS class spacing in the host property
apps/docs/docs/components/badge/_large.component.ts Corrected CSS class spacing in the host property
apps/docs/docs/components/badge/_link.component.ts Corrected CSS class spacing in the host property

Possibly related issues

Possibly related PRs

Poem

🐰 A Badge with Border, Crisp and Bright
Hopping through colors, a delightful sight
From blue to pink, with edges so clean
A rabbit's design, a developer's dream
Bordered badges, now here to stay! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4cf8b7 and adfebeb.

📒 Files selected for processing (6)
  • apps/docs/docs/components/badge/_bordered.component.ts (1 hunks)
  • apps/docs/docs/components/badge/_default.component.ts (1 hunks)
  • apps/docs/docs/components/badge/_icon-only.component.ts (1 hunks)
  • apps/docs/docs/components/badge/_icon.component.ts (1 hunks)
  • apps/docs/docs/components/badge/_large.component.ts (1 hunks)
  • apps/docs/docs/components/badge/_link.component.ts (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • apps/docs/docs/components/badge/_large.component.ts
  • apps/docs/docs/components/badge/_default.component.ts
  • apps/docs/docs/components/badge/_link.component.ts
  • apps/docs/docs/components/badge/_icon-only.component.ts
  • apps/docs/docs/components/badge/_icon.component.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/docs/docs/components/badge/_bordered.component.ts

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.

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
Contributor

@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: 3

🧹 Nitpick comments (6)
apps/docs/docs/components/badge/_bordered.component.ts (1)

1-13: Add unit tests for the bordered badge component

The PR description indicates that tests are missing. Consider adding unit tests to verify:

  • Component creation
  • Host class application
  • Template rendering with different badge variants

Would you like me to help generate the unit test suite for this component?

libs/flowbite-angular/badge/badge.theme.ts (1)

67-79: Consider dark mode border color consistency

The border colors in dark mode might need adjustment. Currently, some components use darker borders in dark mode (e.g., primary uses border-primary-800), while others use lighter borders (e.g., blue uses border-blue-800). This could lead to inconsistent visual hierarchy.

Consider standardizing the dark mode border colors across all variants. For example:

-'bg-blue-100 dark:bg-blue-200 text-blue-800 dark:text-blue-800 group-hover:bg-blue-200 dark:group-hover:bg-blue-300 border-blue-300 dark:border-blue-800'
+'bg-blue-100 dark:bg-blue-200 text-blue-800 dark:text-blue-800 group-hover:bg-blue-200 dark:group-hover:bg-blue-300 border-blue-300 dark:border-blue-400'
apps/docs/docs/components/badge/index.md (1)

29-39: Add code examples to the documentation

While the demo component is referenced correctly, the documentation would be more helpful with actual code examples showing how to use the bordered badge, similar to other sections.

Consider adding usage examples:

## Bordered badge

Use the `[hasBorder]="true"` property to add a border to your badge:

```angular-html
<flowbite-badge [hasBorder]="true" color="primary">Primary bordered badge</flowbite-badge>
<flowbite-badge [hasBorder]="true" color="dark">Dark bordered badge</flowbite-badge>

</blockquote></details>
<details>
<summary>libs/flowbite-angular/badge/badge.component.ts (3)</summary><blockquote>

`47-50`: **Consider documenting the default value in a code comment.**

The provider registration is correct, but adding a comment explaining why false is chosen as the default would improve maintainability.

```diff
 {
+  // Default to false for backward compatibility with existing badges
   provide: FLOWBITE_BADGE_HAS_BORDER_DEFAULT_VALUE,
   useValue: false,
 },

96-99: Enhance property documentation to match other properties.

The documentation should include the @default annotation and a more detailed description, consistent with other properties in the file.

 /**
- * Set if the badge has border
+ * Controls whether the badge displays with a border.
+ * When true, applies a border style based on the current color theme.
+ *
+ * @default false
  */
 public hasBorder = model(inject(FLOWBITE_BADGE_HAS_BORDER_DEFAULT_VALUE));

128-128: Implementation looks good, but tests are needed.

The theme class integration is correct, but test coverage should be added for the new hasBorder property and its integration with the theme service.

Would you like me to help create test cases for:

  • Default value injection
  • hasBorder property binding
  • Theme class generation with hasBorder
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c58cfe and c4cf8b7.

📒 Files selected for processing (7)
  • apps/docs/docs/components/badge/_bordered.component.html (1 hunks)
  • apps/docs/docs/components/badge/_bordered.component.ts (1 hunks)
  • apps/docs/docs/components/badge/index.md (1 hunks)
  • apps/docs/docs/components/badge/ng-doc.page.ts (2 hunks)
  • libs/flowbite-angular/badge/badge.component.ts (4 hunks)
  • libs/flowbite-angular/badge/badge.theme.service.ts (1 hunks)
  • libs/flowbite-angular/badge/badge.theme.ts (3 hunks)
🔇 Additional comments (6)
apps/docs/docs/components/badge/ng-doc.page.ts (1)

2-2: LGTM!

The bordered badge demo is properly integrated into the documentation page configuration.

Also applies to: 23-23

libs/flowbite-angular/badge/badge.theme.ts (2)

36-36: LGTM: Interface changes are well-defined

The hasBorder property is correctly typed as keyof FlowbiteBoolean in both interfaces, maintaining type safety and consistency with the existing pattern.

Also applies to: 50-50


81-83: LGTM: Border configuration is simple and effective

The boolean toggle between border and border-0 classes is clean and follows Tailwind conventions.

libs/flowbite-angular/badge/badge.theme.service.ts (1)

34-34: LGTM: Theme service implementation is correct

The hasBorder property is correctly integrated into the class merging logic, maintaining consistency with other theme properties.

libs/flowbite-angular/badge/badge.component.ts (2)

22-24: LGTM! Token declaration follows best practices.

The injection token is well-named, properly typed, and consistent with the existing pattern.


Line range hint 1-137: Verify theme configuration for bordered badge.

Let's ensure the theme configuration includes the necessary styles for bordered badges.

✅ Verification successful

Theme configuration for bordered badge is properly implemented

The badge theme configuration includes all necessary styles for bordered badges:

  • Border styles are defined for all color variants
  • hasBorder property is properly configured with enabled/disabled states
  • Theme service correctly applies the border classes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if badge theme configuration includes border styles

# Search for border-related styles in badge theme files
rg -l "border" libs/flowbite-angular/badge/badge.theme.ts

# Check badge theme interface for border properties
ast-grep --pattern 'interface BadgeProperties {
  $$$
  hasBorder: $_
  $$$
}'

Length of output: 861


Script:

#!/bin/bash
# Let's check the actual theme implementation for border styles
rg -A 5 "border" libs/flowbite-angular/badge/badge.theme.ts

# Also check the theme service implementation
rg -A 5 "hasBorder" libs/flowbite-angular/badge/badge.theme.service.ts

Length of output: 2150

@MGREMY MGREMY merged commit 8a07b30 into main Dec 19, 2024
5 checks passed
@MGREMY MGREMY deleted the 90-feature-badge-bordered branch December 19, 2024 10:37
@MGREMY MGREMY restored the 90-feature-badge-bordered branch December 19, 2024 10:37
@MGREMY MGREMY deleted the 90-feature-badge-bordered branch December 19, 2024 10:38
@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2024
11 tasks
@MGREMY
Copy link
Collaborator Author

MGREMY commented Dec 19, 2024

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] {Badge} - Bordered
1 participant