Skip to content

Implement dynamic APCA contrast calculation in design simulator - #25

Merged
REX-codebase merged 1 commit into
mainfrom
jules/fix-apca-contrast-logging-js1-39273fb5-15e9-4ece-9cb3-1bf243ab65ea
Jul 18, 2026
Merged

REX-codebase merged 1 commit into
mainfrom
jules/fix-apca-contrast-logging-js1-39273fb5-15e9-4ece-9cb3-1bf243ab65ea

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Why

The design simulator previously logged a hardcoded success message (APCA Contrast Verification: Perceptual Lightness Compliance Checked) during accessibility audits. Because this static message bypassed the actual calculation logic, it produced false-positive compliance reports that could easily mask illegible color choices.

To improve the integrity of our design system audits, this PR replaces the hardcoded string with a dynamic APCA contrast calculation. Designers and developers will now receive accurate, real-time feedback on color legibility.

Key Decisions & Rationale

  • Leveraged Existing Utilities: Used the internal calculatePerceptualContrast helper rather than introducing external packages, keeping the codebase lightweight and maintainable.
  • Strictly Scoped Audit: Focused solely on the primary color pair to fulfill the task requirements efficiently without introducing recursive element auditing.
  • Reporting-Only Impact: Maintained the guardrail that this calculated contrast is strictly for logging/reporting within the "Cognitive Metrics Report" and does not influence the final Taste Score.
  • Zero Space Parsing Changes: Kept the existing OKLCH color parsing logic intact, extracting lightness data dynamically from the context.

What Changed

  • Removed Static Logger: Cleaned up the hardcoded "APCA Contrast Verification: Perceptual Lightness Compliance Checked." log inside skills/utils/design-simulator.js.
  • Exposed Contextual Color Metrics: Updated runTasteAudits to return the colorMetrics containing minLightness and maxLightness derived from OKLCH rules.
  • Integrated Dynamic Calculation: Fed these lightness parameters into the calculatePerceptualContrast helper.
  • Updated Report Output: Modified the simulator output to display the dynamically computed result: - APCA Contrast Verification: Calculated Lc <value> (Primary Pair).

@REX-codebase
REX-codebase merged commit 685e971 into main Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant