import { forwardRef, useState } from 'react' import SplitTag from '../SplitTag' import { TagColor, TagSize, TagShape } from '../../Tags/types' import { splitTagAccessibilityReport } from './SplitTagAccessibilityReport' import { generateAccessibilityReport, downloadReport, getMimeType, getFileExtension, type ReportFormat, } from '../../shared/accessibility/reportGenerator' import { Download as DownloadIcon, Check, X, Info, Server, Package, GitBranch, Activity, TrendingUp, Shield, } from 'lucide-react' import Button from '../../Button/Button' import { ButtonType, ButtonSize } from '../../Button/types' export type SplitTagAccessibilityProps = { className?: string } const SplitTagAccessibility = forwardRef< HTMLDivElement, SplitTagAccessibilityProps >(({ 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( splitTagAccessibilityReport, { format: selectedFormat, includeTestResults, includeRecommendations, } ) const filename = `splittag-accessibility-report-${splitTagAccessibilityReport.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( splitTagAccessibilityReport, { 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 = splitTagAccessibilityReport 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 (

SplitTag Component Accessibility

WCAG {report.wcagVersion} • {report.conformanceLevel} • {report.reportDate}
Evaluates: WCAG 2.0, 2.1, 2.2
{report.overallStatus.toUpperCase()}
{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}

Download Report

{showFullReport && reportHtmlContent && (

Full Accessibility Report

)}

WCAG Criteria Breakdown

{report.criteria.map((criterion) => (
{criterion.id} -{' '} {criterion.title} Level {criterion.level} {criterion.status .charAt(0) .toUpperCase() + criterion.status.slice( 1 )}

{criterion.description}

Implementation: {' '} {criterion.implementation}

{criterion.testResults && (

Test Results: {' '} {criterion.testResults}

)} {criterion.notes && (

Notes:{' '} {criterion.notes}

)}
))}

Strengths

    {report.strengths.map((strength, index) => (
  • ✓ {strength}
  • ))}

Recommendations

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

WCAG Versions Covered

WCAG 2.0

    {report.wcagVersions['2.0'].map( (item, index) => (
  • • {item}
  • ) )}

WCAG 2.1

    {report.wcagVersions['2.1'].map( (item, index) => (
  • • {item}
  • ) )}

WCAG 2.2

    {report.wcagVersions['2.2'].length > 0 ? ( report.wcagVersions['2.2'].map( (item, index) => (
  • • {item}
  • ) ) ) : (
  • No new criteria
  • )}

Interactive Examples

Basic SplitTag Examples

SplitTag with Icons

Interactive SplitTags

All Sizes

Extra Small
Small
Medium
Large

All Shapes

Squarical Shape

Rounded Shape

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