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

switch hex-rgb to polished parseToRgb #18681

Merged
merged 3 commits into from Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/package.json
Expand Up @@ -37,11 +37,11 @@
"classnames": "^2.2.5",
"clipboard": "^2.0.1",
"dom-scroll-into-view": "^1.2.1",
"hex-rgb": "^4.1.0",
"lodash": "^4.17.15",
"memize": "^1.0.5",
"moment": "^2.22.1",
"mousetrap": "^1.6.2",
"polished": "^3.4.2",
"re-resizable": "^6.0.0",
"react-dates": "^17.1.1",
"react-spring": "^8.0.20",
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/utils/colors.js
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { get } from 'lodash';
import hexRgb from 'hex-rgb';
import { parseToRgb } from 'polished';
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 we already have tinycolor2 in our bundles. We could use it instead right?

Copy link

Choose a reason for hiding this comment

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

@jameslnewell Ah, you folks are so fast! You jumped on this before I could :)
I was going to suggest using tinycolor2 since it was already there. My apologies for not realizing that when I submitted my original PR.

Thanks for the heads up @youknowriad + @aduth !

/**
* Internal dependencies
*/
Expand All @@ -20,8 +20,8 @@ import { COLORS } from './colors-values';
* // rgba(0, 0, 0, 0.5)
*/
export function rgba( hexValue = '', alpha = 1 ) {
const [ r, g, b ] = hexRgb( hexValue, { format: 'array' } );
return `rgba(${ r }, ${ g }, ${ b }, ${ alpha })`;
const { red, green, blue } = parseToRgb( hexValue );
return `rgba(${ red }, ${ green }, ${ blue }, ${ alpha })`;
}

/**
Expand Down