Skip to content

Updates - #6

Merged
gilbarbara merged 2 commits into
mainfrom
updates
Jun 27, 2026
Merged

Updates#6
gilbarbara merged 2 commits into
mainfrom
updates

Conversation

@gilbarbara

Copy link
Copy Markdown
Member

This pull request introduces comprehensive improvements to OKLCH color handling, ensuring chroma values are always clamped to the Display-P3 gamut maximum across all entry points and interactions. This prevents out-of-gamut chroma from causing errors or inconsistencies, especially when colors are set via input, props, or user interaction. The changes include a new utility function, its integration throughout the codebase, and an expanded test suite to cover these scenarios.

OKLCH Chroma Clamping and Consistency

  • Added a new function clampOklchToP3 to colorSpace.ts that clamps the chroma (c) of an OKLCH color to the Display-P3 maximum for its lightness and hue, ensuring all colors remain within the supported gamut.
  • Integrated clampOklchToP3 throughout the color picker logic, including initialization, controlled prop updates, color input handling, and all OKLCH-related user interactions in useColorPicker and OKLCHSliders. This guarantees that chroma never exceeds the P3 maximum, regardless of how a color enters the system. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Testing and Validation

  • Added and expanded tests in ColorPicker.test.tsx, OKLCHSliders.test.tsx, useColorPicker.test.tsx, and colorSpace.test.ts to validate that chroma is always clamped to the P3 maximum in all scenarios, including prop changes, input, panel, and slider interactions. These tests assert both the internal state and emitted values. [1] [2] [3] [4]

Dependency Updates

  • Updated several dependencies and devDependencies in package.json to their latest patch/minor versions for improved stability and compatibility, including colorizr, Storybook, Vite, Vitest, and pnpm. [1] [2]

Internal Refactoring

  • Updated imports and types in colorSpace.ts for clarity and to support the new chroma clamping logic. [1] [2]

These changes collectively ensure that the color picker never emits or operates on out-of-gamut OKLCH colors, improving reliability and user experience.

Copilot AI review requested due to automatic review settings June 26, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens OKLCH handling by introducing a Display‑P3 chroma clamp and wiring it into key color-picker entry points and OKLCH interactions, backed by expanded tests. The goal is to prevent out-of-gamut OKLCH chroma values from entering or persisting in picker state and emitted values.

Changes:

  • Added clampOklchToP3 utility (based on getP3MaxChroma) and applied it when OKLCH values enter or are mutated in the hook.
  • Updated OKLCH slider logic to clamp relative chroma so lightness/hue changes can’t preserve an out-of-gamut chroma ratio.
  • Expanded tests to validate clamping across initialization, controlled prop updates, input handling, and interactions; updated dependency versions.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/modules/colorSpace.ts Adds clampOklchToP3 to enforce P3-gamut chroma constraints.
src/hooks/useColorPicker.ts Integrates clamping into OKLCH state initialization, prop updates, and OKLCH interactions.
src/ChannelSliders/OKLCHSliders.tsx Clamps relative chroma on lightness/hue changes to prevent exceeding new gamut maxima.
tests/modules/colorSpace.test.ts Adds unit tests for the new clamp utility.
tests/hooks/useColorPicker.test.tsx Adds hook-level coverage ensuring clamping across multiple interaction paths.
tests/ColorPicker.test.tsx Adds integration coverage ensuring emitted values remain within gamut when inputs would otherwise strand chroma.
tests/ChannelSliders/OKLCHSliders.test.tsx Adds regression coverage ensuring slider interactions don’t emit invalid chroma.
package.json Bumps runtime/dev dependencies (incl. colorizr, Storybook, Vite/Vitest, Playwright, pnpm).
pnpm-lock.yaml Lockfile updates corresponding to dependency bumps.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/useColorPicker.ts Outdated
Comment thread src/hooks/useColorPicker.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

@gilbarbara
gilbarbara merged commit d829635 into main Jun 27, 2026
5 checks passed
@gilbarbara
gilbarbara deleted the updates branch June 27, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants