Repository navigation
v1.16.0
Minor Changes
-
c6d3a4b: Add
react-smart-copy/color: copy and paste colours in every CSS format.colorPayload(color, { format })copies a colour as hex,rgb(),hsl(),hwb(),oklch(),oklab(),lab(),lch()orcolor(display-p3 …). Docs, Notion, Slack and mail also get a small swatch (swatch: falseturns it off).parseColorreads every CSS Color 4 notation: hex, the 148 named colours,rgb()andhsl()in both syntaxes,hwb(),lab(),lch(),oklab(),oklch(), andcolor()insrgb,srgb-linear,display-p3,xyz,xyz-d65andxyz-d50. It returnsnullfor anything else and never throws.formatColorwrites any of the formats. The default precision brings every 8-bit colour back exactly; this was checked on 836,056 colours. Colours outside sRGB are gamut-mapped as CSS Color 4 specifies (chroma reduced in OKLCH, hue kept);gamut: "clip"clips them instead.inGamutandtoGamutare exported too.readColorreads a pasted colour, including declarations copied from developer tools (color: #3b82f6;).pasteAsColorinserts any pasted colour in a field's format and keeps the browser's undo.contrastRatioandcontrastLevel: WCAG 2 contrast for normal and large text, never rounded up.- Accuracy is property-tested against culori, and checked against the browser's own CSS parser in Chromium, Firefox and WebKit.