Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Enhancements for Contrast Calculations (and mini refactor for contrast class) #92

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

danielebarbaro
Copy link
Contributor

This PR introduces improvements to the Contrast class and its related tests:

Refactor:

  • Simplified the Contrast::ratio method for better readability by extracting the luminance calculation into a dedicated Contrast::calculateLuminance method.
  • Improved conditional checks for color conversion in the Contrast class to ensure cleaner and more concise code.

Added new tests to validate:

  • Luminance calculations for edge cases (e.g., white and black colors).
  • Adjusted existing test datasets for better precision and accuracy in contrast ratio calculations.

These changes improve the readability, maintainability, and accuracy of the contrast calculation logic.

@freekmurze freekmurze merged commit e0cdcdb into spatie:main Dec 23, 2024
20 checks passed
@freekmurze
Copy link
Member

Thanks!

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.

2 participants