2023-04-20 10:47:06 +08:00
|
|
|
import type { FC } from 'react';
|
2023-04-18 15:29:34 +08:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import { ConfigContext } from 'antd/es/config-provider';
|
2023-04-20 10:47:06 +08:00
|
|
|
import type { ThemeProviderProps } from 'antd-style';
|
2023-04-18 15:29:34 +08:00
|
|
|
import { ThemeProvider } from 'antd-style';
|
|
|
|
import { theme } from 'antd';
|
|
|
|
|
2023-04-20 10:47:06 +08:00
|
|
|
const SiteThemeProvider: FC<ThemeProviderProps> = ({ children, ...rest }) => {
|
2023-04-18 15:29:34 +08:00
|
|
|
const { getPrefixCls, iconPrefixCls } = useContext(ConfigContext);
|
|
|
|
const rootPrefixCls = getPrefixCls();
|
|
|
|
const { token } = theme.useToken();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ThemeProvider
|
2023-04-20 10:47:06 +08:00
|
|
|
{...rest}
|
2023-04-18 15:29:34 +08:00
|
|
|
customToken={{
|
|
|
|
headerHeight: 64,
|
|
|
|
menuItemBorder: 2,
|
|
|
|
mobileMaxWidth: 767.99,
|
|
|
|
siteMarkdownCodeBg: token.colorFillTertiary,
|
|
|
|
antCls: `.${rootPrefixCls}`,
|
|
|
|
iconCls: `.${iconPrefixCls}`,
|
|
|
|
/** 56 */
|
|
|
|
marginFarXS: (token.marginXXL / 6) * 7,
|
|
|
|
/** 80 */
|
|
|
|
marginFarSM: (token.marginXXL / 3) * 5,
|
|
|
|
/** 96 */
|
|
|
|
marginFar: token.marginXXL * 2,
|
|
|
|
codeFamily: `'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</ThemeProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SiteThemeProvider;
|