@mintlify/common 1.0.547 → 1.0.548
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/getBackgroundColors.d.ts +51 -0
- package/dist/getBackgroundColors.js +100 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DocsConfig } from '@mintlify/validation';
|
|
2
|
+
import { RGBA } from 'color-blend/dist/types.js';
|
|
3
|
+
import { RgbaObject } from 'hex-rgb';
|
|
4
|
+
type TailwindColorScale = {
|
|
5
|
+
'50': string;
|
|
6
|
+
'100': string;
|
|
7
|
+
'200': string;
|
|
8
|
+
'300': string;
|
|
9
|
+
'400': string;
|
|
10
|
+
'500': string;
|
|
11
|
+
'600': string;
|
|
12
|
+
'700': string;
|
|
13
|
+
'800': string;
|
|
14
|
+
'900': string;
|
|
15
|
+
'950': string;
|
|
16
|
+
};
|
|
17
|
+
export type Colors = {
|
|
18
|
+
primary: string;
|
|
19
|
+
primaryLight: string;
|
|
20
|
+
primaryDark: string;
|
|
21
|
+
backgroundLight: string;
|
|
22
|
+
backgroundDark: string;
|
|
23
|
+
bgLightHex: string;
|
|
24
|
+
bgDarkHex: string;
|
|
25
|
+
anchorDefault: string | undefined;
|
|
26
|
+
dropdownDefault: string | undefined;
|
|
27
|
+
gray: TailwindColorScale;
|
|
28
|
+
};
|
|
29
|
+
export declare const hexToRgbString: (hex: string) => string;
|
|
30
|
+
export declare const rgbToRgbString: (rgb: RGBA) => string;
|
|
31
|
+
export declare const rgbToHex: (rgb: RGBA) => string;
|
|
32
|
+
export declare const generateDynamicBackgroundDarkColor: (primaryLight: string, backgroundDark?: string, isHex?: boolean) => string;
|
|
33
|
+
export declare const combineColors: (color1: string, color1Opacity: number, color2: string, color2Opacity: number) => RGBA;
|
|
34
|
+
export declare const generateDynamicGrayRgb: (primaryRgb: RgbaObject, grayColor: string) => string;
|
|
35
|
+
export declare const generateDynamicGrayScale: (primaryColor: string) => TailwindColorScale;
|
|
36
|
+
/**
|
|
37
|
+
* The function `convertColorsToRgbWithCommas` takes a color string with spaces and converts it to RGB
|
|
38
|
+
* format with commas.
|
|
39
|
+
* @param {string} color - The `convertColorsToRgbWithCommas` function takes a color string as input
|
|
40
|
+
* and converts it to RGB format with commas separating the values. For example, if the input color is
|
|
41
|
+
* "255 0 128", the function will return "255, 0, 128".
|
|
42
|
+
*/
|
|
43
|
+
export declare const convertColorsToRgbWithCommas: (color: string) => string;
|
|
44
|
+
export declare function getBackgroundColors(docsConfig?: DocsConfig): {
|
|
45
|
+
light: string;
|
|
46
|
+
dark: string;
|
|
47
|
+
lightHex: string;
|
|
48
|
+
darkHex: string;
|
|
49
|
+
background: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { normal } from 'color-blend';
|
|
2
|
+
import hexRgb from 'hex-rgb';
|
|
3
|
+
export const hexToRgbString = (hex) => {
|
|
4
|
+
try {
|
|
5
|
+
const rgb = hexRgb(hex);
|
|
6
|
+
return `${rgb.red} ${rgb.green} ${rgb.blue}`;
|
|
7
|
+
}
|
|
8
|
+
catch (_a) {
|
|
9
|
+
return '0 0 0';
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const rgbToRgbString = (rgb) => {
|
|
13
|
+
return `${rgb.r} ${rgb.g} ${rgb.b}`;
|
|
14
|
+
};
|
|
15
|
+
export const rgbToHex = (rgb) => {
|
|
16
|
+
return `#${rgb.r.toString(16).padStart(2, '0')}${rgb.g.toString(16).padStart(2, '0')}${rgb.b
|
|
17
|
+
.toString(16)
|
|
18
|
+
.padStart(2, '0')}`;
|
|
19
|
+
};
|
|
20
|
+
export const generateDynamicBackgroundDarkColor = (primaryLight, backgroundDark, isHex) => {
|
|
21
|
+
if (backgroundDark) {
|
|
22
|
+
return isHex ? backgroundDark : hexToRgbString(backgroundDark);
|
|
23
|
+
}
|
|
24
|
+
const combinedBackground = combineColors('#09090b', 1, primaryLight, 0.02);
|
|
25
|
+
return isHex ? rgbToHex(combinedBackground) : rgbToRgbString(combinedBackground);
|
|
26
|
+
};
|
|
27
|
+
export const combineColors = (color1, color1Opacity, color2, color2Opacity) => {
|
|
28
|
+
const color1Rgb = hexRgb(color1);
|
|
29
|
+
const color2Rgb = hexRgb(color2);
|
|
30
|
+
return normal({ r: color1Rgb.red, g: color1Rgb.green, b: color1Rgb.blue, a: color1Opacity }, { r: color2Rgb.red, g: color2Rgb.green, b: color2Rgb.blue, a: color2Opacity });
|
|
31
|
+
};
|
|
32
|
+
export const generateDynamicGrayRgb = (primaryRgb, grayColor) => {
|
|
33
|
+
const grayRgb = hexRgb(grayColor);
|
|
34
|
+
const combinedGray = normal({ 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
|
+
return rgbToRgbString(combinedGray);
|
|
36
|
+
};
|
|
37
|
+
export const generateDynamicGrayScale = (primaryColor) => {
|
|
38
|
+
const neutralScale = {
|
|
39
|
+
'50': '#fafafa',
|
|
40
|
+
'100': '#f5f5f5',
|
|
41
|
+
'200': '#e5e5e5',
|
|
42
|
+
'300': '#d4d4d4',
|
|
43
|
+
'400': '#a3a3a3',
|
|
44
|
+
'500': '#737373',
|
|
45
|
+
'600': '#525252',
|
|
46
|
+
'700': '#404040',
|
|
47
|
+
'800': '#262626',
|
|
48
|
+
'900': '#171717',
|
|
49
|
+
'950': '#0a0a0a',
|
|
50
|
+
};
|
|
51
|
+
const primaryRgb = hexRgb(primaryColor);
|
|
52
|
+
return {
|
|
53
|
+
'50': generateDynamicGrayRgb(primaryRgb, neutralScale[50]),
|
|
54
|
+
'100': generateDynamicGrayRgb(primaryRgb, neutralScale[100]),
|
|
55
|
+
'200': generateDynamicGrayRgb(primaryRgb, neutralScale[200]),
|
|
56
|
+
'300': generateDynamicGrayRgb(primaryRgb, neutralScale[300]),
|
|
57
|
+
'400': generateDynamicGrayRgb(primaryRgb, neutralScale[400]),
|
|
58
|
+
'500': generateDynamicGrayRgb(primaryRgb, neutralScale[500]),
|
|
59
|
+
'600': generateDynamicGrayRgb(primaryRgb, neutralScale[600]),
|
|
60
|
+
'700': generateDynamicGrayRgb(primaryRgb, neutralScale[700]),
|
|
61
|
+
'800': generateDynamicGrayRgb(primaryRgb, neutralScale[800]),
|
|
62
|
+
'900': generateDynamicGrayRgb(primaryRgb, neutralScale[900]),
|
|
63
|
+
'950': generateDynamicGrayRgb(primaryRgb, neutralScale[950]),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The function `convertColorsToRgbWithCommas` takes a color string with spaces and converts it to RGB
|
|
68
|
+
* format with commas.
|
|
69
|
+
* @param {string} color - The `convertColorsToRgbWithCommas` function takes a color string as input
|
|
70
|
+
* and converts it to RGB format with commas separating the values. For example, if the input color is
|
|
71
|
+
* "255 0 128", the function will return "255, 0, 128".
|
|
72
|
+
*/
|
|
73
|
+
export const convertColorsToRgbWithCommas = (color) => {
|
|
74
|
+
return color.split(' ').join(', ');
|
|
75
|
+
};
|
|
76
|
+
export function getBackgroundColors(docsConfig) {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
78
|
+
const primaryColor = (docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.colors.primary) || '#16A34A';
|
|
79
|
+
const primaryLight = (_a = docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.colors.light) !== null && _a !== void 0 ? _a : '#4ADE80';
|
|
80
|
+
if ((docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.theme) === 'linden') {
|
|
81
|
+
docsConfig.background = Object.assign(Object.assign({}, docsConfig.background), { color: {
|
|
82
|
+
light: ((_c = (_b = docsConfig.background) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c.light) ||
|
|
83
|
+
rgbToHex(combineColors('#FFFFFF', 1, primaryColor, 0.03)),
|
|
84
|
+
dark: ((_e = (_d = docsConfig.background) === null || _d === void 0 ? void 0 : _d.color) === null || _e === void 0 ? void 0 : _e.dark) ||
|
|
85
|
+
rgbToHex(combineColors('#09090B', 1, primaryLight, 0.03)),
|
|
86
|
+
} });
|
|
87
|
+
}
|
|
88
|
+
const lightHex = (_h = (_g = (_f = docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.background) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g.light) !== null && _h !== void 0 ? _h : '#ffffff';
|
|
89
|
+
const light = hexToRgbString(lightHex);
|
|
90
|
+
const dark = generateDynamicBackgroundDarkColor(primaryLight, (_k = (_j = docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.background) === null || _j === void 0 ? void 0 : _j.color) === null || _k === void 0 ? void 0 : _k.dark);
|
|
91
|
+
const darkHex = generateDynamicBackgroundDarkColor(primaryLight, (_m = (_l = docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.background) === null || _l === void 0 ? void 0 : _l.color) === null || _m === void 0 ? void 0 : _m.dark, true);
|
|
92
|
+
const background = (_o = docsConfig === null || docsConfig === void 0 ? void 0 : docsConfig.thumbnails) === null || _o === void 0 ? void 0 : _o.background;
|
|
93
|
+
return {
|
|
94
|
+
light,
|
|
95
|
+
dark,
|
|
96
|
+
lightHex,
|
|
97
|
+
darkHex,
|
|
98
|
+
background,
|
|
99
|
+
};
|
|
100
|
+
}
|
package/dist/index.d.ts
CHANGED