@opencode-ai/ui 1.17.14 → 1.17.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/theme/context.d.ts +1 -1
- package/package.json +1 -1
- package/src/theme/context.tsx +10 -7
package/dist/theme/context.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ export declare const useTheme: () => {
|
|
|
17
17
|
cancelPreview: () => void;
|
|
18
18
|
}, ThemeProvider: (props: import("solid-js").ParentProps<{
|
|
19
19
|
defaultTheme?: string;
|
|
20
|
-
onThemeApplied?: (theme: DesktopTheme, mode: "light" | "dark") => void;
|
|
20
|
+
onThemeApplied?: (theme: DesktopTheme, mode: "light" | "dark", scheme: ColorScheme) => void;
|
|
21
21
|
}>) => import("solid-js").JSX.Element;
|
package/package.json
CHANGED
package/src/theme/context.tsx
CHANGED
|
@@ -173,7 +173,10 @@ function cacheThemeVariants(theme: DesktopTheme, themeId: string) {
|
|
|
173
173
|
|
|
174
174
|
export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
175
175
|
name: "Theme",
|
|
176
|
-
init: (props: {
|
|
176
|
+
init: (props: {
|
|
177
|
+
defaultTheme?: string
|
|
178
|
+
onThemeApplied?: (theme: DesktopTheme, mode: "light" | "dark", scheme: ColorScheme) => void
|
|
179
|
+
}) => {
|
|
177
180
|
const themeId = normalize(read(STORAGE_KEYS.THEME_ID) ?? props.defaultTheme) ?? "oc-2"
|
|
178
181
|
const colorScheme = (read(STORAGE_KEYS.COLOR_SCHEME) as ColorScheme | null) ?? "system"
|
|
179
182
|
const mode = colorScheme === "system" ? getSystemMode() : colorScheme
|
|
@@ -212,9 +215,9 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
|
212
215
|
return task
|
|
213
216
|
}
|
|
214
217
|
|
|
215
|
-
const applyTheme = (theme: DesktopTheme, themeId: string, mode: "light" | "dark") => {
|
|
218
|
+
const applyTheme = (theme: DesktopTheme, themeId: string, mode: "light" | "dark", scheme: ColorScheme) => {
|
|
216
219
|
applyThemeCss(theme, themeId, mode)
|
|
217
|
-
props.onThemeApplied?.(theme, mode)
|
|
220
|
+
props.onThemeApplied?.(theme, mode, scheme)
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
const ids = () => {
|
|
@@ -278,7 +281,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
|
278
281
|
createEffect(() => {
|
|
279
282
|
const theme = store.themes[store.themeId]
|
|
280
283
|
if (!theme) return
|
|
281
|
-
applyTheme(theme, store.themeId, store.mode)
|
|
284
|
+
applyTheme(theme, store.themeId, store.mode, store.colorScheme)
|
|
282
285
|
})
|
|
283
286
|
|
|
284
287
|
const setTheme = (id: string) => {
|
|
@@ -333,7 +336,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
|
333
336
|
? getSystemMode()
|
|
334
337
|
: store.previewScheme
|
|
335
338
|
: store.mode
|
|
336
|
-
applyTheme(theme, next, mode)
|
|
339
|
+
applyTheme(theme, next, mode, store.previewScheme ?? store.colorScheme)
|
|
337
340
|
})
|
|
338
341
|
},
|
|
339
342
|
previewColorScheme: (scheme: ColorScheme) => {
|
|
@@ -344,7 +347,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
|
344
347
|
if (!theme) return
|
|
345
348
|
if ((store.previewThemeId ?? store.themeId) !== id) return
|
|
346
349
|
if (store.previewScheme !== scheme) return
|
|
347
|
-
applyTheme(theme, id, mode)
|
|
350
|
+
applyTheme(theme, id, mode, scheme)
|
|
348
351
|
})
|
|
349
352
|
},
|
|
350
353
|
commitPreview: () => {
|
|
@@ -362,7 +365,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
|
|
|
362
365
|
setStore("previewScheme", null)
|
|
363
366
|
void load(store.themeId).then((theme) => {
|
|
364
367
|
if (!theme) return
|
|
365
|
-
applyTheme(theme, store.themeId, store.mode)
|
|
368
|
+
applyTheme(theme, store.themeId, store.mode, store.colorScheme)
|
|
366
369
|
})
|
|
367
370
|
},
|
|
368
371
|
}
|