Skip to content

Commit ea7bd04

Browse files
committed
Rename ThemeProvider to ThemeUIProvider
1 parent f5ae7d6 commit ea7bd04

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

packages/theme-provider/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const RootStyles = () =>
3737
},
3838
})
3939

40-
interface ThemeProviderProps extends Pick<CoreThemeProviderProps, 'theme'> {
40+
export interface ThemeProviderProps
41+
extends Pick<CoreThemeProviderProps, 'theme'> {
4142
children?: React.ReactNode
4243
}
4344

packages/theme-ui/src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import {
44
type ThemeUIStyleObject,
55
} from '@theme-ui/core'
66
import React from 'react'
7+
import BaseThemeProvider, {
8+
type ThemeProviderProps,
9+
} from '@theme-ui/theme-provider'
710
export {
811
__ThemeUIContext,
912
merge,
@@ -28,10 +31,21 @@ export type {
2831
StylePropertyValue,
2932
} from '@theme-ui/core'
3033
export { useColorMode, InitializeColorMode } from '@theme-ui/color-modes'
31-
export { ThemeProvider } from '@theme-ui/theme-provider'
3234
export * from '@theme-ui/components'
3335
export { css, get } from '@theme-ui/css'
3436

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

packages/theme-ui/test/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import mockConsole from 'jest-mock-console'
88
import { fireEvent, render, renderJSON } from '@theme-ui/test-utils'
99

1010
import {
11-
ThemeProvider,
11+
ThemeProvider as DeprecatedThemeProvider,
12+
ThemeUIProvider as ThemeProvider,
1213
jsx,
1314
BaseStyles,
1415
Theme,
@@ -50,6 +51,17 @@ test('warns when multiple versions of emotion are installed', () => {
5051
restore()
5152
})
5253

54+
test('warns deprecated ThemeProvider', () => {
55+
const restore = mockConsole()
56+
render(
57+
<DeprecatedThemeProvider>
58+
<div />
59+
</DeprecatedThemeProvider>
60+
)
61+
expect(console.warn).toHaveBeenCalled()
62+
restore()
63+
})
64+
5365
test('functional themes receive outer theme', () => {
5466
const outer: Theme = {
5567
config: {

0 commit comments

Comments
 (0)