MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / applyPrimaryColor

Function applyPrimaryColor

internal-plugins/setting/src/utils/themeUtils.ts:56–63  ·  view source on GitHub ↗
(primaryColor: PrimaryColor, customColor?: string)

Source from the content-addressed store, hash-verified

54 * 应用主题色类名;当主题色为 custom 时同步写入自定义色变量。
55 */
56export function applyPrimaryColor(primaryColor: PrimaryColor, customColor?: string): void {
57 document.body.className = document.body.className.replace(/theme-\w+/g, '').trim()
58 document.body.classList.add(`theme-${primaryColor}`)
59
60 if (primaryColor === 'custom' && typeof customColor === 'string' && customColor) {
61 applyCustomColor(customColor)
62 }
63}
64
65function hexToRgb(hex: string): { r: number; g: number; b: number } | null {
66 const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)

Callers 1

applyInitialAppearanceFunction · 0.90

Calls 1

applyCustomColorFunction · 0.70

Tested by

no test coverage detected