Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: add variant support for customizable colors to PulsingDot component

naveenkashec8afbef8b83
diff --git a/packages/react/src/PulsingDot.tsx b/packages/react/src/PulsingDot.tsx
index c91cbd2829..6579145014 100644
--- a/packages/react/src/PulsingDot.tsx
+++ b/packages/react/src/PulsingDot.tsx
@@ -1,26 +1,58 @@
+import type { VariantProps } from "class-variance-authority";
+import { cva } from "class-variance-authority";
import type { ComponentProps } from "react";
import { cn } from "./utils/cn";
+const pulseVariants = cva("", {
+ variants: {
+ variant: {
+ amber: "text-amber-500",
+ green: "text-emerald-500",
+ yellow: "text-yellow-500",
+ orange: "text-orange-500",
+ red: "text-red-500",
+ blue: "text-blue-500",
+ gray: "text-gray-500",
+ purple: "text-violet-500"
+ }
+ },
+ defaultVariants: {
+ variant: "green"
+ }
+});
+
+type PulseVariants = VariantProps<typeof pulseVariants>;
+
export function PulsingDot({
inactive,
+ variant,
className,
...props
-}: ComponentProps<"span"> & { inactive?: boolean }) {
+}: ComponentProps<"span"> & { inactive?: boolean } & PulseVariants) {
if (inactive) {
return (
<span
- className={cn("w-2 h-2 bg-muted rounded-full bg-amber-500", className)}
+ className={cn(
+ "w-2 h-2 rounded-full bg-current",
+ pulseVariants({ variant }),
+ className
+ )}
{...props}
/>
);
}
return (
- <span className={cn("relative flex h-2 w-2", className)} {...props}>
- <span
- className={`absolute h-full w-full animate-ping rounded-full border border-amber-500 opacity-100 duration-1000`}
- />
- <span className={`h-2 w-2 rounded-full bg-amber-500`} />
+ <span
+ className={cn(
+ "relative flex h-2 w-2",
+ pulseVariants({ variant }),
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute h-full w-full animate-ping rounded-full border border-current opacity-100 duration-1000" />
+ <span className="h-2 w-2 rounded-full bg-current" />
</span>
);
}