Skip to content

Badge component#191

Open
afrussel wants to merge 2 commits into
afsar-dev:mainfrom
afrussel:badges-component
Open

Badge component#191
afrussel wants to merge 2 commits into
afsar-dev:mainfrom
afrussel:badges-component

Conversation

@afrussel

@afrussel afrussel commented Jun 28, 2026

Copy link
Copy Markdown
  • Added badge component

Summary by CodeRabbit

  • New Features
    • Added a new badge UI component with configurable visual variants and optional styling via className.
    • Added a badge demo card to the components gallery for easy preview.
  • Documentation
    • Added a dedicated badge documentation page, including installation steps and supported variant options.
  • Chores
    • Registered the new badge component in the component catalog for discoverability.

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@afrussel is attempting to deploy a commit to the Mdafsar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aec4839d-e29c-4993-b896-b278dd3a2daa

📥 Commits

Reviewing files that changed from the base of the PR and between 62cb6ae and 3d9c145.

📒 Files selected for processing (3)
  • src/components/nurui/badge-demo.tsx
  • src/components/nurui/badge.tsx
  • src/content/docs/badge.mdx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/nurui/badge.tsx
  • src/content/docs/badge.mdx

📝 Walkthrough

Walkthrough

A new Badge component is added with nine visual variants. A BadgeDemo shows the variants. The badge is registered, added to ComponentsPage, and documented in badge.mdx.

Changes

Badge Component

Layer / File(s) Summary
Badge component and demo
src/components/nurui/badge.tsx, src/components/nurui/badge-demo.tsx
badgeVariants defines nine variants via cva; Badge renders a <div> with composed classes. BadgeDemo renders all variants in a flex container.
Registry and ComponentsPage integration
src/registry/components-registry.tsx, src/components/pages/components/ComponentsPage.tsx
Adds badge entry to the Index registry and inserts a Badge card with BadgeDemo into featuresComponents.
Documentation
src/content/docs/badge.mdx
Adds badge docs with a component preview, CLI/Manual installation tabs, and props/variants tables.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 A badge for each mood, in colors so bright,
default and danger, info and light,
Wrapped in a flex row, they shimmer and gleam,
Registered neatly—a component dream.
Hop hop, little badge, now live on the page! 🏷️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately matches the main change: adding a new Badge component and related docs/demo files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (2)
src/components/nurui/badge.tsx (1)

32-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider <span> instead of <div> for semantic correctness.

Badge renders as a <div>. Since badges are typically inline elements used within text or alongside other inline content, a <span> would be more semantically appropriate and avoid potential invalid HTML nesting issues (e.g., placing a <div> inside a <p>). The inline-flex display already makes it inline-level.

♻️ Proposed change
-function Badge({ className, variant, ...props }: BadgeProps) {
+function Badge({ className, variant, ...props }: BadgeProps) {
   return (
-    <div className={cn(badgeVariants({ variant }), className)} {...props} />
+    <span className={cn(badgeVariants({ variant }), className)} {...props} />
   );
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/nurui/badge.tsx` around lines 32 - 34, Update the Badge
component to use a semantic inline element instead of a block-level one: in
Badge, replace the current div returned by Badge({ className, variant, ...props
}) with a span while keeping the existing cn(badgeVariants({ variant }),
className) styling and prop passthrough. This preserves the inline-flex
behavior, improves semantic correctness, and avoids invalid nesting when Badge
is used inside text containers like p.
src/components/nurui/badge-demo.tsx (1)

6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer cn() over template string for className composition.

The project provides a cn() utility that merges clsx and tailwind-merge. Using it avoids potential class conflicts and is consistent with other components.

♻️ Proposed fix
-    <div className={`flex flex-wrap items-center justify-center gap-3 p-8 ${className || ""}`}>
+    <div className={cn("flex flex-wrap items-center justify-center gap-3 p-8", className)}>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/nurui/badge-demo.tsx` at line 6, The className composition in
the badge demo container should use the shared cn() utility instead of a
template string. Update the wrapper div in badge-demo and import/use cn() so
class merging is consistent with the rest of the components and avoids Tailwind
conflicts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/nurui/badge-demo.tsx`:
- Around line 7-14: The BadgeDemo preview is missing one of the supported badge
styles, so update the BadgeDemo component to render the full set of variants
defined by badgeVariants, including the outline Badge. Add the outline example
alongside the existing Badge variant renders so the demo matches all available
styles and use the Badge component in the same list of variant examples.

In `@src/components/nurui/badge.tsx`:
- Line 7: The Badge component’s focus ring styles are referencing a non-existent
`ring` token and won’t apply on a plain non-focusable `<div>`. Update the
`Badge` styling in `badge.tsx` to either remove the unused `focus:ring-*`
classes or replace `focus:ring-ring` with a valid Tailwind token from
`tailwind.config.ts`, and only keep focus styles if the rendered element is
actually made focusable.

In `@src/content/docs/badge.mdx`:
- Around line 49-54: The badge props documentation has an outdated and
incomplete `variant` list. Update the props table in `badge.mdx` so the
`variant` description matches the actual `badgeVariants` options used by the
Badge component, replacing `destructive` with `danger` and adding `success`,
`warning`, `info`, `light`, and `dark` alongside `default`, `secondary`, and
`outline`. Use the `variant` row and the `badgeVariants`/Badge API as the source
of truth.

---

Nitpick comments:
In `@src/components/nurui/badge-demo.tsx`:
- Line 6: The className composition in the badge demo container should use the
shared cn() utility instead of a template string. Update the wrapper div in
badge-demo and import/use cn() so class merging is consistent with the rest of
the components and avoids Tailwind conflicts.

In `@src/components/nurui/badge.tsx`:
- Around line 32-34: Update the Badge component to use a semantic inline element
instead of a block-level one: in Badge, replace the current div returned by
Badge({ className, variant, ...props }) with a span while keeping the existing
cn(badgeVariants({ variant }), className) styling and prop passthrough. This
preserves the inline-flex behavior, improves semantic correctness, and avoids
invalid nesting when Badge is used inside text containers like p.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dca10b9-38af-4b19-b1d9-7c83166ebd54

📥 Commits

Reviewing files that changed from the base of the PR and between d5730bd and 62cb6ae.

📒 Files selected for processing (5)
  • src/components/nurui/badge-demo.tsx
  • src/components/nurui/badge.tsx
  • src/components/pages/components/ComponentsPage.tsx
  • src/content/docs/badge.mdx
  • src/registry/components-registry.tsx

Comment thread src/components/nurui/badge-demo.tsx
Comment thread src/components/nurui/badge.tsx Outdated
Comment thread src/content/docs/badge.mdx Outdated
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.

1 participant