Skip to content
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
4 changes: 3 additions & 1 deletion src/components/MdxComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { QuickLink, QuickLinks } from './mdx/QuickLinks';
import { Tab, Tabs } from './mdx/Tabs';
import { PreCodeBlock } from './PreCodeBlock';
import ResourceEstimator from './resource-estimator/ResourceEstimator';
import { Badge } from './ui/badge';

const MdxComponents = (version?: string) => {
return {
Expand Down Expand Up @@ -62,7 +63,8 @@ const MdxComponents = (version?: string) => {
<div {...props} className="table-auto w-full overflow-x-auto">
<table>{props.children}</table>
</div>
)
),
Badge
};
};

Expand Down
60 changes: 60 additions & 0 deletions src/components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";

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

const badgeVariants = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
);

export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {
backgroundColor?: string;
textColor?: string;
textSize?: "text-xs" | "text-sm" | "text-base" | "text-lg" | "text-xl" | "text-2xl";
}

function Badge({
className,
variant,
backgroundColor,
textColor,
textSize = "text-xs",
...props
}: BadgeProps) {
return (
<div
className={cn(
badgeVariants({ variant }),
className,
backgroundColor,
textColor,
textSize
)}
style={{
backgroundColor: backgroundColor,
color: textColor,
}}
{...props}
/>
);
}

export { Badge, badgeVariants };
Loading