import { forwardRef, useState } from 'react' import { Drawer, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerBody, DrawerFooter, DrawerClose, } from '../Drawer' import { Button } from '../../Button/index' import { ButtonType, ButtonSize } from '../../Button/types' import { drawerAccessibilityReport } from './DrawerAccessibilityReport' import { generateAccessibilityReport, downloadReport, getMimeType, getFileExtension, type ReportFormat, } from '../../shared/accessibility/reportGenerator' import { Download as DownloadIcon } from 'lucide-react' export type DrawerAccessibilityProps = { className?: string } const DrawerAccessibility = forwardRef< HTMLDivElement, DrawerAccessibilityProps >(({ 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 [basicDrawerOpen, setBasicDrawerOpen] = useState(false) const [keyboardDrawerOpen, setKeyboardDrawerOpen] = useState(false) const [rightDrawerOpen, setRightDrawerOpen] = useState(false) const handleDownload = () => { try { const content = generateAccessibilityReport( drawerAccessibilityReport, { format: selectedFormat, includeTestResults, includeRecommendations, } ) const filename = `drawer-accessibility-report-${drawerAccessibilityReport.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( drawerAccessibilityReport, { 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 = drawerAccessibilityReport 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 return (

Drawer Component Accessibility

WCAG {report.wcagVersion} • {report.conformanceLevel} • {report.reportDate}
Evaluates: WCAG 2.0, 2.1, 2.2

Download Report

{compliantCount}
Compliant ✅
Verified & tested
{nonCompliantCount}
Non-Compliant ❌
Issues found
{unsureCount}
Unsure ⚠️
Needs verification
{complianceRate}%
Compliance Rate
Based on verified items
{unsureCount > 0 && (
⚠️

Manual Verification Required

{unsureCount} criterion/criteria marked as "unsure" require manual verification. These items need testing with contrast checkers, screen readers, or depend on application context.

)}

Summary

{report.summary}

Quick Stats

Total Criteria: {report.criteria.length}
Level A: { report.criteria.filter( (c) => c.level === 'A' ).length }
Level AA: { report.criteria.filter( (c) => c.level === 'AA' ).length }
Level AAA: { report.criteria.filter( (c) => c.level === 'AAA' ).length }
{showFullReport && reportHtmlContent && (

Full Accessibility Report

)}

WCAG Criteria Breakdown

{report.criteria.map((criterion) => (
{criterion.id}:{' '} {criterion.title} Level {criterion.level} {criterion.status === 'compliant' ? '✅ Compliant' : criterion.status === 'non-compliant' ? '❌ Non-Compliant' : criterion.status === 'unsure' ? '⚠️ Unsure' : 'N/A'}

{criterion.description}

Implementation:

{criterion.implementation}

{criterion.testResults && (
Test Results:

{criterion.testResults}

)} {criterion.notes && (
Notes:

{criterion.notes}

)}
))}

Strengths

    {report.strengths.map((strength, index) => (
  • {strength}
  • ))}
{report.recommendations.length > 0 && (

Recommendations

    {report.recommendations.map( (recommendation, index) => (
  • {recommendation}
  • ) )}
)}

Component Example

Keyboard Navigation Example

Right Drawer Example

) }) DrawerAccessibility.displayName = 'DrawerAccessibility' export default DrawerAccessibility