Skip to content

Commit

Permalink
Sync dark mode on browser_info object (#7382)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Oct 16, 2024
1 parent 0bb5cd3 commit 0b59d53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion panel/models/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export class BrowserInfoView extends View {
super.initialize()

if (window.matchMedia != null) {
this.model.dark_mode = window.matchMedia("(prefers-color-scheme: dark)").matches
const darkModeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)")
darkModeMediaQuery.addEventListener("change", (e) => {
this.model.dark_mode = e.matches
})
this.model.dark_mode = darkModeMediaQuery.matches
}
this.model.device_pixel_ratio = window.devicePixelRatio
if (navigator != null) {
Expand Down

0 comments on commit 0b59d53

Please sign in to comment.