WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.46k stars 4.18k forks source link

Components: Support the `EyeDropper` API in `ColorPicker` #34487

Open ciampo opened 3 years ago

ciampo commented 3 years ago

Why

Adding an Eye Dropper tool to the ColorPicker would enhance its UX and features set

What

We should embed an Eye Dropper tool following the EyeDropper APIs:

Note: this API are not stable yet and, at the time of writing, is only supported in Chrome >= 95

A/C

javierarce commented 3 years ago

Here's a proposal for the eyedropper:

image

Figma file

ciampo commented 3 years ago

cc'ing @mtias @pablohoneyhoney and @jasmussen regarding the potential UX around an eyedropper tool in the `ColorPicker.

(example codepen: https://codepen.io/matanbobi/pen/GREoZvo)

pablohoneyhoney commented 3 years ago

Nice!

For some reason I'm not able to see the codepen EyeDropper API is not supported on this platform in any browser and would love to.

Not sure if we want this right away and that's why it wasn't explored initially. If we do, there are cases where the color picker doesn't have a header or it isn't clear if we do need that header all times.

Screen Shot 2021-10-08 at 5 11 09 PM

It might work with the RGBA codes but perhaps the eyedropper could live alongside the control icon if we don't need to label?

Screen Shot 2021-10-08 at 5 14 08 PM
javierarce commented 3 years ago

If we do, there are cases where the color picker doesn't have a header or it isn't clear if we do need that header all times.

In that case we could go for a placement similar to Figma's color picker:

image

pablohoneyhoney commented 3 years ago

It does unbalance the UI heavily, no? Is there perhaps a different way to display the RGBA codes so it could live on the left of the controls icon? For example.

javierarce commented 3 years ago

Is there perhaps a different way to display the RGBA codes so it could live on the left of the controls icon? For example.

I'll think about alternative ways to display the color, but I think we could pull that off by just slightly increasing the width of the component and reducing the space between the color parts:

Quick test:

image

Question: the blue color implies that the RGBA are links, right? What happens when the user clicks them?

ciampo commented 3 years ago

For some reason I'm not able to see the codepen EyeDropper API is not supported on this platform in any browser and would love to.

I am able to run the codepen on the latest stable Chrome for MacOS (Version 94.0.4606.81)

javierarce commented 3 years ago

I'm also on that version, but it didn't work for me I had to install Chrome Canary.

jasmussen commented 3 years ago

This is a sweet feature. Because it's such an advanced browser feature that it's barely rolled out to Chrome yet, though, I would echo Pablo that it seems worth it to restrict the button to exist in context of other advanced configuration tools for the time being. Then as browser support becomes wider, the button could literally graduate in the UI.

That said, it could be nice to include a small enhancement for power-users, such as allowing people to press the i key to invoke the eye-dropper when the color picker is open.

It seems important to change the cursor also, though, when the tool is selected. Ideally we create an entirely custom cursor, pending browsers adding a system-level eye-dropper cursor. Altenately, the crosshair cursor might hold us over.

jorgefilipecosta commented 2 years ago

Should we implement this feature now (with a check and if not supported we don't render anything)? Or it is something for the future when browser support increases?

ciampo commented 2 years ago

Personally, I think this would a nice-to-have feature with (at the moment) a low priority. We could probably use our resources for higher-priority issue and come back to this once browser support looks a bit better.