Skip to content

Commit 696da76

Browse files
committed
add esm support from tocolor
1 parent ee7ccd2 commit 696da76

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"typecheck": "tsc --noEmit"
4949
},
5050
"dependencies": {
51-
"@barelyhuman/tocolor": "^0.0.7"
51+
"@barelyhuman/tocolor": "^0.0.8"
5252
},
5353
"devDependencies": {
5454
"@antfu/eslint-config": "^0.18.9",

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { hexToHSL, hslToHex } from '@barelyhuman/tocolor'
1+
import { hexToHSL, hslToHex } from "@barelyhuman/tocolor";
22

33
function lighter(percentage: number, color: string) {
4-
if (isNaN(percentage)) return color
5-
const { h, s, l } = hexToHSL(color)
6-
let _afterLighten = l + percentage
7-
if (_afterLighten > 100) _afterLighten = 100
8-
return hslToHex(h, s, _afterLighten)
4+
if (isNaN(percentage)) return color;
5+
const { h, s, l } = hexToHSL(color);
6+
let _afterLighten = l + percentage;
7+
if (_afterLighten > 100) _afterLighten = 100;
8+
return hslToHex(h, s, _afterLighten);
99
}
1010

1111
interface TintColorMap {
12-
base: string
13-
tones: number[]
12+
base: string;
13+
tones: number[];
1414
}
1515

1616
export function makeTints(toTint: TintColorMap[]) {
17-
const result = []
17+
const result = [];
1818
for (let i = 0; i < toTint.length; i++) {
19-
const toTintItem = toTint[i]
19+
const toTintItem = toTint[i];
2020
const _item: { base: string; [key: number]: string } = {
2121
base: lighter(0, toTintItem.base),
22-
}
22+
};
2323
toTintItem.tones.forEach((tone) => {
24-
const per = 100 - tone
25-
_item[tone] = lighter(per >= 0 ? per : 0, toTintItem.base)
26-
})
24+
const per = 100 - tone;
25+
_item[tone] = lighter(per >= 0 ? per : 0, toTintItem.base);
26+
});
2727

28-
result.push(_item)
28+
result.push(_item);
2929
}
30-
return result
30+
return result;
3131
}

0 commit comments

Comments
 (0)