Skip to content

Commit

Permalink
feat: Detect firefox darkmode for devtools icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bfanger committed Sep 24, 2023
1 parent 6da4ed1 commit 6a6f9bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/firefox-extension/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ for (const file of [
"pixi-panel.html",
"icon.png",
"[email protected]",
"panel-icon.svg",
"[email protected]",
"[email protected]",
]) {
fs.copyFileSync(path.join(srcDir, file), path.join(outdir, file));
}
Expand Down
File renamed without changes
3 changes: 3 additions & 0 deletions apps/firefox-extension/src/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion apps/firefox-extension/src/pixi-devtools.ts
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
browser.devtools.panels.create("PixiJS", "panel-icon.svg", "pixi-panel.html");
let iconPath = "";
// Detect darkmode.
// This only works when devtools uses the same mode as the browser.
browser.devtools.inspectedWindow
.eval("window.matchMedia('(prefers-color-scheme: dark)').matches")
.then((result) => {
if (Array.isArray(result)) {
iconPath = result[0] ? "[email protected]" : "[email protected]";
}
})
.finally(() => {
browser.devtools.panels.create("PixiJS", iconPath, "pixi-panel.html");
});

0 comments on commit 6a6f9bb

Please sign in to comment.