Skip to content

Refactor opacity parsing and add percent/number converters #181

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

Merged

Conversation

cwall-dev
Copy link
Contributor

The support for percentage values for the "opacity" property, introduced with 4.2.6, results in percentage values being applied to the property after parsing, regardless of the input value.

With this pull request, the behavior has been changed so that a percentage value is only applied if the input was a percentage value.

For this, the "Number" struct was extended with the Percent unit, and appropriate converter methods were added. Additionally, the unit tests were adjusted accordingly.

Updated OpacityPropertyTests to include additional test cases for parsing opacity values and modified expected results for existing tests. Added ToPercentOrNumber method to ValueExtensions for parsing tokens as percentages or numbers. Introduced PercentOrNumberConverter and OptionalPercentOrNumberConverter in Converters, with the latter providing a default value of 1. Modified OpacityProperty to use OptionalPercentOrNumberConverter. Updated Number class to include a Percent as an unit in the Unit enum and modified ToString methods to append '%' for Percent unit.
@TylerBrinks TylerBrinks merged commit 120ddee into TylerBrinks:master Oct 14, 2024
@cwall-dev cwall-dev deleted the change/opacitypercentageoptimization branch October 17, 2024 08:29
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