@@ -30,7 +30,7 @@ import { DeterministicIdContextProvider } from '@instructure/ui-react-utils'
3030
3131import { getTheme } from '../getTheme'
3232
33- import type { ThemeOrOverride } from '../EmotionTypes'
33+ import type { ThemeOrLegacyOverride } from '../EmotionTypes'
3434import type { DeterministicIdProviderValue } from '@instructure/ui-react-utils'
3535import { mergeDeep } from '@instructure/ui-utils'
3636import { Theme } from '@instructure/ui-themes'
@@ -41,7 +41,7 @@ type InstUIProviderProps = {
4141 /**
4242 * A full theme or an override object
4343 */
44- theme ?: ThemeOrOverride
44+ theme ?: ThemeOrLegacyOverride
4545
4646 // TODO-theme-types: fix override typing
4747 /**
@@ -92,18 +92,29 @@ function InstUISettingsProvider({
9292 )
9393 }
9494
95- let providedTheme = theme
96- if ( typeof theme !== 'function' ) {
97- const override = ( theme as Theme ) . themeOverride !
98- providedTheme = {
99- ...theme ,
100- themeOverride : mergeDeep ( override , themeOverride )
101- }
102- }
95+ /**
96+ * new pattern: if you wanna replace a theme inside an InstUISettigsProvider, provide it via the theme prop. It'll
97+ * override everything, replacing the otherwise used theme.
98+ * if you wanna apply an override, use the themeOverride prop.
99+ */
100+
101+ // let providedThemeOverride = themeOverride
102+ // if (typeof themeOverride === 'function') {
103+ // providedThemeOverride = themeOverride(useTheme())
104+ // }
105+
106+ // let providedTheme = theme
107+ // if (typeof theme !== 'function') {
108+ // const override = (theme as Theme).themeOverride!
109+ // providedTheme = {
110+ // ...theme,
111+ // themeOverride: mergeDeep(override, themeOverride)
112+ // }
113+ // }
103114
104115 let providers = (
105116 < DeterministicIdContextProvider instanceCounterMap = { instanceCounterMap } >
106- < ThemeProvider theme = { getTheme ( providedTheme ) } >
117+ < ThemeProvider theme = { getTheme ( theme , themeOverride ) } >
107118 < TextDirectionContext . Provider value = { finalDir } >
108119 { children }
109120 </ TextDirectionContext . Provider >
0 commit comments