Skip to content
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

chore: validate passed color #45

Merged
merged 7 commits into from
Dec 11, 2020
Merged

chore: validate passed color #45

merged 7 commits into from
Dec 11, 2020

Conversation

gerdasi
Copy link
Contributor

@gerdasi gerdasi commented Dec 11, 2020

No description provided.

src/utils.js Outdated
@@ -50,3 +57,16 @@ function numberToPx(name, value) {
}
return value;
}

export function colorToHex(name, value) {
if (!value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about transparent values ? How they will be represented as hex ?

return '';
}
let c;
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to validate only the color, not convert to hex ?

return isValid(color) ? color : '';

@@ -108,4 +110,22 @@ describe('utils', () => {
expect(addQueryParams('url', { one: '?two' })).to.equal('url?one=%3Ftwo');
});
});

describe('colorToHex', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check also rgb and rgba syntax.

@gerdasi gerdasi merged commit c867b6a into wix-incubator:master Dec 11, 2020
@gerdasi gerdasi deleted the color-validation branch December 11, 2020 09:20
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.

None yet

3 participants