Popup color picker
The same picker behind a swatch button and a hex box, for forms where color is one setting among many. It opens under the field. Esc or Cancel puts the old color back; Done or clicking away keeps it. The hex box takes 3, 4, 6 or 8 digits. Here the value feeds a tint scale.
Used in the variable names.
Show code
<div class="cpick-field" data-cpick-popup data-value="#1F4E79">
<button type="button" class="cpick-field-swatch" aria-haspopup="dialog"
aria-expanded="false" aria-controls="base-panel"></button>
<input type="text" class="form-control cpick-field-hex" id="base-hex" value="#1F4E79">
<div class="cpick-panel cpick-panel-popup" id="base-panel" role="dialog" hidden></div>
</div>
// Esc and Cancel revert, Done and clicking away keep the color.
attachPopup(field, (color) => drawScale(color));