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

Sketch Color Palette V2 - Wrong HEX Values #407

Closed
mbulfair opened this issue Mar 25, 2020 · 2 comments
Closed

Sketch Color Palette V2 - Wrong HEX Values #407

mbulfair opened this issue Mar 25, 2020 · 2 comments

Comments

@mbulfair
Copy link

So I just noticed this, while visually looks correct, our project needs to output the correct hex values.

As a test I ran the following:

Starting with #0b7dbb

Using "transforms": ["name/ti/camel", "attribute/cti", "color/sketch"],

Results:

      "red": "0.04",
      "green": "0.49",
      "blue": "0.73",

Import into sketch palettes, the hex value is wrong.

Pasted Graphic

Used this online tool https://craigdallimore.github.io/sketch-palette-generator/?ref=thesketchapphub

Result:

      "blue": "0.7333333333333333",
      "green": "0.49019607843137253",
      "red": "0.043137254901960784",

In Sketch: This is correct value

Pasted Graphic 1

Did I miss something or is there a bug?

@dbanksdesign
Copy link
Member

It looks like there is a bug. It looks like it is because Style Dictionary is rounding the RGB values to 2 places which is not accurate enough for a hex value because each channel (R,G,B) is 0-255, whereas 2 decimal places only has the granularity of 0-100.

Here is the offending code:
https://github.com/amzn/style-dictionary/blob/master/lib/common/transforms.js#L443

And here is a PR fixing it: #412

@mbulfair
Copy link
Author

mbulfair commented Apr 3, 2020

@dbanksdesign thank you for finding and fixing this, hope this get's released soon.

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

No branches or pull requests

2 participants