Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(theme): compose ConfigProvider outside ThemeProvider in every shell (#19457)

Innei2c5faed6c686
diff --git a/apps/share/src/shell/ShareTheme.tsx b/apps/share/src/shell/ShareTheme.tsx
index d8b300b1897..6071a314afe 100644
--- a/apps/share/src/shell/ShareTheme.tsx
+++ b/apps/share/src/shell/ShareTheme.tsx
@@ -18,20 +18,20 @@ const ShareTheme = memo<PropsWithChildren>(({ children }) => {
const appearance = isDark ? 'dark' : 'light';
return (
- <ThemeProvider
- appearance={appearance}
- className={'share-layout'}
- defaultAppearance={appearance}
- defaultThemeMode={appearance}
- style={{ height: '100%', minHeight: '100dvh', width: '100%' }}
- theme={{ cssVar: { key: 'lobe-vars' } }}
- >
- <App style={{ height: '100%' }}>
- <ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
+ <ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
+ <ThemeProvider
+ appearance={appearance}
+ className={'share-layout'}
+ defaultAppearance={appearance}
+ defaultThemeMode={appearance}
+ style={{ height: '100%', minHeight: '100dvh', width: '100%' }}
+ theme={{ cssVar: { key: 'lobe-vars' } }}
+ >
+ <App style={{ height: '100%' }}>
<LazyMotion features={domMax}>{children}</LazyMotion>
- </ConfigProvider>
- </App>
- </ThemeProvider>
+ </App>
+ </ThemeProvider>
+ </ConfigProvider>
);
});
diff --git a/apps/workbench/src/shell/WorkbenchTheme.tsx b/apps/workbench/src/shell/WorkbenchTheme.tsx
index 3c16941879f..b1c4933eb15 100644
--- a/apps/workbench/src/shell/WorkbenchTheme.tsx
+++ b/apps/workbench/src/shell/WorkbenchTheme.tsx
@@ -18,20 +18,20 @@ const WorkbenchTheme = memo<PropsWithChildren>(({ children }) => {
const appearance = isDark ? 'dark' : 'light';
return (
- <ThemeProvider
- appearance={appearance}
- className={'workbench-layout'}
- defaultAppearance={appearance}
- defaultThemeMode={appearance}
- style={{ height: '100%', minHeight: '100dvh', width: '100%' }}
- theme={{ cssVar: { key: 'lobe-vars' } }}
- >
- <App style={{ height: '100%' }}>
- <ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
+ <ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
+ <ThemeProvider
+ appearance={appearance}
+ className={'workbench-layout'}
+ defaultAppearance={appearance}
+ defaultThemeMode={appearance}
+ style={{ height: '100%', minHeight: '100dvh', width: '100%' }}
+ theme={{ cssVar: { key: 'lobe-vars' } }}
+ >
+ <App style={{ height: '100%' }}>
<LazyMotion features={domMax}>{children}</LazyMotion>
- </ConfigProvider>
- </App>
- </ThemeProvider>
+ </App>
+ </ThemeProvider>
+ </ConfigProvider>
);
});
diff --git a/eslint.config.mjs b/eslint.config.mjs
index ebdc274b425..2c09887f7a7 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -37,6 +37,13 @@ const performanceRestrictedImportPaths = [
'Import the imperative facade from "@/features/ShareModal" so the modal implementation stays outside initial chunks.',
name: '@/features/ShareModal/Modal',
},
+ {
+ allowTypeImports: true,
+ importNames: ['motion'],
+ message:
+ 'The app runs under <LazyMotion features={domMax}>; `motion` bundles every feature again. Use `m` from "motion/react" (or "motion/react-m").',
+ name: 'motion/react',
+ },
{
allowTypeImports: true,
message:
diff --git a/src/features/AuthShell/AuthThemeLite.tsx b/src/features/AuthShell/AuthThemeLite.tsx
index d453c89d27f..2a70f65bc59 100644
--- a/src/features/AuthShell/AuthThemeLite.tsx
+++ b/src/features/AuthShell/AuthThemeLite.tsx
@@ -23,31 +23,31 @@ const AuthThemeLite = memo<AuthThemeLiteProps>(({ children, globalCDN }) => {
const currentAppearance = isDark ? 'dark' : 'light';
return (
- <ThemeProvider
- appearance={currentAppearance}
- className={'auth-layout'}
- defaultAppearance={currentAppearance}
- defaultThemeMode={currentAppearance}
- style={{ height: '100%' }}
- theme={{
- cssVar: { key: 'lobe-vars' },
+ <ConfigProvider
+ motion={m}
+ config={{
+ aAs: Link,
+ imgAs: Image,
+ imgUnoptimized: true,
+ proxy: globalCDN ? 'unpkg' : undefined,
}}
>
- <App style={{ height: '100%' }}>
- <ConfigProvider
- motion={m}
- config={{
- aAs: Link,
- imgAs: Image,
- imgUnoptimized: true,
- proxy: globalCDN ? 'unpkg' : undefined,
- }}
- >
+ <ThemeProvider
+ appearance={currentAppearance}
+ className={'auth-layout'}
+ defaultAppearance={currentAppearance}
+ defaultThemeMode={currentAppearance}
+ style={{ height: '100%' }}
+ theme={{
+ cssVar: { key: 'lobe-vars' },
+ }}
+ >
+ <App style={{ height: '100%' }}>
<LazyMotion features={domMax}>{children}</LazyMotion>
<ToastHost />
- </ConfigProvider>
- </App>
- </ThemeProvider>
+ </App>
+ </ThemeProvider>
+ </ConfigProvider>
);
});
diff --git a/src/features/Billboard/Carousel.tsx b/src/features/Billboard/Carousel.tsx
index 8428b8338c2..f86db172cc2 100644
--- a/src/features/Billboard/Carousel.tsx
+++ b/src/features/Billboard/Carousel.tsx
@@ -5,7 +5,7 @@ import { ActionIcon, Button } from '@lobehub/ui/base-ui';
import { Carousel as AntCarousel } from 'antd';
import { createStaticStyles, cssVar } from 'antd-style';
import { X } from 'lucide-react';
-import { motion } from 'motion/react';
+import { m } from 'motion/react';
import {
type ComponentRef,
memo,
@@ -283,7 +283,7 @@ const BillboardCarousel = memo<BillboardCarouselProps>(
const cardDataProps = cardAttr ? { [cardAttr]: '' } : {};
return (
- <motion.div
+ <m.div
{...cardDataProps}
className={styles.card}
initial={{ opacity: 0, scale: 0.92, y: 16 }}
@@ -339,7 +339,7 @@ const BillboardCarousel = memo<BillboardCarouselProps>(
</Flexbox>
</>
)}
- </motion.div>
+ </m.div>
);
},
);
diff --git a/src/layout/GlobalProvider/AppTheme.tsx b/src/layout/GlobalProvider/AppTheme.tsx
index 8df9dc6c657..b01d58865bc 100644
--- a/src/layout/GlobalProvider/AppTheme.tsx
+++ b/src/layout/GlobalProvider/AppTheme.tsx
@@ -158,41 +158,41 @@ const AppTheme = memo<AppThemeProps>(
const currentAppearence = isDark ? 'dark' : 'light';
return (
- <ThemeProvider
- appearance={currentAppearence}
- className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
- defaultAppearance={currentAppearence}
- defaultThemeMode={currentAppearence}
- customTheme={{
- neutralColor: neutralColor ?? defaultNeutralColor,
- primaryColor: primaryColor ?? defaultPrimaryColor,
- }}
- theme={{
- cssVar: { key: 'lobe-vars' },
- token: {
- fontFamily,
- fontFamilyCode,
- motion: animationMode !== 'disabled',
- motionUnit: animationMode === 'agile' ? 0.05 : 0.1,
- },
+ <ConfigProvider
+ locale={uiLocale}
+ motion={m}
+ resources={uiResources}
+ config={{
+ aAs: Link,
+ imgAs: Image,
+ imgUnoptimized: true,
+ proxy: globalCDN ? 'unpkg' : undefined,
}}
>
- {!!customFontURL && <FontLoader url={customFontURL} />}
- <GlobalStyle />
- <ConfigProvider
- locale={uiLocale}
- motion={m}
- resources={uiResources}
- config={{
- aAs: Link,
- imgAs: Image,
- imgUnoptimized: true,
- proxy: globalCDN ? 'unpkg' : undefined,
+ <ThemeProvider
+ appearance={currentAppearence}
+ className={cx(styles.app, styles.scrollbar, styles.scrollbarPolyfill)}
+ defaultAppearance={currentAppearence}
+ defaultThemeMode={currentAppearence}
+ customTheme={{
+ neutralColor: neutralColor ?? defaultNeutralColor,
+ primaryColor: primaryColor ?? defaultPrimaryColor,
+ }}
+ theme={{
+ cssVar: { key: 'lobe-vars' },
+ token: {
+ fontFamily,
+ fontFamilyCode,
+ motion: animationMode !== 'disabled',
+ motionUnit: animationMode === 'agile' ? 0.05 : 0.1,
+ },
}}
>
+ {!!customFontURL && <FontLoader url={customFontURL} />}
+ <GlobalStyle />
{children}
- </ConfigProvider>
- </ThemeProvider>
+ </ThemeProvider>
+ </ConfigProvider>
);
},
);
diff --git a/src/utils/router.tsx b/src/utils/router.tsx
index 9e01362639b..ad01949c803 100644
--- a/src/utils/router.tsx
+++ b/src/utils/router.tsx
@@ -152,16 +152,16 @@ export const ErrorBoundary = ({ resetPath }: ErrorBoundaryProps) => {
}
return (
- <ThemeProvider
- appearance={appearance}
- defaultAppearance={appearance}
- defaultThemeMode={appearance}
- theme={{ cssVar: { key: 'lobe-vars' } }}
- >
- <ConfigProvider motion={m}>
+ <ConfigProvider motion={m}>
+ <ThemeProvider
+ appearance={appearance}
+ defaultAppearance={appearance}
+ defaultThemeMode={appearance}
+ theme={{ cssVar: { key: 'lobe-vars' } }}
+ >
<ErrorCapture error={error} resetPath={resetPath} />
- </ConfigProvider>
- </ThemeProvider>
+ </ThemeProvider>
+ </ConfigProvider>
);
};