All files / src/components/ui release-badge.tsx

100% Statements 11/11
100% Branches 17/17
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 4711x         11x             242x 242x     242x 242x   242x   241x 241x   242x                                            
const RELEASE_COLORS: Record<string, { dot: string; text: string }> = {
	alpha: { dot: "bg-amber-500", text: "text-amber-500" },
	beta: { dot: "bg-emerald-500", text: "text-emerald-500" },
};
 
const ENV_COLORS: Record<string, string> = {
	dev: "bg-amber-500",
	preview: "bg-purple-500",
	local: "bg-gray-500",
};
 
export function ReleaseBadge() {
	const releaseVersion = import.meta.env.VITE_RELEASE_VERSION || "";
	const environment = import.meta.env.VITE_ENVIRONMENT || "local";
 
	const showRelease =
		releaseVersion === "alpha" || releaseVersion === "beta";
	const showEnv = environment !== "production";
 
	if (!showRelease && !showEnv) return null;
 
	const colors = RELEASE_COLORS[releaseVersion];
	const envColor = ENV_COLORS[environment] || "bg-gray-500";
 
	return (
		<span className="inline-flex flex-wrap items-center gap-1 ml-2">
			{showRelease && colors && (
				<span
					className={`inline-flex items-center gap-1 text-[10px] font-semibold ${colors.text}`}
				>
					<span
						className={`w-1.5 h-1.5 rounded-full ${colors.dot} animate-pulse`}
					/>
					{releaseVersion}
				</span>
			)}
			{showEnv && (
				<span
					className={`text-[9px] font-bold text-white px-1.5 py-px rounded-lg uppercase tracking-wide ${envColor}`}
				>
					{environment}
				</span>
			)}
		</span>
	);
}