chore: custom brand color

This commit is contained in:
jialin
2025-04-28 10:05:06 +08:00
parent 3fb3381a19
commit fb90d79eb3
12 changed files with 398 additions and 139 deletions
+2 -1
View File
@@ -1,7 +1,8 @@
import { getActiveStatus, setActiveStatus } from '@/atoms/tab-active';
const tabsMap = {
resources: 'resources'
resources: 'resources',
userSettings: 'userSettings'
};
export default function useTabActive() {
+5 -5
View File
@@ -6,7 +6,7 @@ import { useEffect, useMemo } from 'react';
type Theme = 'light' | 'realDark' | 'auto';
export default function useUserSettings() {
const { light, dark } = themeConfig;
const { light, dark, colorPrimary } = themeConfig;
const [userSettings, setUserSettings] = useAtom(userSettingsHelperAtom);
const setHtmlThemeAttr = (theme: string) => {
@@ -17,15 +17,16 @@ export default function useUserSettings() {
};
const themeData = useMemo(() => {
const themeTokens = userSettings.theme === 'realDark' ? dark : light;
themeTokens.token.colorPrimary = userSettings.colorPrimary || colorPrimary;
return {
...(userSettings.theme === 'realDark' ? dark : light)
...themeTokens
};
}, [userSettings.theme]);
}, [userSettings.theme, userSettings.colorPrimary]);
const setTheme = (theme: Theme) => {
setHtmlThemeAttr(theme);
setUserSettings({
...userSettings,
theme: theme,
isDarkTheme: theme === 'realDark'
});
@@ -35,7 +36,6 @@ export default function useUserSettings() {
setHtmlThemeAttr(userSettings.theme);
}, [userSettings.theme]);
// set theme by system theme: only for theme is auto
useEffect(() => {
const handleChange = (e: MediaQueryListEvent) => {
setTheme(e.matches ? 'realDark' : 'light');