"use client" import * as React from "react" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip" import { cn } from "../../lib/utils" export interface FeatureGateProps { /** Whether the feature is available. When false, applies mode behavior. */ enabled: boolean /** * How to render when enabled=false: * - 'disable' (default): renders children as disabled with a tooltip * - 'hide': renders nothing * - 'badge': renders children with a 'Coming soon' badge overlay */ mode?: "disable" | "hide" | "badge" /** Tooltip text shown in 'disable' mode. Defaults to 'Coming soon'. */ tooltip?: string children: React.ReactNode className?: string } /** * Gates a UI element behind a feature flag. * * Use this to wrap any button, link, or UI section that is not yet implemented. * This prevents shipping clickable elements with no handlers. * * @example * // Disable a button with a tooltip * * * * * @example * // Hide completely * * * */ export function FeatureGate({ enabled, mode = "disable", tooltip = "Coming soon", children, className, }: FeatureGateProps) { if (enabled) { return <>{children} } if (mode === "hide") { return null } if (mode === "badge") { return (
{children}
Soon
) } // mode === 'disable' (default): wrap in tooltip, disable interaction return ( {children}

{tooltip}

) }