Repository navigation
feat(color-picker): migrate to @simonwep/pickr - #3151
deadlyjack wants to merge 2 commits into
Conversation
Replace vanilla-picker with an inline Pickr dialog, add recent color swatches with format cycling, validate and migrate stored colors, and round fractional alpha in Hex.fromRgb. Add unit tests for swatch storage/migration and hex alpha rounding.
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; the remaining migration-test gap is non-blocking. Findings
SummaryReplaces
The latest changes address the earlier opacity finding. No new actionable issues were found. Reviews (2) · Last reviewed commit: "refactor(color-picker): extract formatCo..." · Reviewed by Greptile |
Move Pickr color formatting into a pure module, quantize alpha through the 8-bit channel so faint colors stay translucent, and reuse the formatter for stored hex colors. Add focused tests for every format and the alpha round-trip.
| const [first, second, third] = (isHsl ? hsva.toHSLA() : hsva.toRGBA()).map( | ||
| Math.round, | ||
| ); |
There was a problem hiding this comment.
Rounding HSL channels to whole numbers changes the picked colour. For example, #123456 becomes hsl(210, 65%, 20%), which is #123354. Opening an existing hsl(210, 65.4%, 20.4%) and tapping OK also changes it, and the recent swatch keeps the exact hex, so it no longer matches the inserted text.
vanilla-picker kept one decimal. I compared both roundings over ~636k RGB colours: one decimal round-trips all of them, while whole numbers change about 89% (by up to 5/255 per channel).
| const [first, second, third] = (isHsl ? hsva.toHSLA() : hsva.toRGBA()).map( | |
| Math.round, | |
| ); | |
| const [first, second, third] = isHsl | |
| ? hsva.toHSLA().map((value) => Number(value.toFixed(1))) | |
| : hsva.toRGBA().map(Math.round); |
A test with a non-integer HSL colour such as #123456 would cover this.
| &::after { | ||
| content: ""; | ||
| position: absolute; | ||
| inset: 0; |
There was a problem hiding this comment.
Minor: inset needs Chrome 87, but we support WebView 67+ and autoprefixer doesn't expand it. On Chrome 67–86 these pseudo-elements should collapse to 0×0, leaving the recent swatches and the preview circle with no colour.
| inset: 0; | |
| top: 0; | |
| right: 0; | |
| bottom: 0; | |
| left: 0; |
Replace vanilla-picker with an inline Pickr dialog, add recent color swatches with format cycling, validate and migrate stored colors, and round fractional alpha in Hex.fromRgb. Add unit tests for swatch storage/migration and hex alpha rounding.