Skip to content

Commit

Permalink
fix: set default theme color constance
Browse files Browse the repository at this point in the history
  • Loading branch information
shuashuai committed Sep 25, 2024
1 parent 3698389 commit b9064e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ui/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,5 @@ export const SYSTEM_AVATAR_OPTIONS = [
];

export const TAG_SLUG_NAME_MAX_LENGTH = 35;

export const DEFAULT_THEME_COLOR = '#0033ff';
5 changes: 4 additions & 1 deletion ui/src/components/CustomizeTheme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Color from 'color';

import { shiftColor, tintColor, shadeColor } from '@/utils';
import { themeSettingStore } from '@/stores';
import { DEFAULT_THEME_COLOR } from '@/common/constants';

const Index: FC = () => {
const { theme, theme_config } = themeSettingStore((_) => _);
Expand All @@ -34,7 +35,9 @@ const Index: FC = () => {
const setThemeColor = () => {
const themeMetaNode = document.querySelector('meta[name="theme-color"]');
if (themeMetaNode) {
const themeColor = primaryColor ? primaryColor.hex() : '#0033ff';
const themeColor = primaryColor
? primaryColor.hex()
: DEFAULT_THEME_COLOR;
themeMetaNode.setAttribute('content', themeColor);
}
};
Expand Down
5 changes: 3 additions & 2 deletions ui/src/pages/Admin/Themes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useToast } from '@/hooks';
import { handleFormError, scrollToElementTop } from '@/utils';
import { themeSettingStore } from '@/stores';
import { setupAppTheme } from '@/utils/localize';
import { DEFAULT_THEME_COLOR } from '@/common/constants';

const Index: FC = () => {
const { t } = useTranslation('translation', {
Expand Down Expand Up @@ -67,7 +68,7 @@ const Index: FC = () => {
type: 'string',
title: t('primary_color.label'),
description: t('primary_color.text'),
default: '#0033FF',
default: DEFAULT_THEME_COLOR,
},
},
};
Expand Down Expand Up @@ -103,7 +104,7 @@ const Index: FC = () => {

const resetPrimaryScheme = () => {
const formMeta = { ...formData };
formMeta.primary_color.value = '#0033FF';
formMeta.primary_color.value = DEFAULT_THEME_COLOR;
setFormData({ ...formMeta });
};

Expand Down
3 changes: 2 additions & 1 deletion ui/src/stores/themeSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import create from 'zustand';

import { AdminSettingsTheme } from '@/common/interface';
import { DEFAULT_THEME_COLOR } from '@/common/constants';

interface IType {
theme: AdminSettingsTheme['theme'];
Expand All @@ -36,7 +37,7 @@ const store = create<IType>((set) => ({
theme_config: {
default: {
navbar_style: 'colored',
primary_color: '#0033FF',
primary_color: DEFAULT_THEME_COLOR,
},
},
update: (params) =>
Expand Down

0 comments on commit b9064e3

Please sign in to comment.