-
Notifications
You must be signed in to change notification settings - Fork 179
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
Use native eyedropper API if available #11739
Conversation
025beea
to
23e749c
Compare
packages/story-editor/src/components/eyedropper/useEyeDropperApi.js
Outdated
Show resolved
Hide resolved
1d98c46
to
8565225
Compare
Karma test for the EyeDropper on this PR ... After a bunch of debugging I tried creating a standalone HTML page and a test using Puppeteer --- See: https://www.youtube.com/watch?v=gDtnM01dkhU Looks like the EyeDropper doesn't track with the programatic click i.e.
Same for Karma from what I can tell. |
packages/story-editor/src/components/colorPicker/karma/eyedropper.karma.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality is awesome. And truth be told, it does work a bit better than our own implementation 🙈.
I just have some nits about structure - I think the hooks can be better abstracted for a cleaner API.
packages/story-editor/src/components/colorPicker/basicColorPicker.js
Outdated
Show resolved
Hide resolved
packages/story-editor/src/components/eyedropper/useEyeDropperApi.js
Outdated
Show resolved
Hide resolved
packages/story-editor/src/components/eyedropper/useEyeDropperApi.js
Outdated
Show resolved
Hide resolved
packages/story-editor/src/components/eyedropper/useEyeDropperApi.js
Outdated
Show resolved
Hide resolved
packages/story-editor/src/components/colorPicker/basicColorPicker.js
Outdated
Show resolved
Hide resolved
Size Change: +239 B (0%) Total Size: 2.64 MB
ℹ️ View Unchanged
|
Plugin builds for 6b53b6f are ready 🛎️!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merapi I updated this to now use |
Hm, don't we want to just do this in ...
useGlobalKeyDownEffect('esc', closeEyedropper);
if (isEyeDropperApiSupported) {
return null;
}
... |
Your right - should be fine as is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and works great!
{!isEyeDropperApiSupported && ( | ||
<CanvasImage ref={imgRef} src={img} alt="" /> | ||
)} | ||
{!isEyeDropperApiSupported && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surely these can be combined into one condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We can even do an early return if isEyeDropperApiSupported
is true
like suggested here and skip this part, eyedropperLayer
is not needed at all if we have the native API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit to consider but otherwise 👍🏻
@merapi code is updated with that early return now. |
Context
The EyeDropper API enables developers to use a browser-supplied eyedropper in the construction of custom color pickers.
If available use the native browser EyeDropper in place of the current
html-to-image
EyeDropper.html-to-image
EyeDropperSummary
Adds code to check if the EyeDropper API is supported. In which case it will be used when opening the EyeDropper.
There's currently support in Chrome and Edge.
https://caniuse.com/mdn-api_eyedropper
Relevant Technical Choices
To-do
User-facing changes
Testing Instructions
This PR can be tested by following these steps:
Reviews
Does this PR have a security-related impact?
No
Does this PR change what data or activity we track or use?
No
Does this PR have a legal-related impact?
No
Checklist
Type: XYZ
label to the PRFixes #9478