Color picker component in Perspective

Hi

Just wanted to know if there is a color picker/selector component in the Perspective module.

No.

Iā€™m not aware of plans to add one in the near future. Someone could provide a third party module in the meantime.

Oh alright, thanks.

Here is one on the exchange, I actually started a more robust one as well to add, just havent done it yet so who knows maybe one day!

5 Likes

Woah! will try using this component, thanks a lot!

So, I needed a color picker and tried the one from the exchange.
I thought it could be polished a bit more, and... I couldn't sleep last night anyway.

color_picker.zip (34.6 KB)
image

Not gonna lie, I stole the palette from the one @Travis.Cox made.
Also used his mechanism to write the colors part to the parameter (property change script on the r/g/b components.).
What changed, then ?
Internally, I tried to clean it up a bit, make things simpler. Rewrote the scripts to make them clearer.
Visually, The r/g/b/a components adapt to show what color you'll get by putting the slider handle somewhere. It's accurate enough.

I didn't test this on multiple browsers, so if you find something that behaves weirdly, please report back.
Also note that the css used to modify the slider's handle and bind it to its container might need to be adjusted if you change the size of the sliders (there's some padding involved to make it stay inside).
You'll find the handle's css in the color_slider_handle, as an injection,
and the css for the slider itself in color_slider

There's also an alpha part. The color returned won't include it (hex code still on 6 characters) if there's no transparency.

The popup expects a popup_id, an item_id and an initial color.
The popup_id is used to close the popup, and is provided automatically if you use the color_popup function.
item_id is used to filter the incoming messages, in case there are several things calling this popup.
Can be pretty much anything, as long as it identifies the component that should receive the message.
color is, well, an initial color, in case you need to change a color instead of creating a new one.
This could probably be improved, maybe just giving it a default color... I didn't need it so I didn't do it.

I might polish it some more when I get time, but this is good enough for my use case.

edit: Just realized it's missing a style class... that's in my actual project.
I'll try and fix this asap. And maybe also make things align a bit more neatly.

edit: forgot about this. Updated with slightly better looking version.

2 Likes