Repository navigation
Releases: MineProDan/contrast-audit
Releases · MineProDan/contrast-audit
Release list
ContrastAudit 0.1.0
First release of ContrastAudit: audit a whole color theme for WCAG 2.1 contrast from swift test, and get one failure that names every failing pair with its measured and required ratio.
Real output from the demo package (docs/example-output.txt):
✘ Test emberMeetsAA() recorded an issue at ThemeContrastTests.swift:19:35: Issue recorded
↳ Contrast audit failed for theme 'Ember' at AA: 2 of 12 checks failed (6 pairs x 2 variants).
[light] 'toggle-track' on 'surface' 1.76:1 needs 3.00:1 (AA, UI component)
[dark] 'subtitle' on 'surface' 3.89:1 needs 4.50:1 (AA, body text)
Not counted as failures: 1 waived.
Added
ContrastCore, with no UI-framework or test-framework imports:SRGBColor, created from components in 0...1 (throws instead of clamping),
from 8-bit components, or from#RGB,#RGBA,#RRGGBBand#RRGGBBAA
hex strings.- WCAG 2.1 relative luminance and
ContrastRatio, which compares unrounded
values and displays them truncated to two decimals, never rounded up. PairRole(.bodyText,.largeText,.uiComponent) and
ConformanceLevel(.aa,.aaa) with the WCAG 2.1 requirements.Theme,ColorPairandVariantfor declaring pairs once and auditing
them in every variant.- Explicit backdrops for translucent backgrounds; source-over compositing on
gamma-encoded sRGB; no assumed white background. Waiverfor reviewed exceptions with a reason and optional expiry note.Baselinefor recording known failures that may not get worse, with a
versioned JSON format.AuditReportwithsummary, the aggregatedfailureDescription,
markdown()andjson(), andCheckResultfor inspecting checks in code.- Configuration mistakes (missing or malformed colors, duplicates, empty
themes, backdrop problems, baseline level mismatch) reported as
AuditProblems instead of crashes.
ContrastAuditTesting:ContrastAudit.assertPassesfor XCTest and
ContrastAudit.expectPassesfor Swift Testing, each recording one failure
with the aggregated message at the caller's source location.ContrastPlatformColors:SRGBColor(resolving:appearance:)forNSColor,
SRGBColor(resolving:with:)forUIColorandSRGBColor(resolving:in:)for
SwiftUIColor, each with an explicit appearance, converting to sRGB without
clamping.scripts/verify_vectors.py, an independent standard-library Python
implementation that generates the reference-vector fixture used by the tests.Examples/ThemeAuditDemo, a separate package with one passing and one
intentionally failing invented theme.scripts/leak_scan.shand a GitHub Actions workflow for macOS (Xcode 26.6 and
Xcode 16.0 / Swift 6.0), the iOS
simulator, Linux and the leak scan.
A passing audit means the declared pairs meet the declared ratios. It does not mean an app is accessible.