@mintlify/common 1.0.1051 → 1.0.1053
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.
- package/dist/colors.d.ts +13 -2
- package/dist/colors.js +29 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -8
package/dist/colors.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { DocsConfig } from '@mintlify/validation';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export type RGBA = {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
a: number;
|
|
7
|
+
};
|
|
8
|
+
export type RgbaObject = {
|
|
9
|
+
red: number;
|
|
10
|
+
green: number;
|
|
11
|
+
blue: number;
|
|
12
|
+
alpha: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const hexRgb: (hex: string) => RgbaObject;
|
|
4
15
|
type TailwindColorScale = {
|
|
5
16
|
'50': string;
|
|
6
17
|
'100': string;
|
package/dist/colors.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const blendNormal = (backdrop, source) => {
|
|
2
|
+
const alpha = source.a + backdrop.a - source.a * backdrop.a;
|
|
3
|
+
if (alpha === 0)
|
|
4
|
+
return { r: 0, g: 0, b: 0, a: 0 };
|
|
5
|
+
const weight = source.a / alpha;
|
|
6
|
+
const channel = (b, s) => Math.round((1 - weight) * b + weight * s);
|
|
7
|
+
return {
|
|
8
|
+
r: channel(backdrop.r, source.r),
|
|
9
|
+
g: channel(backdrop.g, source.g),
|
|
10
|
+
b: channel(backdrop.b, source.b),
|
|
11
|
+
a: alpha,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export const hexRgb = (hex) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const match = (_a = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(hex)) === null || _a === void 0 ? void 0 : _a[1];
|
|
17
|
+
if (!match)
|
|
18
|
+
throw new TypeError(`Expected a valid hex string, got ${hex}`);
|
|
19
|
+
const value = match.length < 6 ? [...match].map((char) => char + char).join('') : match;
|
|
20
|
+
const num = Number.parseInt(value.slice(0, 6), 16);
|
|
21
|
+
return {
|
|
22
|
+
red: num >> 16,
|
|
23
|
+
green: (num >> 8) & 0xff,
|
|
24
|
+
blue: num & 0xff,
|
|
25
|
+
alpha: value.length === 8 ? Number.parseInt(value.slice(6, 8), 16) / 255 : 1,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
3
28
|
export const hexToRgbString = (hex) => {
|
|
4
29
|
try {
|
|
5
30
|
const rgb = hexRgb(hex);
|
|
@@ -27,11 +52,11 @@ export const generateDynamicBackgroundDarkColor = (primaryLight, backgroundDark,
|
|
|
27
52
|
export const combineColors = (color1, color1Opacity, color2, color2Opacity) => {
|
|
28
53
|
const color1Rgb = hexRgb(color1);
|
|
29
54
|
const color2Rgb = hexRgb(color2);
|
|
30
|
-
return
|
|
55
|
+
return blendNormal({ r: color1Rgb.red, g: color1Rgb.green, b: color1Rgb.blue, a: color1Opacity }, { r: color2Rgb.red, g: color2Rgb.green, b: color2Rgb.blue, a: color2Opacity });
|
|
31
56
|
};
|
|
32
57
|
export const generateDynamicGrayRgb = (primaryRgb, grayColor) => {
|
|
33
58
|
const grayRgb = hexRgb(grayColor);
|
|
34
|
-
const combinedGray =
|
|
59
|
+
const combinedGray = blendNormal({ r: primaryRgb.red, g: primaryRgb.green, b: primaryRgb.blue, a: 0.6 }, { r: grayRgb.red, g: grayRgb.green, b: grayRgb.blue, a: 0.95 });
|
|
35
60
|
return rgbToRgbString(combinedGray);
|
|
36
61
|
};
|
|
37
62
|
export const generateDynamicGrayScale = (primaryColor) => {
|