import { Lock, Crown } from "lucide-react" import { usePro } from "@/contexts/pro-context" import { cn } from "@/lib/utils" import { Badge } from "@/components/ui/badge" interface ProLockedOverlayProps { children: React.ReactNode featureName?: string description?: string /** If true, shows content with a subtle lock instead of blur overlay */ showPreview?: boolean } export function ProLockedOverlay({ children, featureName = "This feature", description = "Upgrade to Pro to unlock this feature and many more.", showPreview = true }: ProLockedOverlayProps) { const { isPro, triggerShake } = usePro() if (isPro) { return <>{children} } // New behavior: show content with click handler to trigger shake and subtle fade if (showPreview) { return (
{ // Prevent actual interaction and trigger shake e.preventDefault() e.stopPropagation() triggerShake() }} > {/* The actual content - visible with subtle fade but not interactive */}
{children}
) } // Legacy behavior with blur overlay (for backwards compatibility) return (
{/* The actual content - visible but with overlay */}
{children}
{/* Lock overlay */}

Pro Feature

{featureName} is available in the Pro version. {description}

) } /** * A smaller inline lock badge for individual form controls */ export function ProLockBadge() { const { isPro } = usePro() if (isPro) return null return ( Pro ) } /** * Wrapper for locked form controls - triggers shake on click */ interface ProLockedControlProps { children: React.ReactNode className?: string } export function ProLockedControl({ children, className }: ProLockedControlProps) { const { isPro, triggerShake } = usePro() if (isPro) { return <>{children} } return (
{ e.preventDefault() e.stopPropagation() triggerShake() }} >
{children}
) } /** * Displays a locked value (e.g., analytics numbers) as XX */ interface ProLockedValueProps { value: string | number className?: string } export function ProLockedValue({ value, className }: ProLockedValueProps) { const { isPro, triggerShake } = usePro() if (isPro) { return {value} } // Convert numbers to XX format const maskedValue = typeof value === 'number' ? 'XX' : value.toString().replace(/[0-9]/g, 'X').replace(/[a-zA-Z]/g, 'X') return ( { e.preventDefault() triggerShake() }} title="Upgrade to Pro to see this value" > {maskedValue} ) } /** * A label with Pro badge for individual Pro settings * Shows a crown Pro badge and fades the text when not Pro */ interface ProSettingLabelProps { children: React.ReactNode className?: string /** Optional: show even if user is Pro (useful for showing what's included) */ alwaysShowBadge?: boolean } export function ProSettingLabel({ children, className, alwaysShowBadge = false }: ProSettingLabelProps) { const { isPro, triggerShake } = usePro() const showBadge = alwaysShowBadge || !isPro return ( { e.preventDefault() triggerShake() } : undefined} > {children} {showBadge && ( Pro )} ) }