From e0fc63922692317e25b76ca42af2c08175ba6156 Mon Sep 17 00:00:00 2001 From: Lea Verou Date: Wed, 5 Mar 2025 13:38:32 -0500 Subject: [PATCH] Only use hex when color is within sRGB --- src/styles/color/scripts/postprocess.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/color/scripts/postprocess.js b/src/styles/color/scripts/postprocess.js index 0e7df65cf..d36661e58 100644 --- a/src/styles/color/scripts/postprocess.js +++ b/src/styles/color/scripts/postprocess.js @@ -41,9 +41,9 @@ for (let paletteId in palettes) { let color = tints[tint]; tint = tint.padStart(2, '0'); + let format = color.inGamut('srgb') ? 'hex' : undefined; - tintCSS = - `--wa-color-${hue}-${tint}: ${color.toString({ format: 'hex' })} /* ${color.toString()} */;\n` + tintCSS; + tintCSS = `--wa-color-${hue}-${tint}: ${color.toString({ format })} /* ${color.toString()} */;\n` + tintCSS; } if (tints.maxChromaTint != tints.maxChromaTintRaw) {