We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I've found a bug that when opacity value is really small (like 1% - 4%) function will generate wrong hex.
Expected: "#FF700003" Received: "#FF70003" 32 | it('returns proper values', () => { 33 | expect(opacity('#FF7000', 0.0)).toBe('#FF700000') > 34 | expect(opacity('#FF7000', 0.01)).toBe('#FF700003')
To fix I changed those lines:
if (opacity === 0) color += '00' else if (opacity !== 1) color += Math.round(opacity * 255).toString(16) return `#${color}`
into this:
const hexOpacity = Math.round(percentage * 255) .toString(16) .padStart(2, '0') .toUpperCase() return `#${color}${hexOpacity}`
This adds zeros at the beginning if generated opacity doesn't contain 2 characters. This also works for 0.0 value so no if needed.
if
The text was updated successfully, but these errors were encountered:
Hi @dkoprowski, a fix has been merged and will be released in 0.1.2 soon. Thanks for reporting 😄
Sorry, something went wrong.
Wow that was fast :)
Successfully merging a pull request may close this issue.
Hi, I've found a bug that when opacity value is really small (like 1% - 4%) function will generate wrong hex.
Failing test example:
Fix
To fix I changed those lines:
into this:
This adds zeros at the beginning if generated opacity doesn't contain 2 characters. This also works for 0.0 value so no
if
needed.The text was updated successfully, but these errors were encountered: