-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
How to generate old syntax for rgba for CSS? #203
Comments
Found it: color.toString({commas: true, format: 'rgba'}); It's confusing because documentation hides all information except function signatures, and you need to uncheck the checkboxes to see the actual documentation. Clicking on signature just add hash to URL. This is quite odd and bad DX I would say. Why not remove those checkboxes, I don't see the point of having them. It looks like you don't have documentation at first sight. |
I found that confusing too, but click on the colored boxes rather than the text, so just the one call you are interested in expands. |
This does not seem to yield the desired result on my side:
Running |
I have the same issue I would like to have numerical value not percentage, but it works. I only wonder in how many browsers. |
Yeah, we should probably remove those docs. They are also wildly out of date.
What is the desired result? It does have commas, and it is
Percentages are generally better as it's a representation that is not designed after 8bit implementation constraints. But you can get numbers, it's just a little more involved: let lv_magenta = new Color("#ff006688");
// Custom functional format:
lv_magenta.toString({format: {
name: "rgba",
commas: true,
coords: [
"<number>[0, 255]",
"<number>[0, 255]",
"<number>[0, 255]",
]
}}) // 'rgba(255, 0, 102 , 0.5333)' or, to reuse the format: let lv_magenta = new Color("#ff006688");
let rgba_number = {
name: "rgba",
commas: true,
coords: [
"<number>[0, 255]",
"<number>[0, 255]",
"<number>[0, 255]",
]
};
lv_magenta.toString({format: rgba_number}) // 'rgba(255, 0, 102 , 0.5333)' We should probably add a shortcut so you can just do
All browsers support percentages in |
I'm not sure how others but the way color works on computer it more intuitive to use 0-255 color range than floating point number, what it should to if the color is between two values? what will the output of 0.3333333333% I feel that percentage is confusing that's why I prefer what system is using. Another reason is that when creating hex color you can't create more than 255 and it's hard to read. The same as getting inches or yards when measuring the length if you specify the input in meters. Doesn't make sense to me. So at least there should be an easy what to use 0-255 values if I want. BTW: what is that space before the last comma? I also would like to have clean output, it looks like a bug to me. |
I actually ended up going with a different color library because I couldn't figure out the call signature and how to get the desired output. I am using Typescript and it would not allow to call toString with a And "desired output" was just a reference to @jcubic's It would be very nice with such a format shorthand. |
Not sure why you feel 0-255 is more intuitive, if 0.3333% is hard, why is 84.3333 not hard? Note that the 0-255 are not necessarily integers, exactly because color is not necessarily 8 bit anymore.
I just pushed a fix for that in bf36ebc.
Typescript support is still somewhat beta, it was just added in #221. I just pushed a fix for this in d0ab5d1, @MysteryBlokHed @jgerigmeyer hope I did it right.
I just pushed it in 667c19a ! Feel free to try it out and let me know what you think! |
Thank you! Great work 😃 |
I've noticed that the library is using this syntax:
rgb(65.098% 49.804% 34.902% / 0.997);
Where can I use browser support for this syntax? It seems this is quite new. Can you generate older syntax:
Where can I check browser support for this new syntax? I work for a library that works in IE11 (I know it's deprecated but I want my library to work for old browsers even IE11).
The text was updated successfully, but these errors were encountered: