-
-
Notifications
You must be signed in to change notification settings - Fork 75
Migrate postcss-lab-function #13
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
Antonio-Laguna
merged 10 commits into
main
from
postcss-lab-function--passionate-finnish-spitz-a43b5b5214
Nov 28, 2021
Merged
Migrate postcss-lab-function #13
Antonio-Laguna
merged 10 commits into
main
from
postcss-lab-function--passionate-finnish-spitz-a43b5b5214
Nov 28, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…-frank-howler-monkey-86bb10a556
Does this round up or down? Floor or ceil? I'm worried about the tests updates |
romainmenke
commented
Nov 28, 2021
It uses document.documentElement.style="color: rgb(0, 0, 0.49)";
console.log(window.getComputedStyle(document.documentElement).color);
// rgb(0, 0, 0)
console.log(Math.round(0.49));
// 0
document.documentElement.style="color: rgb(0, 0, 0.50)";
console.log(window.getComputedStyle(document.documentElement).color);
// rgb(0, 0, 1)
console.log(Math.round(0.50));
// 1
document.documentElement.style="color: rgb(0, 0, 0.51)";
console.log(window.getComputedStyle(document.documentElement).color);
// rgb(0, 0, 1)
console.log(Math.round(0.51));
// 1 |
Antonio-Laguna
approved these changes
Nov 28, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This is very thorough
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
inlined the color conversion
The current color conversion is not perfect, neither is the conversion in https://github.com/csstools/postcss-lab-function
This conversion tries to match https://facelessuser.github.io/coloraide/
As this packages was suggested as a reference in current spec work.
They try to implement the CSS spec in python.
Once out of gamut color handling is fully specced we should rework the color conversion.
Inlining the functions makes it possible to do this locally without needing to introduce breaking changes in https://www.npmjs.com/package/@csstools/convert-colors
Ideally convert-colors would one day be brought up to speed too.
But I want to avoid getting stuck here because that package is much bigger than what we require for
lab
andlch
fixes
lch
hue values with units : csstools/postcss-lab-function#12This was a small fix.
Just added a check for the unit of the last value and the conversion for the value.
fixes CSS variables : csstools/postcss-lab-function#11
fixes rounding of
rgb
values : csstools/postcss-lab-function#10I tested this in browsers and they also round the
rgb()
values.color: rgb(1.123, 32.234, 5.50)
window.getComputedStyle(foo).color
->rgb(1, 32, 6)