diff --git a/frontend/src/components/visualizations-new/primitives/bit-display.tsx b/frontend/src/components/visualizations-new/primitives/bit-display.tsx new file mode 100644 index 0000000..47eab67 --- /dev/null +++ b/frontend/src/components/visualizations-new/primitives/bit-display.tsx @@ -0,0 +1,84 @@ +'use client'; + +import { motion } from 'framer-motion'; +import { cn } from '@/lib/utils'; +import type { BitState } from '@/lib/visualizations/types'; + +interface BitDisplayProps { + bit: BitState; + bitWidth?: number; + showLabel?: boolean; + showDecimal?: boolean; + className?: string; +} + +const STATE_CLASSES = { + normal: 'bg-[var(--muted)] border-[var(--border)] text-[var(--foreground)]', + highlighted: 'bg-[var(--primary)]/20 border-[var(--primary)] text-[var(--primary)]', + comparing: 'bg-amber-500/20 border-amber-500 text-amber-500 shadow-[0_0_8px_rgba(245,158,11,0.4)]', + result: 'bg-green-500/20 border-green-500 text-green-500', + cancelled: 'bg-[var(--muted)]/30 border-[var(--border)]/50 text-[var(--muted-foreground)] opacity-40', +} as const; + +export function BitDisplay({ + bit, + bitWidth = 8, + showLabel = true, + showDecimal = true, + className, +}: BitDisplayProps) { + // Pad the bits string to the desired width + const paddedBits = bit.bits.padStart(bitWidth, '0'); + + return ( +