support EyeDropper API in color picker

Chrome 95+
https://wicg.github.io/eyedropper-api/
This commit is contained in:
tophf 2021-09-24 09:39:49 +03:00
parent 997f1fe8de
commit cf0ecbfd4a
5 changed files with 18 additions and 0 deletions

BIN
images/eyedropper/16px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

BIN
images/eyedropper/32px.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

View File

@ -0,0 +1,3 @@
Author: DesignContest
License: https://creativecommons.org/licenses/by/4.0/
Source: https://iconarchive.com/show/outline-icons-by-designcontest/Eyedropper-icon.html

View File

@ -377,6 +377,15 @@
color: var(--label-color-hover); color: var(--label-color-hover);
} }
.colorpicker-dropper {
position: absolute;
right: 7px;
bottom: 4px;
width: 16px;
height: 16px;
cursor: pointer;
}
.colorpicker-palette:not(:empty) { .colorpicker-palette:not(:empty) {
--swatch-size: 16px; --swatch-size: 16px;
margin: 0 var(--margin) var(--margin); margin: 0 var(--margin) var(--margin);

View File

@ -167,6 +167,12 @@
$('format-change', [ $('format-change', [
$formatChangeButton = $('format-change-button', {onclick: setFromFormatElement}, '↔'), $formatChangeButton = $('format-change-button', {onclick: setFromFormatElement}, '↔'),
]), ]),
window.EyeDropper &&
$('dropper', {
tag: 'img',
onclick: () => new window.EyeDropper().open().then(r => setFromColor(r.sRGBHex), () => 0),
srcset: '/images/eyedropper/16px.png, /images/eyedropper/32px.png 2x',
}),
]), ]),
$palette = $('palette', { $palette = $('palette', {
onclick: onPaletteClicked, onclick: onPaletteClicked,