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

return rgb #33

Open
giorg opened this issue Nov 30, 2015 · 8 comments
Open

return rgb #33

giorg opened this issue Nov 30, 2015 · 8 comments
Labels

Comments

@giorg
Copy link

giorg commented Nov 30, 2015

Hi,
is it possible to have rgb code instead of hex in return?
thanks

@charettes
Copy link
Owner

Hi @giorg, I'm not sure I understand your request. You'd like to store the data as rgb(1,2,3)?

@giorg
Copy link
Author

giorg commented Nov 30, 2015

Hi,
first of all thanks for this cool plugin, it works perfectly.
What I need is: when I define in my model

color = RGBColorField(null=True, blank=True)

then when in the admin I choose a color it is saved in my color field as hexadecimal. Is it possible to store it as "45,21,34" for example?

thanks a lot

@charettes
Copy link
Owner

I think it would require some work but It could be possible.

If you're interested on working a patch that adds a kwarg to RGBColorFIeld to opt-in this feature I'd be happy to review it.

@smarlowucf
Copy link

Is there still interest in making RGB values an option? If so, the best option might be to use a different jQuery color picker.

Looking through the code I found this block. The current picker is converting all RGB values to hex.

A picker like this would provide the option to use many different color formats. The issue would be whether or not changing the color picker could be done in a non-breaking way.

I'd be willing to attempt these changes if there's any interest with such a change?

@charettes
Copy link
Owner

@smarlowucf a patch is welcome but I believe the requested feature was to make the RGBColor database field return a tri-truple instead of a string.

@smarlowucf
Copy link

Okay, the initial question made me think rgb stored as a string rgb(1,2,3) rather than a tuple (1,2,3).

Migrating to a new jQuery color picker will likely cause some major functionality changes that may be unwanted. The current picker displays a set of colors to be chosen, whereas other pickers I've found provide a palette of colors to choose from. So no input of a colors list would be needed.

Also, CSS expects color formats as strings so sticking to that format seems like an easier option if the color field value is used on the frontend. http://www.w3schools.com/cssref/css_colors_legal.asp

In either case it seems like choosing a JS color picker that supports the wanted color formats is a better option than converting the format on the backend. However, if a color list is wanted the picker I suggested above is not a good option.

@shacker
Copy link

shacker commented Jun 20, 2017

If someone does undertake this work, please consider offering both RGB and RGBA values (with or without alpha).

@portedison
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants