Skip to content

Commit

Permalink
🐛 fix: 修正 GetCustom 相关方法类型没导出的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 7, 2023
1 parent c11d175 commit db6727c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
16 changes: 1 addition & 15 deletions src/containers/AppContainer/ThemeContent.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import { GetCustomStylish, GetCustomToken, ThemeAppearance } from '@/types';
import { ReactElement, ReactNode, useMemo } from 'react';

import { AntdStylish, AntdToken, FullToken, ThemeAppearance } from '@/types';

import { useThemeMode } from '@/hooks';
import { useAntdTheme } from '@/hooks/useAntdTheme';
import { theme } from 'antd';
import { ThemeConfig } from 'antd/es/config-provider/context';
import { ThemeProvider } from '../ThemeProvider';
import { AntdProvider, type AntdProviderProps } from './AntdProvider';

export type GetCustomToken<T> = (theme: {
token: AntdToken;
appearance: ThemeAppearance;
isDarkMode: boolean;
}) => T;

export type GetCustomStylish<S> = (theme: {
token: FullToken;
stylish: AntdStylish;
appearance: ThemeAppearance;
isDarkMode: boolean;
}) => S;

type GetAntdTheme = (appearance: ThemeAppearance) => ThemeConfig | undefined;
export interface ThemeContentProps<T, S = Record<string, string>>
extends Omit<AntdProviderProps, 'theme'> {
Expand Down
6 changes: 2 additions & 4 deletions src/containers/AppContainer/ThemeSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ const ThemeSwitcher: FC<ThemeSwitcherProps> = memo(
darkThemeMatch = matchThemeMode('dark');
}

if (!themeMode || themeMode === 'auto') {
setTimeout(() => {
matchBrowserTheme();
}, 1);
if (themeMode === 'auto') {
setTimeout(matchBrowserTheme, 1);
}

darkThemeMatch.addEventListener('change', matchBrowserTheme);
Expand Down
13 changes: 13 additions & 0 deletions src/types/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ThemeContextState } from '@/context';
import { ThemeAppearance } from 'antd-style/src';
import { AliasToken } from 'antd/es/theme/interface';

export type AntdToken = AliasToken;
Expand All @@ -12,6 +13,18 @@ export interface AntdStylish {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CustomToken {}

export type GetCustomToken<T> = (theme: {
token: AntdToken;
appearance: ThemeAppearance;
isDarkMode: boolean;
}) => T;

export type GetCustomStylish<S> = (theme: {
token: FullToken;
stylish: AntdStylish;
appearance: ThemeAppearance;
isDarkMode: boolean;
}) => S;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CustomStylish {}

Expand Down

0 comments on commit db6727c

Please sign in to comment.