import { forwardRef, useState } from 'react' import AvatarGroup from '../AvatarGroup' import { AvatarSize } from '../../Avatar/types' import { avatarGroupAccessibilityReport } from './AvatarGroupAccessibilityReport' import { generateAccessibilityReport, downloadReport, getMimeType, getFileExtension, type ReportFormat, } from '../../shared/accessibility/reportGenerator' import { Download as DownloadIcon } from 'lucide-react' import { Button } from '../../Button' import { ButtonType, ButtonSize } from '../../Button/types' export type AvatarGroupAccessibilityProps = { className?: string } const AvatarGroupAccessibility = forwardRef< HTMLDivElement, AvatarGroupAccessibilityProps >(({ className }, ref) => { const [selectedFormat, setSelectedFormat] = useState('markdown') const [includeTestResults, setIncludeTestResults] = useState(true) const [includeRecommendations, setIncludeRecommendations] = useState(true) const [reportHtmlContent, setReportHtmlContent] = useState( null ) const [showFullReport, setShowFullReport] = useState(false) const handleDownload = () => { try { const content = generateAccessibilityReport( avatarGroupAccessibilityReport, { format: selectedFormat, includeTestResults, includeRecommendations, } ) const filename = `avatargroup-accessibility-report-${avatarGroupAccessibilityReport.reportDate}.${getFileExtension(selectedFormat)}` const mimeType = getMimeType(selectedFormat) downloadReport(content, filename, mimeType) } catch (error) { console.error('Error generating report:', error) alert('Failed to generate report. Please try again.') } } const handleViewReport = () => { try { const htmlContent = generateAccessibilityReport( avatarGroupAccessibilityReport, { format: 'html', includeTestResults, includeRecommendations, } ) setReportHtmlContent(htmlContent) setShowFullReport(true) } catch (error) { console.error('Error generating report:', error) alert('Failed to generate report. Please try again.') } } const report = avatarGroupAccessibilityReport const compliantCount = report.criteria.filter( (c) => c.status === 'compliant' ).length const nonCompliantCount = report.criteria.filter( (c) => c.status === 'non-compliant' ).length const unsureCount = report.criteria.filter( (c) => c.status === 'unsure' ).length const totalApplicable = report.criteria.filter( (c) => c.status !== 'not-applicable' ).length const complianceRate = totalApplicable > 0 ? Math.round((compliantCount / totalApplicable) * 100) : 0 const mockAvatars = [ { id: 1, alt: 'John Doe', src: 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=32&h=32&fit=crop&crop=face', }, { id: 2, alt: 'Jane Smith', src: 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=32&h=32&fit=crop&crop=face', }, { id: 3, alt: 'Mike Johnson' }, { id: 4, alt: 'Sarah Wilson', fallback: 'SW' }, { id: 5, alt: 'Alex Brown' }, { id: 6, alt: 'Emma Davis' }, ] return (

AvatarGroup Accessibility Report

WCAG 2.0, 2.1, 2.2 Compliance Analysis - Level AA

Report Date: {report.reportDate}

{report.overallStatus.toUpperCase()}
{/* Compliance Stats */}
{compliantCount}
Compliant
{nonCompliantCount}
Non-Compliant
{unsureCount}
Requires Verification
{complianceRate}%
Compliance Rate
{/* Summary & Download */}

Summary

{report.summary}

Download Report

{/* Full Report Viewer */} {showFullReport && reportHtmlContent && (

Full Accessibility Report

Interactive HTML report (same as downloaded version)