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/add badge size #65

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.0.341](https://github.com/getpingback/ui/compare/v0.0.340...v0.0.341) (2025-02-19)


### Bug Fixes

* add size props to badge component ([cc5fe2b](https://github.com/getpingback/ui/commits/cc5fe2b5237552f85d518228aa5e8e0ddbf6f008))

### [0.0.338](https://github.com/getpingback/ui/compare/v0.0.337...v0.0.338) (2025-02-10)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@getpingback/ui",
"author": "Pingback Team",
"version": "0.0.340",
"version": "0.0.342",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
14 changes: 10 additions & 4 deletions src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cva, type VariantProps } from 'class-variance-authority';

import { cn } from '@/lib/utils';

const badgeVariants = cva('inline-flex items-center px-2.5 py-0.5 text-xs font-semibold w-fit', {
const badgeVariants = cva('inline-flex items-center px-2.5 py-0.5 font-semibold w-fit', {
variants: {
type: {
green: 'bg-badge-green text-badge-green-foreground',
Expand All @@ -24,8 +24,13 @@ const badgeVariants = cva('inline-flex items-center px-2.5 py-0.5 text-xs font-s
},
transform: {
uppercase: 'uppercase'
},
size: {
default: 'text-xs',
small: 'text-[10px] max-h-[20px]'
}
},

compoundVariants: [
{
variant: 'outline',
Expand Down Expand Up @@ -61,14 +66,15 @@ const badgeVariants = cva('inline-flex items-center px-2.5 py-0.5 text-xs font-s
defaultVariants: {
type: 'purple',
radius: 'full',
variant: 'ghost'
variant: 'ghost',
size: 'default'
}
});

export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}

function Badge({ className, variant, type, radius, transform, ...props }: BadgeProps) {
return <div className={cn(badgeVariants({ variant, type, radius, transform }), className)} {...props} />;
function Badge({ className, variant, type, radius, transform, size, ...props }: BadgeProps) {
return <div className={cn(badgeVariants({ variant, type, radius, transform, size }), className)} {...props} />;
}

export { Badge, badgeVariants };