-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pass colorspace to color modifier mix utility (#272)
- Loading branch information
1 parent
03cf7ad
commit 7617f9d
Showing
4 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@tokens-studio/sd-transforms': patch | ||
--- | ||
|
||
Pass colorspace to mix modifier, to use the correct color space to mix in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import Color from 'colorjs.io'; | ||
import { ColorSpaceTypes } from '@tokens-studio/types'; | ||
|
||
export function mix(color: Color, amount: number, mixColor: Color): Color { | ||
export function mix( | ||
color: Color, | ||
colorSpace: ColorSpaceTypes, | ||
amount: number, | ||
mixColor: Color, | ||
): Color { | ||
const mixValue = Math.max(0, Math.min(1, Number(amount))); | ||
|
||
return new Color(color.mix(mixColor, mixValue).toString()); | ||
return new Color(color.mix(mixColor, mixValue, { space: colorSpace }).toString()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters