@alveole/theme 0.37.3 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { Color } from '../constants';
2
+ type Between0And1 = number;
3
+ type HexColor = `#${string}`;
4
+ export declare const darken: (hexadecimalColor: Color, amount: Between0And1) => HexColor;
5
+ export {};
6
+ //# sourceMappingURL=darkenColor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"darkenColor.d.ts","sourceRoot":"","sources":["../../src/helpers/darkenColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,KAAK,YAAY,GAAG,MAAM,CAAC;AAC3B,KAAK,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAC;AAE7B,eAAO,MAAM,MAAM,GAAI,kBAAkB,KAAK,EAAE,QAAQ,YAAY,KAAG,QAYtE,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const darken = (hexadecimalColor, amount) => {
2
+ hexadecimalColor = hexadecimalColor.replace(/^#/, '');
3
+ if (hexadecimalColor.length === 3)
4
+ hexadecimalColor = hexadecimalColor
5
+ .split('')
6
+ .map(c => c + c)
7
+ .join('');
8
+ if (hexadecimalColor.length !== 6)
9
+ throw new Error('Invalid hex color');
10
+ const r = Math.max(0, parseInt(hexadecimalColor.slice(0, 2), 16) - Math.round(255 * amount));
11
+ const g = Math.max(0, parseInt(hexadecimalColor.slice(2, 4), 16) - Math.round(255 * amount));
12
+ const b = Math.max(0, parseInt(hexadecimalColor.slice(4, 6), 16) - Math.round(255 * amount));
13
+ return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alveole/theme",
3
- "version": "0.37.3",
3
+ "version": "0.38.1",
4
4
  "description": "Shared theme tokens and utilities.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",