Skip to content

Commit

Permalink
stashed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlwizard committed Dec 8, 2024
1 parent 9e9a5e0 commit a511a5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"yoavbls.pretty-ts-errors",
"bradlc.vscode-tailwindcss",
"unifiedjs.vscode-mdx",
"github.vscode-github-actions"
"github.vscode-github-actions",
"aaron-bond.better-comments"
]
}
6 changes: 3 additions & 3 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ function token(

if (eq(typeof color, "string"))
// @ts-ignore:
result = eq(typeof color, "number")
? num2c()
: parseToken(c2str(), "rgb");
result = (typeof color === "number"
&& num2c())
|| parseToken(c2str(), "rgb");


// @ts-ignore:
Expand Down
6 changes: 5 additions & 1 deletion test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { diverging, sortBy, filterBy, stats, colors } from "./lib/index.ts";
import { mc, token } from "./lib/utils.ts";

// console.log(stats(colors('all', '600'), {
// factor: ['chroma', 'hue'], colorspace: 'lch'
// factor: ['chroma', 'hue'], colorspace: 'lch'zzzzzzz
// }))


Expand All @@ -16,6 +16,10 @@ import { mc, token } from "./lib/utils.ts";


//console.info(sortBy(['purple', 'blue'], { relative: true, factor: ['chroma', 'hue'] }))
// * fix this
// ! fix this
// ? fix this
// todo

//console.log(mc('rgb.b')(['rgb', 0.4, 0.3, 0.1]))
console.log(mc('lch.h')({ r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }))
Expand Down
18 changes: 11 additions & 7 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import runner, { type Spec } from "./runner.ts";



const str = '#ffc300', arr = ['rgb', 0.4, 0.3, 0.1], obj = { r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }, fn_mc = (a: string, b: string) => mc(a)(b)
const str = '#ffc3003f', arr = ['rgb', 0.4, 0.3, 0.1, 0.7], obj = { r: 0.2, g: 0.4, b: 0.5, mode: 'rgb' }, fn_mc = (a: string, b: string) => mc(a)(b)
const specs: Spec[] = [{
description: "converts an object to a number",
callback: token,
Expand All @@ -16,19 +16,19 @@ const specs: Spec[] = [{
params: [str, { kind: 'arr', targetMode: 'lab' }]
},
{
description: "converts an array to a hex string",
description: "converts an array to a 6 character hex string (without the alpha channel). ",
callback: token,
params: [arr, { kind: 'str' }]
params: [arr, { kind: 'str', omitAlpha: true }]
},
{
description: "converts an array to an object",
description: "converts an array to an object without alpha and mode properties",
callback: token,
params: [arr, { kind: 'obj' }]
params: [arr, { kind: 'obj', omitMode: true, omitAlpha: true }]
},
{
description: "converts an object to an array",
description: "converts an object to an array of channel values with no mode string.",
callback: token,
params: [obj, { kind: 'arr' }]
params: [obj, { kind: 'arr', omitMode: true }]
},
{
description: "converts an array to a number",
Expand All @@ -42,6 +42,10 @@ const specs: Spec[] = [{
description: 'gets the channel value of a color object',
callback: fn_mc,
params: ['lch.l', obj]
}, {
description: 'sets the channel value of a color object',
callback: fn_mc,
params: ['lch.h', obj, '*0.2']
}
];

Expand Down

0 comments on commit a511a5c

Please sign in to comment.