Skip to content

Commit 1721e1b

Browse files
committed
Move deprecated component to package
1 parent 72a3f1f commit 1721e1b

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

packages/theme-provider/src/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,37 @@ export interface ThemeProviderProps
4242
children?: React.ReactNode
4343
}
4444

45+
export const ThemeUIProvider: React.FC<ThemeProviderProps> = ({
46+
theme,
47+
children,
48+
}) => {
49+
const outer = useThemeUI()
50+
51+
const isTopLevel = outer === __themeUiDefaultContextValue
52+
53+
return (
54+
<CoreProvider theme={theme}>
55+
<ColorModeProvider>
56+
{isTopLevel && <RootStyles />}
57+
{children}
58+
</ColorModeProvider>
59+
</CoreProvider>
60+
)
61+
}
62+
63+
/** @deprecated ThemeProvider is now called ThemeUIProvider to reduce confusion with Emotion */
4564
export const ThemeProvider: React.FC<ThemeProviderProps> = ({
4665
theme,
4766
children,
4867
}) => {
68+
React.useEffect(() => {
69+
if (process.env.NODE_ENV !== 'production') {
70+
console.warn(
71+
'[theme-ui] The export ThemeUIProvider is deprecated and is now called ThemeProvider to reduce confusion with Emotion. Please update your import; ThemeUIProvider will be removed in a future version.'
72+
)
73+
}
74+
}, [])
75+
4976
const outer = useThemeUI()
5077

5178
const isTopLevel = outer === __themeUiDefaultContextValue

packages/theme-ui/src/index.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import {
44
type ThemeUIStyleObject,
55
} from '@theme-ui/core'
66
import React from 'react'
7-
import {
8-
ThemeProvider as BaseThemeProvider,
9-
type ThemeProviderProps,
10-
} from '@theme-ui/theme-provider'
117
export {
128
__ThemeUIContext,
139
merge,
1410
useThemeUI,
1511
createElement,
1612
} from '@theme-ui/core'
13+
export { ThemeProvider, ThemeUIProvider } from '@theme-ui/theme-provider'
1714
export type {
1815
ThemeUIContextValue,
1916
SxProp,
@@ -35,18 +32,6 @@ export { useColorMode, InitializeColorMode } from '@theme-ui/color-modes'
3532
export * from '@theme-ui/components'
3633
export { css, get } from '@theme-ui/css'
3734

38-
/** @deprecated This export has been renamed ThemeUIProvider */
39-
export function ThemeProvider(
40-
props: ThemeProviderProps
41-
): typeof BaseThemeProvider {
42-
console.warn(
43-
'[theme-ui] The export <ThemeProvider> is deprecated; it’s now called ThemeUIProvider to reduce confusion. Please update your imports.'
44-
)
45-
return React.createElement(BaseThemeProvider, props)
46-
}
47-
48-
export { BaseThemeProvider as ThemeUIProvider }
49-
5035
export const BaseStyles = (
5136
props: Record<string, unknown> & { sx?: ThemeUIStyleObject }
5237
): JSX.Element =>

0 commit comments

Comments
 (0)