Skip to content

Commit 20bd425

Browse files
committed
Fix bug where project creation pages always start in light mode
1 parent 11f9cdc commit 20bd425

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/webview/newMicroPythonProjectPanel.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,12 @@ print("Finished.")\r\n`;
471471
// Restrict the webview to only load specific scripts
472472
const nonce = getNonce();
473473

474+
const defaultTheme =
475+
window.activeColorTheme.kind === ColorThemeKind.Dark ||
476+
window.activeColorTheme.kind === ColorThemeKind.HighContrast
477+
? "dark"
478+
: "light";
479+
474480
return `<!DOCTYPE html>
475481
<html lang="en">
476482
<head>
@@ -492,9 +498,12 @@ print("Finished.")\r\n`;
492498
tailwind.config = {
493499
darkMode: 'class',
494500
};
501+
502+
localStorage.theme = "${defaultTheme}";
503+
495504
</script>
496505
</head>
497-
<body class="scroll-smooth w-screen">
506+
<body class="scroll-smooth w-screen${defaultTheme === "dark" ? " dark" : ""}">
498507
<div id="above-nav" class="container max-w-6xl mx-auto flex justify-between items-center w-full sticky top-0 z-10 pl-5 h-5">
499508
</div>
500509
<div id="nav-overlay" class="overlay hidden md:hidden inset-y-0 right-0 w-auto z-50 overflow-y-auto ease-out bg-slate-400 dark:bg-slate-800 drop-shadow-lg">

src/webview/newProjectPanel.mts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,13 @@ export class NewProjectPanel {
14911491
)
14921492
);
14931493

1494+
const defaultTheme =
1495+
window.activeColorTheme.kind === ColorThemeKind.Dark ||
1496+
window.activeColorTheme.kind === ColorThemeKind.HighContrast
1497+
? "dark"
1498+
: "light";
1499+
const riscvDefaultSvgUri = defaultTheme === "dark" ? riscvWhiteSvgUri : riscvBlackSvgUri;
1500+
14941501
this._versionBundlesLoader = new VersionBundlesLoader(this._extensionUri);
14951502

14961503
// construct auxiliary html
@@ -1664,14 +1671,16 @@ export class NewProjectPanel {
16641671
var doProjectImport = ${this._isProjectImport};
16651672
var forceCreateFromExample = ${forceCreateFromExample};
16661673
1674+
localStorage.theme = "${defaultTheme}";
1675+
16671676
// riscv logos
16681677
const riscvWhiteSvgUri = "${riscvWhiteSvgUri.toString()}";
16691678
const riscvWhiteYellowSvgUri = "${riscvWhiteYellowSvgUri.toString()}";
16701679
const riscvBlackSvgUri = "${riscvBlackSvgUri.toString()}";
16711680
const riscvColorSvgUri = "${riscvColorSvgUri.toString()}";
16721681
</script>
16731682
</head>
1674-
<body class="scroll-smooth w-screen">
1683+
<body class="scroll-smooth w-screen${defaultTheme === "dark" ? " dark" : ""}">
16751684
<div id="above-nav" class="container max-w-6xl mx-auto flex justify-between items-center w-full sticky top-0 z-10 pl-5 h-5">
16761685
</div>
16771686
<div id="nav-overlay" class="overlay hidden md:hidden inset-y-0 right-0 w-auto z-50 overflow-y-auto ease-out bg-slate-400 dark:bg-slate-800 drop-shadow-lg">
@@ -1796,7 +1805,7 @@ export class NewProjectPanel {
17961805
<label for="riscvToggle" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Architecture (Pico 2)</label>
17971806
<div class="flex items-center justify-between p-2 bg-gray-100 rounded-lg dark:bg-gray-700">
17981807
<input type="checkbox" id="sel-riscv" class="ms-2" />
1799-
<img id="riscvIcon" src="${riscvColorSvgUri.toString()}" alt="RISC-V Logo" class="h-6 mx-auto w-28">
1808+
<img id="riscvIcon" src="${riscvDefaultSvgUri.toString()}" alt="RISC-V Logo" class="h-6 mx-auto w-28">
18001809
</div>
18011810
</div>
18021811
</div>

0 commit comments

Comments
 (0)