Skip to content

Commit

Permalink
fix: family() now works as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlwizard committed Dec 17, 2024
1 parent fc0d6eb commit c2eaf67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "culori/css";
import {
adjustHue,
and,
customConcat,

eq,
exprParser,
floorCeil,
Expand Down Expand Up @@ -676,21 +676,21 @@ console.log(family("#310000"))
// 'red'
*/
function family(color?: ColorToken): BiasedHues & ColorFamily {
if (!(achromatic(color))) {
const [hueAngle, hueFamilies] = [
mc("lch.h")(color),
hue.map(arr => arr[0])
];
console.log(hueAngle, hueFamilies)

if (!achromatic(color))





// @ts-ignore:
return hueFamilies.find((o) => {
return hue.find((arr) => {
// @ts-ignore:
const hueRanges = customConcat(hue[o]);
const hueRanges = arr.slice(1).flat(1) as number[]

return inRange(mc("lch.h")(color), min(hueRanges), max(hueRanges))
})[0];

console.log(hueRanges)
return inRange(hueAngle, min(hueRanges), max(hueRanges));
});
}

// @ts-ignore:
return "gray";
Expand Down
6 changes: 3 additions & 3 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { alpha, mc, token } from "../lib/utils.ts";
import { alpha, family, mc, token } from "../lib/utils.ts";
import runner, { type Spec } from "./runner.ts";


Expand Down Expand Up @@ -91,9 +91,9 @@ const specs: Spec[] = [{
callback: alpha, params: [str]
},
{
description: 'sets the ',
description: 'gets the hue family of a color token',
params: [str],
callback: undefined
callback: family
}
];

Expand Down

0 comments on commit c2eaf67

Please sign in to comment.