-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e397e95
commit 077ce8b
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { type VariantProps, cva } from "class-variance-authority"; | ||
import { cn } from "lib/cn"; | ||
import { type ElementRef, type HTMLAttributes, forwardRef } from "react"; | ||
|
||
export const badgeVariants = cva( | ||
"inline-flex items-center rounded-md px-2 transition-colors focus:outline-none focus-visible:ring-4 focus:ring-ring font-medium max-w-max gap-1.5 bg-badge-background text-badge-foreground", | ||
{ | ||
variants: { | ||
size: { | ||
sm: "text-xs h-5", | ||
md: "text-sm h-6", | ||
lg: "text-base h-8", | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: "md", | ||
}, | ||
}, | ||
); | ||
|
||
export interface BadgeProps | ||
extends HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
const Badge = forwardRef<ElementRef<"div">, BadgeProps>( | ||
({ className, size, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn(badgeVariants({ size }), className)} | ||
{...props} | ||
/> | ||
), | ||
); | ||
|
||
export { Badge }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { Badge, type BadgeProps } from "app/components/ui/Badge"; | ||
|
||
const meta: Meta<typeof Badge> = { | ||
title: "Design system/Badge", | ||
component: Badge, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Badge>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Default", | ||
size: "md", | ||
}, | ||
argTypes: { | ||
size: { | ||
type: "string", | ||
control: "select", | ||
options: ["sm", "md", "lg"] satisfies BadgeProps["size"][], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters