Skip to content

Conversation

lelandrichardson
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @dralletje, @vjeux and @sahrens to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Apr 14, 2016
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);

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

@lelandrichardson lelandrichardson force-pushed the lmr--rgb-interpolation-rounding branch from b22d40c to 7723437 Compare April 14, 2016 20:49
@facebook-github-bot
Copy link
Contributor

@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);

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

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

@vjeux
Copy link
Contributor

vjeux commented Apr 15, 2016

#accepted

Fix the flow errors and @ide comments and you can merge it

@lelandrichardson lelandrichardson force-pushed the lmr--rgb-interpolation-rounding branch from 7723437 to 57b5466 Compare April 15, 2016 16:24
@facebook-github-bot
Copy link
Contributor

@lelandrichardson updated the pull request.

@lelandrichardson lelandrichardson force-pushed the lmr--rgb-interpolation-rounding branch from 57b5466 to 44e2962 Compare April 15, 2016 16:32
@facebook-github-bot
Copy link
Contributor

@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);

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

Copy link
Contributor

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...

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

@lelandrichardson lelandrichardson force-pushed the lmr--rgb-interpolation-rounding branch from 44e2962 to fb468ec Compare April 15, 2016 16:39
@facebook-github-bot
Copy link
Contributor

@lelandrichardson updated the pull request.

@lelandrichardson
Copy link
Contributor Author

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in 4ee0f7b Apr 15, 2016
aprct pushed a commit to aprct/react-native that referenced this pull request Apr 18, 2016
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
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
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
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants