Skip to content

Commit

Permalink
⚡️ perf: use antd cssvar mode to improve performance (#4446)
Browse files Browse the repository at this point in the history
* try cssvar

* Update package.json
  • Loading branch information
arvinxx authored Oct 22, 2024
1 parent f338b10 commit 4429c2b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
"lodash": "^4.17.21",
"markdown-table": "^3.0.3",
"node-fetch": "^3.3.2",
"node-gyp": "^10.2.0",
"openapi-typescript": "^6.7.6",
"p-map": "^7.0.2",
"prettier": "^3.3.3",
Expand Down
49 changes: 26 additions & 23 deletions src/layout/GlobalProvider/AppTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { ConfigProvider, NeutralColors, PrimaryColors, ThemeProvider } from '@lobehub/ui';
import { ConfigProvider as AntdConfigProvider } from 'antd';
import { ThemeAppearance, createStyles } from 'antd-style';
import 'antd/dist/reset.css';
import Image from 'next/image';
Expand Down Expand Up @@ -103,31 +104,33 @@ const AppTheme = memo<AppThemeProps>(
}, [neutralColor]);

return (
<ThemeProvider
className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
customTheme={{
neutralColor: neutralColor ?? defaultNeutralColor,
primaryColor: primaryColor ?? defaultPrimaryColor,
}}
defaultAppearance={defaultAppearance}
onAppearanceChange={(appearance) => {
setCookie(LOBE_THEME_APPEARANCE, appearance);
}}
themeMode={themeMode}
>
<GlobalStyle />
<AntdStaticMethods />
<ConfigProvider
config={{
aAs: Link,
imgAs: Image,
imgUnoptimized: true,
proxy: globalCDN ? 'unpkg' : undefined,
<AntdConfigProvider theme={{ cssVar: true }}>
<ThemeProvider
className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
customTheme={{
neutralColor: neutralColor ?? defaultNeutralColor,
primaryColor: primaryColor ?? defaultPrimaryColor,
}}
defaultAppearance={defaultAppearance}
onAppearanceChange={(appearance) => {
setCookie(LOBE_THEME_APPEARANCE, appearance);
}}
themeMode={themeMode}
>
{children}
</ConfigProvider>
</ThemeProvider>
<GlobalStyle />
<AntdStaticMethods />
<ConfigProvider
config={{
aAs: Link,
imgAs: Image,
imgUnoptimized: true,
proxy: globalCDN ? 'unpkg' : undefined,
}}
>
{children}
</ConfigProvider>
</ThemeProvider>
</AntdConfigProvider>
);
},
);
Expand Down

0 comments on commit 4429c2b

Please sign in to comment.