@@ -173,7 +173,10 @@ function cacheThemeVariants(theme: DesktopTheme, themeId: string) {
173173
174174export const { use : useTheme , provider : ThemeProvider } = createSimpleContext ( {
175175 name : "Theme" ,
176- init : ( props : { defaultTheme ?: string ; onThemeApplied ?: ( theme : DesktopTheme , mode : "light" | "dark" ) => void } ) => {
176+ init : ( props : {
177+ defaultTheme ?: string
178+ onThemeApplied ?: ( theme : DesktopTheme , mode : "light" | "dark" , scheme : ColorScheme ) => void
179+ } ) => {
177180 const themeId = normalize ( read ( STORAGE_KEYS . THEME_ID ) ?? props . defaultTheme ) ?? "oc-2"
178181 const colorScheme = ( read ( STORAGE_KEYS . COLOR_SCHEME ) as ColorScheme | null ) ?? "system"
179182 const mode = colorScheme === "system" ? getSystemMode ( ) : colorScheme
@@ -212,9 +215,9 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
212215 return task
213216 }
214217
215- const applyTheme = ( theme : DesktopTheme , themeId : string , mode : "light" | "dark" ) => {
218+ const applyTheme = ( theme : DesktopTheme , themeId : string , mode : "light" | "dark" , scheme : ColorScheme ) => {
216219 applyThemeCss ( theme , themeId , mode )
217- props . onThemeApplied ?.( theme , mode )
220+ props . onThemeApplied ?.( theme , mode , scheme )
218221 }
219222
220223 const ids = ( ) => {
@@ -278,7 +281,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
278281 createEffect ( ( ) => {
279282 const theme = store . themes [ store . themeId ]
280283 if ( ! theme ) return
281- applyTheme ( theme , store . themeId , store . mode )
284+ applyTheme ( theme , store . themeId , store . mode , store . colorScheme )
282285 } )
283286
284287 const setTheme = ( id : string ) => {
@@ -333,7 +336,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
333336 ? getSystemMode ( )
334337 : store . previewScheme
335338 : store . mode
336- applyTheme ( theme , next , mode )
339+ applyTheme ( theme , next , mode , store . previewScheme ?? store . colorScheme )
337340 } )
338341 } ,
339342 previewColorScheme : ( scheme : ColorScheme ) => {
@@ -344,7 +347,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
344347 if ( ! theme ) return
345348 if ( ( store . previewThemeId ?? store . themeId ) !== id ) return
346349 if ( store . previewScheme !== scheme ) return
347- applyTheme ( theme , id , mode )
350+ applyTheme ( theme , id , mode , scheme )
348351 } )
349352 } ,
350353 commitPreview : ( ) => {
@@ -362,7 +365,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
362365 setStore ( "previewScheme" , null )
363366 void load ( store . themeId ) . then ( ( theme ) => {
364367 if ( ! theme ) return
365- applyTheme ( theme , store . themeId , store . mode )
368+ applyTheme ( theme , store . themeId , store . mode , store . colorScheme )
366369 } )
367370 } ,
368371 }
0 commit comments