-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Round interpolation for RGB components #6984
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
Round interpolation for RGB components #6984
Conversation
By analyzing the blame information on this pull request, we identified @dralletje, @vjeux and @sahrens to be potential reviewers. |
return (input) => { | ||
var i = 0; | ||
// 'rgba(0, 100, 200, 0)' | ||
// -> | ||
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...' | ||
return outputRange[0].replace(stringShapeRegex, () => { | ||
return String(interpolations[i++](input)); | ||
const val = interpolations[i++](input); | ||
return String(shouldRound && i < 4 ? Math.round(val) : val); |
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.
string This type is incompatible with number
b22d40c
to
7723437
Compare
@lelandrichardson updated the pull request. |
return (input) => { | ||
var i = 0; | ||
// 'rgba(0, 100, 200, 0)' | ||
// -> | ||
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...' | ||
return outputRange[0].replace(stringShapeRegex, () => { | ||
return String(interpolations[i++](input)); | ||
const val : Number = interpolations[i++](input); |
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.
string This type is incompatible with Number
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.
number This type is incompatible with Number
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.
I don't speak eslint/flow, apparently.... does anyone know what I should do to fix this? Thanks.
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.
It probably wants const val: number
instead of Number
#accepted Fix the flow errors and @ide comments and you can merge it |
7723437
to
57b5466
Compare
@lelandrichardson updated the pull request. |
57b5466
to
44e2962
Compare
@lelandrichardson updated the pull request. |
return (input) => { | ||
var i = 0; | ||
// 'rgba(0, 100, 200, 0)' | ||
// -> | ||
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...' | ||
return outputRange[0].replace(stringShapeRegex, () => { | ||
return String(interpolations[i++](input)); | ||
const val: number = interpolations[i++](input); |
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.
string This type is incompatible with number
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.
I think you should be able to do
const val = +
interpolations...
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.
string This type is incompatible with number
44e2962
to
fb468ec
Compare
@lelandrichardson updated the pull request. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
Summary:The CSS spec doesn't allow for decimal values inside of rgb colors, however the RN implementation does, so there was a disconnect here. This tests to see if the output range is an rgb color, and if so, rounds the first 3 interpolated components (but not the 4th, since that would be opacity and allows for a decimal). cc vjeux Closes facebook#6984 Differential Revision: D3186473 fb-gh-sync-id: a320bf2311764e084386700bf8c8a42ab2a347eb fbshipit-source-id: a320bf2311764e084386700bf8c8a42ab2a347eb
Summary:The CSS spec doesn't allow for decimal values inside of rgb colors, however the RN implementation does, so there was a disconnect here. This tests to see if the output range is an rgb color, and if so, rounds the first 3 interpolated components (but not the 4th, since that would be opacity and allows for a decimal). cc vjeux Closes facebook#6984 Differential Revision: D3186473 fb-gh-sync-id: a320bf2311764e084386700bf8c8a42ab2a347eb fbshipit-source-id: a320bf2311764e084386700bf8c8a42ab2a347eb
The CSS spec doesn't allow for decimal values inside of rgb colors, however the RN implementation does, so there was a disconnect here.
This tests to see if the output range is an rgb color, and if so, rounds the first 3 interpolated components (but not the 4th, since that would be opacity and allows for a decimal).
cc @vjeux