summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src
diff options
context:
space:
mode:
authorLuke Parker <[email protected]>2026-03-12 16:38:56 +1000
committerGitHub <[email protected]>2026-03-12 16:38:56 +1000
commitd481f64bdeaca91226e66c0e7888c7a10ba631f7 (patch)
tree8700aaad0363342015ffc49cb962620186e1f7f0 /packages/ui/src
parent54e7baa6cfff86627e5555842560b4a20e4be424 (diff)
downloadopencode-d481f64bdeaca91226e66c0e7888c7a10ba631f7.tar.gz
opencode-d481f64bdeaca91226e66c0e7888c7a10ba631f7.zip
fix(electron): theme Windows titlebar overlay (#16843)
Co-authored-by: Brendan Allan <[email protected]>
Diffstat (limited to 'packages/ui/src')
-rw-r--r--packages/ui/src/theme/context.tsx15
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/ui/src/theme/context.tsx b/packages/ui/src/theme/context.tsx
index cda967697..ad82a088d 100644
--- a/packages/ui/src/theme/context.tsx
+++ b/packages/ui/src/theme/context.tsx
@@ -77,7 +77,7 @@ function cacheThemeVariants(theme: DesktopTheme, themeId: string) {
export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
name: "Theme",
- init: (props: { defaultTheme?: string }) => {
+ init: (props: { defaultTheme?: string; onThemeApplied?: (theme: DesktopTheme, mode: "light" | "dark") => void }) => {
const [store, setStore] = createStore({
themes: DEFAULT_THEMES as Record<string, DesktopTheme>,
themeId: normalize(props.defaultTheme) ?? "oc-2",
@@ -119,10 +119,15 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
}
})
+ const applyTheme = (theme: DesktopTheme, themeId: string, mode: "light" | "dark") => {
+ applyThemeCss(theme, themeId, mode)
+ props.onThemeApplied?.(theme, mode)
+ }
+
createEffect(() => {
const theme = store.themes[store.themeId]
if (theme) {
- applyThemeCss(theme, store.themeId, store.mode)
+ applyTheme(theme, store.themeId, store.mode)
}
})
@@ -171,7 +176,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
? getSystemMode()
: store.previewScheme
: store.mode
- applyThemeCss(theme, next, previewMode)
+ applyTheme(theme, next, previewMode)
},
previewColorScheme: (scheme: ColorScheme) => {
setStore("previewScheme", scheme)
@@ -179,7 +184,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
const id = store.previewThemeId ?? store.themeId
const theme = store.themes[id]
if (theme) {
- applyThemeCss(theme, id, previewMode)
+ applyTheme(theme, id, previewMode)
}
},
commitPreview: () => {
@@ -197,7 +202,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
setStore("previewScheme", null)
const theme = store.themes[store.themeId]
if (theme) {
- applyThemeCss(theme, store.themeId, store.mode)
+ applyTheme(theme, store.themeId, store.mode)
}
},
}