/** * @ai-summary Translucent guidance overlay for camera viewfinder * @ai-context Displays aspect-ratio guides for VIN (~6:1), receipt (~2:3), and documents */ import React from 'react'; import { Box, Typography } from '@mui/material'; import type { GuidanceOverlayProps, GuidanceType } from './types'; import { GUIDANCE_CONFIGS } from './types'; /** Calculate overlay dimensions based on guidance type and container */ function getOverlayStyles(type: GuidanceType): React.CSSProperties { if (type === 'none') { return { display: 'none' }; } const config = GUIDANCE_CONFIGS[type]; // For VIN (wide), use width-constrained layout // For receipt/document (tall), use height-constrained layout if (config.aspectRatio > 1) { // Wide aspect ratio (VIN) return { width: '85%', height: 'auto', aspectRatio: `${config.aspectRatio}`, maxHeight: '30%', }; } else { // Tall aspect ratio (receipt, document) return { height: '70%', width: 'auto', aspectRatio: `${config.aspectRatio}`, maxWidth: '85%', }; } } export const GuidanceOverlay: React.FC = ({ type }) => { if (type === 'none') { return null; } const config = GUIDANCE_CONFIGS[type]; const overlayStyles = getOverlayStyles(type); return ( {/* Guide box */} {/* Corner indicators */} {/* Instruction text */} {config.description} ); }; interface CornerIndicatorProps { position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; } const CornerIndicator: React.FC = ({ position }) => { const size = 20; const thickness = 3; const positionStyles: Record = { 'top-left': { top: -thickness / 2, left: -thickness / 2, borderTop: `${thickness}px solid white`, borderLeft: `${thickness}px solid white`, }, 'top-right': { top: -thickness / 2, right: -thickness / 2, borderTop: `${thickness}px solid white`, borderRight: `${thickness}px solid white`, }, 'bottom-left': { bottom: -thickness / 2, left: -thickness / 2, borderBottom: `${thickness}px solid white`, borderLeft: `${thickness}px solid white`, }, 'bottom-right': { bottom: -thickness / 2, right: -thickness / 2, borderBottom: `${thickness}px solid white`, borderRight: `${thickness}px solid white`, }, }; return ( ); }; export default GuidanceOverlay;