Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-lamps-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gitbook/colors": patch
---

Change lightness check for color step 9 to allow input colors with a higher-than-needed contrast
6 changes: 5 additions & 1 deletion packages/colors/src/transformations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ export function colorScale(
const targetL =
foregroundColor.L * mapping[index] + backgroundColor.L * (1 - mapping[index]);

if (index === 8 && !mix && Math.abs(baseColor.L - targetL) < 0.2) {
if (
index === 8 &&
!mix &&
(darkMode ? targetL - baseColor.L < 0.2 : baseColor.L - targetL < 0.2)
) {
// Original colour is close enough to target, so let's use the original colour as step 9.
result.push(hex);
continue;
Expand Down