@lobehub/ui 1.1.0
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/LICENSE +21 -0
- package/README.md +144 -0
- package/es/ActionIcon/index.d.ts +15 -0
- package/es/ActionIcon/index.js +84 -0
- package/es/DraggablePanel/index.d.ts +26 -0
- package/es/DraggablePanel/index.js +197 -0
- package/es/DraggablePanel/style.d.ts +18 -0
- package/es/DraggablePanel/style.js +30 -0
- package/es/DraggablePanel/utils.d.ts +2 -0
- package/es/DraggablePanel/utils.js +12 -0
- package/es/Logo/Logo3D.d.ts +4 -0
- package/es/Logo/Logo3D.js +11 -0
- package/es/Logo/LogoFlat.d.ts +4 -0
- package/es/Logo/LogoFlat.js +104 -0
- package/es/Logo/LogoHighContrast.d.ts +4 -0
- package/es/Logo/LogoHighContrast.js +26 -0
- package/es/Logo/LogoText.d.ts +4 -0
- package/es/Logo/LogoText.js +18 -0
- package/es/Logo/index.d.ts +8 -0
- package/es/Logo/index.js +54 -0
- package/es/SideNav/index.d.ts +9 -0
- package/es/SideNav/index.js +44 -0
- package/es/Template/index.d.ts +7 -0
- package/es/Template/index.js +15 -0
- package/es/ThemeProvider/GlobalStyle.d.ts +3 -0
- package/es/ThemeProvider/GlobalStyle.js +19 -0
- package/es/ThemeProvider/index.d.ts +11 -0
- package/es/ThemeProvider/index.js +40 -0
- package/es/ThemeProvider/token.d.ts +3 -0
- package/es/ThemeProvider/token.js +45 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +6 -0
- package/es/styles/algorithms/colorRelationship.d.ts +6 -0
- package/es/styles/algorithms/colorRelationship.js +88 -0
- package/es/styles/algorithms/index.d.ts +15 -0
- package/es/styles/algorithms/index.js +67 -0
- package/es/styles/algorithms/paletteGenerator.d.ts +51 -0
- package/es/styles/algorithms/paletteGenerator.js +74 -0
- package/es/styles/antdTheme.d.ts +2 -0
- package/es/styles/antdTheme.js +4 -0
- package/es/styles/customStylish.d.ts +17 -0
- package/es/styles/customStylish.js +19 -0
- package/es/styles/customToken.d.ts +65 -0
- package/es/styles/customToken.js +24 -0
- package/es/styles/index.d.ts +3 -0
- package/es/styles/index.js +3 -0
- package/es/styles/theme/dark.d.ts +4 -0
- package/es/styles/theme/dark.js +82 -0
- package/es/styles/theme/index.d.ts +2 -0
- package/es/styles/theme/index.js +2 -0
- package/es/styles/theme/light.d.ts +4 -0
- package/es/styles/theme/light.js +36 -0
- package/es/types/index.d.ts +9 -0
- package/es/types/index.js +1 -0
- package/es/utils/colorUtils.d.ts +1 -0
- package/es/utils/colorUtils.js +10 -0
- package/lib/ActionIcon/index.d.ts +15 -0
- package/lib/ActionIcon/index.js +110 -0
- package/lib/DraggablePanel/index.d.ts +26 -0
- package/lib/DraggablePanel/index.js +217 -0
- package/lib/DraggablePanel/style.d.ts +18 -0
- package/lib/DraggablePanel/style.js +287 -0
- package/lib/DraggablePanel/utils.d.ts +2 -0
- package/lib/DraggablePanel/utils.js +40 -0
- package/lib/Logo/Logo3D.d.ts +4 -0
- package/lib/Logo/Logo3D.js +45 -0
- package/lib/Logo/LogoFlat.d.ts +4 -0
- package/lib/Logo/LogoFlat.js +130 -0
- package/lib/Logo/LogoHighContrast.d.ts +4 -0
- package/lib/Logo/LogoHighContrast.js +58 -0
- package/lib/Logo/LogoText.d.ts +4 -0
- package/lib/Logo/LogoText.js +49 -0
- package/lib/Logo/index.d.ts +8 -0
- package/lib/Logo/index.js +54 -0
- package/lib/SideNav/index.d.ts +9 -0
- package/lib/SideNav/index.js +58 -0
- package/lib/Template/index.d.ts +7 -0
- package/lib/Template/index.js +41 -0
- package/lib/ThemeProvider/GlobalStyle.d.ts +3 -0
- package/lib/ThemeProvider/GlobalStyle.js +80 -0
- package/lib/ThemeProvider/index.d.ts +11 -0
- package/lib/ThemeProvider/index.js +68 -0
- package/lib/ThemeProvider/token.d.ts +3 -0
- package/lib/ThemeProvider/token.js +73 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +54 -0
- package/lib/styles/algorithms/colorRelationship.d.ts +6 -0
- package/lib/styles/algorithms/colorRelationship.js +87 -0
- package/lib/styles/algorithms/index.d.ts +15 -0
- package/lib/styles/algorithms/index.js +81 -0
- package/lib/styles/algorithms/paletteGenerator.d.ts +51 -0
- package/lib/styles/algorithms/paletteGenerator.js +91 -0
- package/lib/styles/antdTheme.d.ts +2 -0
- package/lib/styles/antdTheme.js +30 -0
- package/lib/styles/customStylish.d.ts +17 -0
- package/lib/styles/customStylish.js +117 -0
- package/lib/styles/customToken.d.ts +65 -0
- package/lib/styles/customToken.js +54 -0
- package/lib/styles/index.d.ts +3 -0
- package/lib/styles/index.js +21 -0
- package/lib/styles/theme/dark.d.ts +4 -0
- package/lib/styles/theme/dark.js +131 -0
- package/lib/styles/theme/index.d.ts +2 -0
- package/lib/styles/theme/index.js +32 -0
- package/lib/styles/theme/light.d.ts +4 -0
- package/lib/styles/theme/light.js +64 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/index.js +17 -0
- package/lib/utils/colorUtils.d.ts +1 -0
- package/lib/utils/colorUtils.js +52 -0
- package/package.json +122 -0
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ActionIcon, type ActionIconProps } from './ActionIcon';
|
|
2
|
+
export { default as DraggablePanel, type DraggablePanelProps } from './DraggablePanel';
|
|
3
|
+
export { default as Logo } from './Logo';
|
|
4
|
+
export { default as SideNav, type SideNavProps } from './SideNav';
|
|
5
|
+
export { default as Template, type TemplateProps } from './Template';
|
|
6
|
+
export { default as ThemeProvider } from './ThemeProvider';
|
package/es/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ActionIcon } from "./ActionIcon";
|
|
2
|
+
export { default as DraggablePanel } from "./DraggablePanel";
|
|
3
|
+
export { default as Logo } from "./Logo";
|
|
4
|
+
export { default as SideNav } from "./SideNav";
|
|
5
|
+
export { default as Template } from "./Template";
|
|
6
|
+
export { default as ThemeProvider } from "./ThemeProvider";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import chroma from 'chroma-js';
|
|
3
|
+
var baseColors = [{
|
|
4
|
+
name: 'red',
|
|
5
|
+
hue: 0
|
|
6
|
+
}, {
|
|
7
|
+
name: 'orange',
|
|
8
|
+
hue: 30
|
|
9
|
+
}, {
|
|
10
|
+
name: 'yellow',
|
|
11
|
+
hue: 60
|
|
12
|
+
}, {
|
|
13
|
+
name: 'yellow-green',
|
|
14
|
+
hue: 90
|
|
15
|
+
}, {
|
|
16
|
+
name: 'green',
|
|
17
|
+
hue: 120
|
|
18
|
+
}, {
|
|
19
|
+
name: 'cyan-green',
|
|
20
|
+
hue: 150
|
|
21
|
+
}, {
|
|
22
|
+
name: 'cyan',
|
|
23
|
+
hue: 180
|
|
24
|
+
}, {
|
|
25
|
+
name: 'cyan-blue',
|
|
26
|
+
hue: 210
|
|
27
|
+
}, {
|
|
28
|
+
name: 'blue',
|
|
29
|
+
hue: 240
|
|
30
|
+
}, {
|
|
31
|
+
name: 'blue-violet',
|
|
32
|
+
hue: 270
|
|
33
|
+
}, {
|
|
34
|
+
name: 'violet',
|
|
35
|
+
hue: 300
|
|
36
|
+
}, {
|
|
37
|
+
name: 'red-violet',
|
|
38
|
+
hue: 330
|
|
39
|
+
}];
|
|
40
|
+
var findClosestColorBase = function findClosestColorBase(hue) {
|
|
41
|
+
var minDifference = 360;
|
|
42
|
+
var closestColorBase = {
|
|
43
|
+
name: '',
|
|
44
|
+
hue: 0
|
|
45
|
+
};
|
|
46
|
+
baseColors.forEach(function (colorBase) {
|
|
47
|
+
var hueDifference = Math.abs(hue - colorBase.hue);
|
|
48
|
+
var adjustedDifference = Math.min(hueDifference, 360 - hueDifference);
|
|
49
|
+
if (adjustedDifference < minDifference) {
|
|
50
|
+
minDifference = adjustedDifference;
|
|
51
|
+
closestColorBase = colorBase;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return closestColorBase.hue;
|
|
55
|
+
};
|
|
56
|
+
export var generateAssociatedColors = function generateAssociatedColors(baseColor) {
|
|
57
|
+
var adjustWarning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
58
|
+
var color = chroma(baseColor);
|
|
59
|
+
var _color$oklch = color.oklch(),
|
|
60
|
+
_color$oklch2 = _slicedToArray(_color$oklch, 3),
|
|
61
|
+
baseLightness = _color$oklch2[0],
|
|
62
|
+
baseChroma = _color$oklch2[1],
|
|
63
|
+
baseHue = _color$oklch2[2];
|
|
64
|
+
var closestColorHue = findClosestColorBase(baseHue);
|
|
65
|
+
|
|
66
|
+
// 计算色相偏移量
|
|
67
|
+
// const hueOffset = 0;
|
|
68
|
+
var hueOffset = baseHue - closestColorHue;
|
|
69
|
+
|
|
70
|
+
// 应用色相偏移量
|
|
71
|
+
|
|
72
|
+
var successBaseHue = 150; // 绿色基准色相值
|
|
73
|
+
var errorBaseHue = 30; // 红色基准色相值
|
|
74
|
+
var warningBaseHue = 90; // 黄色基准色相值
|
|
75
|
+
var infoBaseHue = 255; // 蓝色基准色相值
|
|
76
|
+
|
|
77
|
+
var successHue = (successBaseHue + hueOffset) % 360;
|
|
78
|
+
var errorHue = (errorBaseHue + hueOffset) % 360;
|
|
79
|
+
var warningHue = (warningBaseHue + hueOffset) % 360;
|
|
80
|
+
var infoHue = (infoBaseHue + hueOffset) % 360;
|
|
81
|
+
var warningLightness = adjustWarning ? 0.8 + baseLightness * 0.2 : baseLightness;
|
|
82
|
+
return {
|
|
83
|
+
success: chroma.oklch(baseLightness, baseChroma, successHue).hex(),
|
|
84
|
+
error: chroma.oklch(baseLightness, baseChroma, errorHue).hex(),
|
|
85
|
+
warning: chroma.oklch(warningLightness, baseChroma, warningHue).hex(),
|
|
86
|
+
info: chroma.oklch(baseLightness, baseChroma, infoHue).hex()
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColorMapToken } from 'antd/es/theme/interface/maps/colors';
|
|
2
|
+
import { ColorPalettes, NeutralPaletteOptions, SeedColors, TokenType } from './paletteGenerator';
|
|
3
|
+
export declare type TokenRelationship = (type: TokenType) => Partial<Record<keyof ColorMapToken, number>>;
|
|
4
|
+
interface MapTokenAlgorithm extends NeutralPaletteOptions {
|
|
5
|
+
relationship?: TokenRelationship;
|
|
6
|
+
seedColors?: Partial<SeedColors>;
|
|
7
|
+
infoColorFollowPrimary?: boolean;
|
|
8
|
+
adjustWarning?: boolean;
|
|
9
|
+
brandColor?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const genMapTokenAlgorithm: (mode: 'dark' | 'light', params?: MapTokenAlgorithm) => {
|
|
12
|
+
palettes: ColorPalettes;
|
|
13
|
+
tokens: Partial<Record<keyof ColorMapToken, string>>;
|
|
14
|
+
};
|
|
15
|
+
export type { ColorPalettes } from './paletteGenerator';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
import { generateAssociatedColors } from "./colorRelationship";
|
|
6
|
+
import { generateColorPalette, generateNeutralPalette } from "./paletteGenerator";
|
|
7
|
+
var defaultRelationship = function defaultRelationship(type) {
|
|
8
|
+
var _ref;
|
|
9
|
+
var key = type.toUpperCase()[0] + type.slice(1);
|
|
10
|
+
return _ref = {}, _defineProperty(_ref, "color".concat(key, "Bg"), 1), _defineProperty(_ref, "color".concat(key, "BgHover"), 2), _defineProperty(_ref, "color".concat(key, "Border"), 3), _defineProperty(_ref, "color".concat(key, "BorderHover"), 4), _defineProperty(_ref, "color".concat(key, "Hover"), 5), _defineProperty(_ref, "color".concat(key), 6), _defineProperty(_ref, "color".concat(key, "Active"), 7), _defineProperty(_ref, "color".concat(key, "TextHover"), 8), _defineProperty(_ref, "color".concat(key, "Text"), 9), _defineProperty(_ref, "color".concat(key, "TextActive"), 10), _ref;
|
|
11
|
+
};
|
|
12
|
+
export var genMapTokenAlgorithm = function genMapTokenAlgorithm(mode, params) {
|
|
13
|
+
var _ref2 = params || {},
|
|
14
|
+
_ref2$relationship = _ref2.relationship,
|
|
15
|
+
relationship = _ref2$relationship === void 0 ? defaultRelationship : _ref2$relationship,
|
|
16
|
+
_ref2$infoColorFollow = _ref2.infoColorFollowPrimary,
|
|
17
|
+
infoColorFollowPrimary = _ref2$infoColorFollow === void 0 ? false : _ref2$infoColorFollow,
|
|
18
|
+
adjustWarning = _ref2.adjustWarning,
|
|
19
|
+
_ref2$brandColor = _ref2.brandColor,
|
|
20
|
+
brandColor = _ref2$brandColor === void 0 ? mode === 'dark' ? '#fff' : '#000' : _ref2$brandColor;
|
|
21
|
+
var funcColors = generateAssociatedColors(brandColor, adjustWarning);
|
|
22
|
+
var seedColors = _objectSpread(_objectSpread({
|
|
23
|
+
primary: brandColor
|
|
24
|
+
}, funcColors), params === null || params === void 0 ? void 0 : params.seedColors);
|
|
25
|
+
if (infoColorFollowPrimary) {
|
|
26
|
+
seedColors.info = brandColor;
|
|
27
|
+
}
|
|
28
|
+
var palettes = {
|
|
29
|
+
primary: generateColorPalette(seedColors.primary, params).map(function (color) {
|
|
30
|
+
return color.hex;
|
|
31
|
+
}),
|
|
32
|
+
error: generateColorPalette(seedColors.error, params).map(function (c) {
|
|
33
|
+
return c.hex;
|
|
34
|
+
}),
|
|
35
|
+
warning: generateColorPalette(seedColors.warning, params).map(function (c) {
|
|
36
|
+
return c.hex;
|
|
37
|
+
}),
|
|
38
|
+
success: generateColorPalette(seedColors.success, params).map(function (c) {
|
|
39
|
+
return c.hex;
|
|
40
|
+
}),
|
|
41
|
+
info: generateColorPalette(seedColors.info, params).map(function (color) {
|
|
42
|
+
return color.hex;
|
|
43
|
+
}),
|
|
44
|
+
neutral: generateNeutralPalette(seedColors.primary, _objectSpread(_objectSpread({}, params), {}, {
|
|
45
|
+
neutral: true
|
|
46
|
+
})).map(function (c) {
|
|
47
|
+
return c.hex;
|
|
48
|
+
}),
|
|
49
|
+
grey: generateNeutralPalette(seedColors.primary, params).map(function (c) {
|
|
50
|
+
return c.hex;
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
var tokens = {};
|
|
54
|
+
var types = ['primary', 'error', 'warning', 'success', 'info'];
|
|
55
|
+
types.forEach(function (type) {
|
|
56
|
+
Object.entries(relationship(type)).forEach(function (_ref3) {
|
|
57
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
58
|
+
key = _ref4[0],
|
|
59
|
+
value = _ref4[1];
|
|
60
|
+
tokens[key] = palettes[type][value];
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
palettes: palettes,
|
|
65
|
+
tokens: tokens
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface Color {
|
|
2
|
+
hex: string;
|
|
3
|
+
oklch: [number, number, number];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @title 阴影参数
|
|
7
|
+
*/
|
|
8
|
+
interface AdjustParams {
|
|
9
|
+
/**
|
|
10
|
+
* @title 步骤
|
|
11
|
+
* @description 阴影的层数,即需要生成几个阴影层,默认为 5。
|
|
12
|
+
*/
|
|
13
|
+
steps: number;
|
|
14
|
+
/**
|
|
15
|
+
* @title 目标亮度
|
|
16
|
+
* @description 阴影的最终亮度值,取值范围为 0~255,默认为 0。
|
|
17
|
+
*/
|
|
18
|
+
targetBrightness: number;
|
|
19
|
+
/**
|
|
20
|
+
* @title 色相调整
|
|
21
|
+
* @description 调整阴影颜色的色相值,取值范围为 -180~180,默认为 0。
|
|
22
|
+
*/
|
|
23
|
+
hueAdjustment: number;
|
|
24
|
+
/**
|
|
25
|
+
* @title 饱和度调整
|
|
26
|
+
* @description 调整阴影颜色的饱和度值,取值范围为 -100~100,默认为 0。
|
|
27
|
+
*/
|
|
28
|
+
saturationAdjustment: number;
|
|
29
|
+
/**
|
|
30
|
+
* @title 饱和度缩放
|
|
31
|
+
* @description 缩放阴影颜色的饱和度值,取值范围为 0~1,默认为 1。
|
|
32
|
+
*/
|
|
33
|
+
saturationScale: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ColorPaletteOptions {
|
|
36
|
+
lighter?: Partial<AdjustParams>;
|
|
37
|
+
darker?: Partial<AdjustParams>;
|
|
38
|
+
reverse?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare type TokenType = 'primary' | 'success' | 'warning' | 'error' | 'info' | 'grey' | 'neutral';
|
|
41
|
+
export declare type ColorPalettes = Record<TokenType, string[]>;
|
|
42
|
+
export declare type SeedColors = Record<TokenType, string>;
|
|
43
|
+
export declare const generateColorPalette: (baseColorHex: string, options?: ColorPaletteOptions) => Color[];
|
|
44
|
+
export interface NeutralPaletteOptions {
|
|
45
|
+
lighter?: Partial<AdjustParams>;
|
|
46
|
+
darker?: Partial<AdjustParams>;
|
|
47
|
+
reverse?: boolean;
|
|
48
|
+
neutral?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare const generateNeutralPalette: (baseColorHex: string, options?: NeutralPaletteOptions) => Color[];
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import chroma from 'chroma-js';
|
|
2
|
+
import { merge } from 'lodash';
|
|
3
|
+
var defaultLight = {
|
|
4
|
+
steps: 6,
|
|
5
|
+
targetBrightness: 0.98,
|
|
6
|
+
saturationAdjustment: 0.4,
|
|
7
|
+
saturationScale: 1.6,
|
|
8
|
+
hueAdjustment: 1
|
|
9
|
+
};
|
|
10
|
+
var defaultDark = {
|
|
11
|
+
steps: 4,
|
|
12
|
+
targetBrightness: 0.3,
|
|
13
|
+
saturationAdjustment: 0.6,
|
|
14
|
+
saturationScale: 1.6,
|
|
15
|
+
hueAdjustment: 1.03
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 生成 OKLCH 色板
|
|
19
|
+
export var generateColorPalette = function generateColorPalette(baseColorHex) {
|
|
20
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
var lighter = merge({}, defaultLight, options.lighter);
|
|
22
|
+
var darker = merge({}, defaultDark, options.darker);
|
|
23
|
+
var baseColor = chroma(baseColorHex);
|
|
24
|
+
var baseColorOKLCH = baseColor.oklch();
|
|
25
|
+
var colorPalette = [];
|
|
26
|
+
for (var i = lighter.steps; i > 0; i--) {
|
|
27
|
+
var lightness = baseColorOKLCH[0] + (lighter.targetBrightness - baseColorOKLCH[0]) / lighter.steps * i;
|
|
28
|
+
var chromaValue = baseColorOKLCH[1] - (1 - lighter.saturationAdjustment) * lighter.saturationScale * baseColorOKLCH[1] / lighter.steps * i;
|
|
29
|
+
var newColor = chroma.oklch(lightness, chromaValue, baseColorOKLCH[2]);
|
|
30
|
+
colorPalette.push({
|
|
31
|
+
hex: newColor.hex(),
|
|
32
|
+
oklch: newColor.oklch()
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
colorPalette.push({
|
|
36
|
+
hex: baseColorHex,
|
|
37
|
+
oklch: baseColorOKLCH
|
|
38
|
+
});
|
|
39
|
+
for (var _i = 1; _i <= darker.steps; _i++) {
|
|
40
|
+
var _lightness = baseColorOKLCH[0] - (baseColorOKLCH[0] - darker.targetBrightness) / darker.steps * _i;
|
|
41
|
+
var _chromaValue = baseColorOKLCH[1] - (1 - darker.saturationAdjustment) * darker.saturationScale * baseColorOKLCH[1] / darker.steps * _i;
|
|
42
|
+
|
|
43
|
+
// 色相调整因子
|
|
44
|
+
var hue = baseColorOKLCH[2] * darker.hueAdjustment;
|
|
45
|
+
|
|
46
|
+
// 确保色相值在 0 到 360 之间
|
|
47
|
+
if (hue > 360) {
|
|
48
|
+
hue = hue % 360;
|
|
49
|
+
} else if (hue < 0) {
|
|
50
|
+
hue = 360 + hue % 360;
|
|
51
|
+
}
|
|
52
|
+
var _newColor = chroma.oklch(_lightness, _chromaValue, hue);
|
|
53
|
+
colorPalette.push({
|
|
54
|
+
hex: _newColor.hex(),
|
|
55
|
+
oklch: _newColor.oklch()
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return options.reverse ? colorPalette.reverse() : colorPalette;
|
|
59
|
+
};
|
|
60
|
+
export var generateNeutralPalette = function generateNeutralPalette(baseColorHex) {
|
|
61
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
62
|
+
var baseColor = chroma(baseColorHex);
|
|
63
|
+
var baseColorOKLCH = baseColor.oklch();
|
|
64
|
+
|
|
65
|
+
// 计算中性颜色的色相
|
|
66
|
+
var neutralHue = baseColorOKLCH[2];
|
|
67
|
+
|
|
68
|
+
// 将主色的饱和度降低以获得中性颜色
|
|
69
|
+
var neutralChromaValue = options.neutral ? baseColorOKLCH[1] * 0.2 : 0;
|
|
70
|
+
|
|
71
|
+
// 使用降低饱和度的颜色作为基础色重新生成色板
|
|
72
|
+
var neutralBaseColor = chroma.oklch(baseColorOKLCH[0], neutralChromaValue, neutralHue);
|
|
73
|
+
return generateColorPalette(neutralBaseColor.hex(), options);
|
|
74
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GetCustomStylish } from 'antd-style';
|
|
2
|
+
declare module 'antd-style' {
|
|
3
|
+
interface CustomStylish extends SiteStylish {
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export interface SiteStylish {
|
|
7
|
+
clickableText: string;
|
|
8
|
+
resetLinkColor: string;
|
|
9
|
+
heroButtonGradient: string;
|
|
10
|
+
heroGradient: string;
|
|
11
|
+
heroTextShadow: string;
|
|
12
|
+
heroGradientFlow: string;
|
|
13
|
+
heroBlurBall: string;
|
|
14
|
+
iconGradientDefault: string;
|
|
15
|
+
blur: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const getCustomStylish: GetCustomStylish<SiteStylish>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
3
|
+
import { rgba } from 'polished';
|
|
4
|
+
export var getCustomStylish = function getCustomStylish(_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
isDarkMode = _ref.isDarkMode;
|
|
8
|
+
return {
|
|
9
|
+
clickableText: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n "])), token.colorTextSecondary, token.colorText),
|
|
10
|
+
resetLinkColor: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: inherit;\n\n &:hover,\n &:active {\n color: inherit;\n }\n "]))),
|
|
11
|
+
heroButtonGradient: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: linear-gradient(90deg, ", " 0%, ", " 100%);\n "])), token.gradientColor1, token.gradientColor2),
|
|
12
|
+
heroGradient: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-image: ", ";\n background-size: 300% 300%;\n "])), token.gradientHeroBgG),
|
|
13
|
+
heroGradientFlow: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n animation: flow 5s ease infinite;\n\n @keyframes flow {\n 0% {\n background-position: 0 0;\n }\n\n 50% {\n background-position: 100% 100%;\n }\n\n 100% {\n background-position: 0 0;\n }\n }\n "]))),
|
|
14
|
+
heroTextShadow: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n will-change: transform;\n\n text-shadow: 0 8px 20px ", ",\n 0 8px 60px ", ",\n 0 8px 80px ", ";\n "])), rgba(token.gradientColor2, 0.2), rgba(token.gradientColor3, 0.2), rgba(token.cyan, isDarkMode ? 0.2 : 0.4)),
|
|
15
|
+
heroBlurBall: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n filter: blur(69px);\n will-change: transform;\n background: linear-gradient(\n 135deg,\n ", " 0%,\n ", " 30%,\n ", " 70%,\n ", " 100%\n );\n background-size: 200% 200%;\n animation: glow 10s ease infinite;\n\n @keyframes glow {\n 0% {\n background-position: 0 -100%;\n }\n\n 50% {\n background-position: 200% 50%;\n }\n\n 100% {\n background-position: 0 -100%;\n }\n }\n "])), token.gradientColor3, token.gradientColor1, token.red, token.cyan),
|
|
16
|
+
iconGradientDefault: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n radial-gradient(\n 100% 100% at 50% 0,\n ", " 0,\n ", " 100%\n )"])), rgba(token.colorSolid, 0.2), rgba(token.colorSolid, 0.1)),
|
|
17
|
+
blur: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n backdrop-filter: blur(7px);\n // background: ", ";\n "])), rgba(token.colorBgBase, 0.5))
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GetCustomToken } from 'antd-style';
|
|
2
|
+
declare module 'antd-style' {
|
|
3
|
+
interface CustomToken extends SiteToken {
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @title 站点主题 Token
|
|
8
|
+
* @description 站点的一些基础配置信息
|
|
9
|
+
*/
|
|
10
|
+
export interface SiteToken {
|
|
11
|
+
/**
|
|
12
|
+
* @title 头部高度
|
|
13
|
+
*/
|
|
14
|
+
headerHeight: number;
|
|
15
|
+
/**
|
|
16
|
+
* @title 底部高度
|
|
17
|
+
*/
|
|
18
|
+
footerHeight: number;
|
|
19
|
+
/**
|
|
20
|
+
* @title 侧边栏宽度
|
|
21
|
+
*/
|
|
22
|
+
sidebarWidth: number;
|
|
23
|
+
/**
|
|
24
|
+
* @title 目录宽度
|
|
25
|
+
*/
|
|
26
|
+
tocWidth: number;
|
|
27
|
+
/**
|
|
28
|
+
* @title 内容最大宽度
|
|
29
|
+
* @description 文本内容的最大宽度 1152
|
|
30
|
+
*/
|
|
31
|
+
contentMaxWidth: number | string;
|
|
32
|
+
/**
|
|
33
|
+
* @title 渐变色1
|
|
34
|
+
*/
|
|
35
|
+
gradientColor1: string;
|
|
36
|
+
/**
|
|
37
|
+
* @title 渐变色2
|
|
38
|
+
*/
|
|
39
|
+
gradientColor2: string;
|
|
40
|
+
/**
|
|
41
|
+
* @title 渐变色3
|
|
42
|
+
*/
|
|
43
|
+
gradientColor3: string;
|
|
44
|
+
/**
|
|
45
|
+
* @title 渐变背景色
|
|
46
|
+
*/
|
|
47
|
+
gradientHeroBgG: string;
|
|
48
|
+
/**
|
|
49
|
+
* @title 默认图标渐变色
|
|
50
|
+
*/
|
|
51
|
+
gradientIconDefault: string;
|
|
52
|
+
/**
|
|
53
|
+
* @title 实色
|
|
54
|
+
*/
|
|
55
|
+
colorSolid: string;
|
|
56
|
+
/**
|
|
57
|
+
* @title 代码高亮字体
|
|
58
|
+
*/
|
|
59
|
+
fontFamilyHighlighter: string;
|
|
60
|
+
/**
|
|
61
|
+
* 是否让 Demo 继承站点主题
|
|
62
|
+
*/
|
|
63
|
+
demoInheritSiteTheme: boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare const createCustomToken: GetCustomToken<SiteToken>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { rgba } from 'polished';
|
|
2
|
+
export var createCustomToken = function createCustomToken(_ref) {
|
|
3
|
+
var isDarkMode = _ref.isDarkMode,
|
|
4
|
+
token = _ref.token;
|
|
5
|
+
var gradientColor1 = token.blue;
|
|
6
|
+
var gradientColor2 = isDarkMode ? token.pink : token.cyan;
|
|
7
|
+
var gradientColor3 = token.purple;
|
|
8
|
+
var colorSolid = isDarkMode ? token.colorWhite : '#000';
|
|
9
|
+
return {
|
|
10
|
+
headerHeight: 64,
|
|
11
|
+
footerHeight: 300,
|
|
12
|
+
sidebarWidth: 240,
|
|
13
|
+
tocWidth: 176,
|
|
14
|
+
contentMaxWidth: 1152,
|
|
15
|
+
fontFamilyHighlighter: "'Fira Code', 'Fira Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace",
|
|
16
|
+
colorSolid: colorSolid,
|
|
17
|
+
gradientColor1: gradientColor1,
|
|
18
|
+
gradientColor2: gradientColor2,
|
|
19
|
+
gradientColor3: gradientColor3,
|
|
20
|
+
gradientHeroBgG: "radial-gradient(at 80% 20%, ".concat(gradientColor1, " 0%, ").concat(gradientColor2, " 80%, ").concat(gradientColor3, " 130%)"),
|
|
21
|
+
gradientIconDefault: "radial-gradient(\n 100% 100% at 50% 0,\n ".concat(rgba(colorSolid, isDarkMode ? 0.2 : 0.2), " 0,\n ").concat(rgba(colorSolid, isDarkMode ? 0.1 : 0.4), " 100%\n )"),
|
|
22
|
+
demoInheritSiteTheme: false
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { theme } from 'antd';
|
|
5
|
+
import { genMapTokenAlgorithm } from "../algorithms";
|
|
6
|
+
var cyanColors = ['rgba(0, 225, 242, 0.12)', 'rgba(0, 232, 245, 0.22)', 'rgba(0, 237, 250, 0.32)', 'rgba(0, 243, 255, 0.42)', 'rgba(0, 247, 255, 0.53)', 'rgba(0, 246, 254, 0.65)', 'rgba(0, 247, 253, 0.77)', 'rgba(0, 245, 255, 0.75)', 'rgba(0, 244, 255, 0.73)', 'rgba(0, 239, 253, 0.72)', 'rgba(0, 237, 253, 0.7)'];
|
|
7
|
+
var darkModeRelationship = function darkModeRelationship(type) {
|
|
8
|
+
var _ref;
|
|
9
|
+
var key = type.toUpperCase()[0] + type.slice(1);
|
|
10
|
+
return _ref = {}, _defineProperty(_ref, "color".concat(key, "Bg"), 1), _defineProperty(_ref, "color".concat(key, "BgHover"), 2), _defineProperty(_ref, "color".concat(key, "Border"), 3), _defineProperty(_ref, "color".concat(key, "BorderHover"), 4), _defineProperty(_ref, "color".concat(key, "Hover"), 7), _defineProperty(_ref, "color".concat(key), 6), _defineProperty(_ref, "color".concat(key, "Active"), 5), _defineProperty(_ref, "color".concat(key, "TextHover"), 8), _defineProperty(_ref, "color".concat(key, "Text"), 9), _defineProperty(_ref, "color".concat(key, "TextActive"), 10), _ref;
|
|
11
|
+
};
|
|
12
|
+
var darkMode = genMapTokenAlgorithm('dark', {
|
|
13
|
+
lighter: {
|
|
14
|
+
steps: 4,
|
|
15
|
+
// 减少较亮颜色的数量
|
|
16
|
+
targetBrightness: 0.8,
|
|
17
|
+
// 降低最大亮度值
|
|
18
|
+
saturationAdjustment: 0.6 // 减小较亮颜色的饱和度调整
|
|
19
|
+
// saturationScale: 1,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
darker: {
|
|
23
|
+
steps: 6,
|
|
24
|
+
// 增加较暗颜色的数量
|
|
25
|
+
targetBrightness: 0.2,
|
|
26
|
+
// 降低最小亮度值
|
|
27
|
+
saturationAdjustment: 0.4,
|
|
28
|
+
// 增加较暗颜色的饱和度调整
|
|
29
|
+
hueAdjustment: 1,
|
|
30
|
+
// 保持暗色调的色相调整因子
|
|
31
|
+
saturationScale: 1
|
|
32
|
+
},
|
|
33
|
+
reverse: true,
|
|
34
|
+
relationship: darkModeRelationship
|
|
35
|
+
});
|
|
36
|
+
export var darkColorPalettes = darkMode.palettes;
|
|
37
|
+
var darkAlgorithm = function darkAlgorithm(seedToken, mapToken) {
|
|
38
|
+
return _objectSpread(_objectSpread(_objectSpread({}, theme.darkAlgorithm(seedToken, mapToken)), darkMode.tokens), {}, {
|
|
39
|
+
'cyan-1': cyanColors[1],
|
|
40
|
+
'cyan-2': cyanColors[2],
|
|
41
|
+
'cyan-3': cyanColors[3],
|
|
42
|
+
'cyan-4': cyanColors[4],
|
|
43
|
+
'cyan-5': cyanColors[5],
|
|
44
|
+
'cyan-6': cyanColors[6],
|
|
45
|
+
'cyan-7': cyanColors[7],
|
|
46
|
+
'cyan-8': cyanColors[8],
|
|
47
|
+
'cyan-9': cyanColors[9],
|
|
48
|
+
'cyan-10': cyanColors[10]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export var darkTheme = {
|
|
52
|
+
token: {
|
|
53
|
+
colorTextLightSolid: '#000000',
|
|
54
|
+
colorBgLayout: '#000000',
|
|
55
|
+
colorBgContainer: '#111111',
|
|
56
|
+
colorBgElevated: '#222222',
|
|
57
|
+
colorBgSpotlight: '#444444',
|
|
58
|
+
colorBorder: '#333333',
|
|
59
|
+
colorBorderSecondary: '#333333',
|
|
60
|
+
colorText: '#ffffff',
|
|
61
|
+
colorTextSecondary: '#999999',
|
|
62
|
+
colorTextTertiary: '#888888',
|
|
63
|
+
colorTextQuaternary: '#666666',
|
|
64
|
+
colorPrimary: '#ffffff',
|
|
65
|
+
colorInfo: '#0070f3',
|
|
66
|
+
colorSuccess: '#50e3c2',
|
|
67
|
+
colorWarning: '#f5a623',
|
|
68
|
+
colorError: '#ee0000',
|
|
69
|
+
colorFillQuaternary: 'rgba(0,0,0,0)',
|
|
70
|
+
borderRadius: 5,
|
|
71
|
+
borderRadiusXS: 3,
|
|
72
|
+
borderRadiusSM: 3,
|
|
73
|
+
borderRadiusLG: 8,
|
|
74
|
+
controlHeight: 36,
|
|
75
|
+
boxShadow: '0 12px 20px 6px rgb(0 0 0 / 0.08)',
|
|
76
|
+
boxShadowSecondary: '0 2px 8px 2px rgb(0 0 0 / 0.07), 0 2px 4px -1px rgb(0 0 0 / 0.04)',
|
|
77
|
+
colorLinkHover: darkColorPalettes.primary[7],
|
|
78
|
+
colorLink: darkColorPalettes.primary[6],
|
|
79
|
+
colorLinkActive: darkColorPalettes.primary[5]
|
|
80
|
+
},
|
|
81
|
+
algorithm: darkAlgorithm
|
|
82
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { genMapTokenAlgorithm } from "../algorithms";
|
|
5
|
+
var lightMode = genMapTokenAlgorithm('light');
|
|
6
|
+
export var lightColorPalettes = lightMode.palettes;
|
|
7
|
+
export var lightTheme = {
|
|
8
|
+
token: {
|
|
9
|
+
colorTextLightSolid: '#ffffff',
|
|
10
|
+
colorBgLayout: '#ffffff',
|
|
11
|
+
colorBgContainer: '#fafafa',
|
|
12
|
+
colorBgElevated: '#f2f2f2',
|
|
13
|
+
colorBgSpotlight: '#999999',
|
|
14
|
+
colorBorder: '#eaeaea',
|
|
15
|
+
colorBorderSecondary: '#eaeaea',
|
|
16
|
+
colorText: '#000000',
|
|
17
|
+
colorTextSecondary: '#444444',
|
|
18
|
+
colorTextTertiary: '#666666',
|
|
19
|
+
colorTextQuaternary: '#888888',
|
|
20
|
+
colorPrimary: '#000000',
|
|
21
|
+
colorFillQuaternary: 'rgba(0,0,0,0)',
|
|
22
|
+
borderRadius: 5,
|
|
23
|
+
borderRadiusXS: 3,
|
|
24
|
+
borderRadiusSM: 3,
|
|
25
|
+
borderRadiusLG: 8,
|
|
26
|
+
controlHeight: 36,
|
|
27
|
+
boxShadow: '0 12px 20px 6px rgb(104 112 118 / 0.08)',
|
|
28
|
+
boxShadowSecondary: '0 2px 8px 2px rgb(104 112 118 / 0.07), 0 2px 4px -1px rgb(104 112 118 / 0.04)',
|
|
29
|
+
colorLinkHover: lightColorPalettes.primary[5],
|
|
30
|
+
colorLink: lightColorPalettes.primary[6],
|
|
31
|
+
colorLinkActive: lightColorPalettes.primary[7]
|
|
32
|
+
},
|
|
33
|
+
algorithm: function algorithm(seedToken, mapToken) {
|
|
34
|
+
return _objectSpread(_objectSpread({}, mapToken), lightMode.tokens);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Theme as AntdStyleTheme } from 'antd-style';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare module 'styled-components' {
|
|
4
|
+
interface DefaultTheme extends AntdStyleTheme {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare type DivProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
8
|
+
export declare type SvgProps = React.DetailedHTMLProps<React.HTMLAttributes<SVGSVGElement>, SVGSVGElement>;
|
|
9
|
+
export declare type ImgProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertAlphaToSolid: (foreground: string, background: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import chroma from 'chroma-js';
|
|
2
|
+
export var convertAlphaToSolid = function convertAlphaToSolid(foreground, background) {
|
|
3
|
+
var fgColor = chroma(foreground);
|
|
4
|
+
var bgColor = chroma(background);
|
|
5
|
+
var alpha = fgColor.alpha();
|
|
6
|
+
var alphaComplement = 1 - alpha;
|
|
7
|
+
var mixedColor = [fgColor.get('rgb.r') * alpha + bgColor.get('rgb.r') * alphaComplement, fgColor.get('rgb.g') * alpha + bgColor.get('rgb.g') * alphaComplement, fgColor.get('rgb.b') * alpha + bgColor.get('rgb.b') * alphaComplement];
|
|
8
|
+
var resultColor = chroma(mixedColor);
|
|
9
|
+
return resultColor.hex();
|
|
10
|
+
};
|