mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 20:21:22 +00:00
.github
.vscode
app
components
breadcrumb
cart
engine-sizes
filters
form
grid
home-page
icons
layout
manufacturers-grid
models
orders
page
product
profile
transmission-codes
ui
badge.tsx
button.tsx
card.tsx
heading.tsx
index.ts
input.tsx
label.tsx
skeleton.tsx
text.tsx
banner.tsx
display-tabs.tsx
divider.tsx
faq.tsx
hero-icon.tsx
hero.tsx
loading-dots.tsx
logo-square.tsx
opengraph-image.tsx
price.tsx
prose.tsx
side-dialog.tsx
spinner.tsx
tag.tsx
tooltip.tsx
contexts
fonts
hooks
lib
public
.env.example
.eslintrc.js
.gitignore
.nvmrc
.prettierignore
README.md
license.md
middleware.ts
next.config.js
package.json
pnpm-lock.yaml
postcss.config.js
prettier.config.js
tailwind.config.js
tsconfig.json
36 lines
851 B
TypeScript
36 lines
851 B
TypeScript
import React from 'react';
|
|
|
|
import { VariantProps, tv } from 'tailwind-variants';
|
|
|
|
const badgeStyles = tv({
|
|
base: [
|
|
'absolute -right-2 -top-2 h-5 w-5',
|
|
'flex items-center justify-center rounded-full text-xs font-semibold'
|
|
],
|
|
variants: {
|
|
color: {
|
|
primary: 'bg-primary text-white',
|
|
secondary: 'bg-secondary text-white',
|
|
content: 'bg-content text-white'
|
|
}
|
|
},
|
|
defaultVariants: {
|
|
color: 'content'
|
|
}
|
|
});
|
|
|
|
export interface BadgeProps extends VariantProps<typeof badgeStyles> {
|
|
content: string | number;
|
|
className?: string;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default function Badge({ className, color, children, content }: BadgeProps) {
|
|
return (
|
|
<span className="relative flex-none">
|
|
{children}
|
|
<span className={badgeStyles({ color, className })}>{content}</span>
|
|
</span>
|
|
);
|
|
}
|