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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/theme/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Code Quality

- Stop publishing `@wordpress/theme` source paths by moving publish-ready assets outside `src` and enforcing the package boundary ([#80213](https://github.com/WordPress/gutenberg/pull/80213)).
- Update `colorjs.io` dependency to remove need for colorspace registration workaround ([#80272](https://github.com/WordPress/gutenberg/pull/80272)).

## 1.0.0 (2026-07-14)

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@wordpress/element": "file:../element",
"@wordpress/private-apis": "file:../private-apis",
"@wordpress/style-runtime": "file:../style-runtime",
"colorjs.io": "^0.6.0",
"colorjs.io": "^0.7.0",
"memize": "^2.1.0"
},
"devDependencies": {
Expand Down
7 changes: 1 addition & 6 deletions packages/theme/src/color-ramps/lib/color-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export function getContrast(
* `rgb()`/`rgba()`, or a CSS named color), throwing otherwise.
*
* Rejection is deterministic regardless of which `ColorSpace`s are globally
* registered: `clampToGamut` registers `OKLCH`, which would otherwise make
* `oklch()` strings parse, but their space id is `oklch` (not `srgb`) so they
* are still rejected.
* registered.
*
* @param seed The seed-color string to validate.
* @throws If `seed` is not an sRGB-parseable, fully opaque string.
Expand Down Expand Up @@ -87,8 +85,5 @@ export function assertValidSeedColor( seed: string ): void {
*/
export function clampToGamut( c: string | PlainColorObject ) {
ColorSpace.register( sRGB );
// Workaround for upstream toGamut(method:'css') bug.
// https://github.com/color-js/color.js/pull/734
ColorSpace.register( OKLCH );
return to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );
}
10 changes: 3 additions & 7 deletions packages/theme/src/color-ramps/lib/taper-chroma.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ColorSpace,
get,
toGamut,
toGamutCSS,
OKLCH,
sRGB,
type ColorSpace,
type PlainColorObject,
} from 'colorjs.io/fn';

Expand Down Expand Up @@ -36,10 +36,6 @@ export function taperChroma(
lTarget: number, // [0..1]
options: TaperChromaOptions = {}
): { l: number; c: number } | PlainColorObject {
// Workaround for upstream toGamut(method:'css') bug.
// https://github.com/color-js/color.js/pull/734
ColorSpace.register( OKLCH );

const gamut = options.gamut ?? sRGB;
const alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface
const carry = options.carry ?? 0.5;
Expand Down Expand Up @@ -213,7 +209,7 @@ function maxInGamutChromaAtLH(
};

// Let `toGamut` reduce the chroma to the gamut maximum.
const clamped = toGamut( probe, { space: gamutSpace, method: 'css' } );
const clamped = toGamutCSS( probe, { space: gamutSpace } );

return get( clamped, [ OKLCH, 'c' ] );
}
2 changes: 1 addition & 1 deletion packages/theme/src/color-ramps/test/seed-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function testSeedColorContract( build: ( seed: string ) => unknown ) {
expect( () => build( seed ) ).toThrow();
} );

it( 'rejects oklch() even when the OKLCH color space is registered', () => {
it( 'rejects non-sRGB color spaces even when the color space is registered', () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Technically nothing's changing here but mentioning OKLCH seemed incidental to what we were doing with the previous workaround. The intent with the test is that the seed should be rejected for any non-SRGB color value, regardless of which colorspace. OKLCH is still a fine representative example to use in the test body.

// Registering OKLCH would otherwise make `oklch(...)` strings parse.
ColorSpace.register( OKLCH );
expect( () => build( 'oklch(0.7 0.15 250)' ) ).toThrow();
Expand Down
Loading