File tree Expand file tree Collapse file tree 2 files changed +28
-16
lines changed Expand file tree Collapse file tree 2 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,37 @@ export interface ThemeProviderProps
42
42
children ?: React . ReactNode
43
43
}
44
44
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 */
45
64
export const ThemeProvider : React . FC < ThemeProviderProps > = ( {
46
65
theme,
47
66
children,
48
67
} ) => {
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
+
49
76
const outer = useThemeUI ( )
50
77
51
78
const isTopLevel = outer === __themeUiDefaultContextValue
Original file line number Diff line number Diff line change @@ -4,16 +4,13 @@ import {
4
4
type ThemeUIStyleObject ,
5
5
} from '@theme-ui/core'
6
6
import React from 'react'
7
- import {
8
- ThemeProvider as BaseThemeProvider ,
9
- type ThemeProviderProps ,
10
- } from '@theme-ui/theme-provider'
11
7
export {
12
8
__ThemeUIContext ,
13
9
merge ,
14
10
useThemeUI ,
15
11
createElement ,
16
12
} from '@theme-ui/core'
13
+ export { ThemeProvider , ThemeUIProvider } from '@theme-ui/theme-provider'
17
14
export type {
18
15
ThemeUIContextValue ,
19
16
SxProp ,
@@ -35,18 +32,6 @@ export { useColorMode, InitializeColorMode } from '@theme-ui/color-modes'
35
32
export * from '@theme-ui/components'
36
33
export { css , get } from '@theme-ui/css'
37
34
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
-
50
35
export const BaseStyles = (
51
36
props : Record < string , unknown > & { sx ?: ThemeUIStyleObject }
52
37
) : JSX . Element =>
You can’t perform that action at this time.
0 commit comments