'use client'; import * as React from 'react'; import { cn } from '@/lib/utils/cn'; export interface InputLevelMeterProps { level: number; // 0.0 to 1.0 orientation?: 'horizontal' | 'vertical'; className?: string; } export function InputLevelMeter({ level, orientation = 'horizontal', className, }: InputLevelMeterProps) { // Clamp level between 0 and 1 const clampedLevel = Math.max(0, Math.min(1, level)); // Calculate color based on level const getColor = (level: number): string => { if (level > 0.9) return 'bg-red-500'; if (level > 0.7) return 'bg-yellow-500'; return 'bg-green-500'; }; const isHorizontal = orientation === 'horizontal'; return (
{/* Level bar */}
{/* Clip indicator (at 90%) */} {clampedLevel > 0.9 && (
)} {/* Tick marks */}
{[0.25, 0.5, 0.75].map((tick) => (
))}
); }