Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge conditions
  • Loading branch information
jsnajdr committed Nov 7, 2025
commit 3474192fcf9cc67ad369cb91c3ef49e161d2166d
18 changes: 10 additions & 8 deletions packages/theme/src/color-ramps/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function calculateRamp( {
>;
let maxDeficit = -Infinity;
let maxDeficitDirection: RampDirection = 'lighter';
let maxDeficitStep = 'none';
let maxDeficitStep;

// Keep track of the calculated colors, as they are going to be useful
// when other colors reference them.
Expand Down Expand Up @@ -177,12 +177,14 @@ function calculateRamp( {

// When the target contrast is not met, take note of it and use
// that information to guide the ramp calculation bisection.
if ( ! contrast.ignoreWhenAdjustingSeed ) {
if ( searchResults.deficit && searchResults.deficit > maxDeficit ) {
maxDeficit = searchResults.deficit;
maxDeficitDirection = computedDir;
maxDeficitStep = stepName;
}
if (
! contrast.ignoreWhenAdjustingSeed &&
searchResults.deficit &&
searchResults.deficit > maxDeficit
) {
maxDeficit = searchResults.deficit;
maxDeficitDirection = computedDir;
maxDeficitStep = stepName;
}

// Store calculated color for future dependencies
Expand Down Expand Up @@ -301,7 +303,7 @@ export function buildRamp(
let bestSeed = seed;
let bestDeficit = maxDeficit;

const iterSteps = stepsForStep( maxDeficitStep as keyof Ramp, config );
const iterSteps = stepsForStep( maxDeficitStep!, config );

// Binary search: try a new seed and recompute the whole ramp
for ( let i = 0; i < MAX_BISECTION_ITERATIONS; i++ ) {
Expand Down