Skip to content

Commit fb1815a

Browse files
committed
Apply color-scheme-light class to html element for proper CSS variable inheritance
The previous fix applied the color-scheme-light class only to the body element, but CSS variables were defined on :root (the html element). This caused specificity issues where the variables wouldn't properly override. Now applying the class to both document.documentElement (html) and document.body to ensure CSS variables are properly inherited throughout the iframe. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent eb8e467 commit fb1815a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

website/src/components/code-preview.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ function generateJavaScriptIFrameHTML(
5555
: "light"
5656
);
5757
if (colorScheme === "dark") {
58+
document.documentElement.classList.remove("color-scheme-light");
5859
document.body.classList.remove("color-scheme-light");
5960
} else {
61+
document.documentElement.classList.add("color-scheme-light");
6062
document.body.classList.add("color-scheme-light");
6163
}
6264
</script>
@@ -145,8 +147,10 @@ function generatePythonIFrameHTML(
145147
: "light"
146148
);
147149
if (colorScheme === "dark") {
150+
document.documentElement.classList.remove("color-scheme-light");
148151
document.body.classList.remove("color-scheme-light");
149152
} else {
153+
document.documentElement.classList.add("color-scheme-light");
150154
document.body.classList.add("color-scheme-light");
151155
}
152156
</script>

0 commit comments

Comments
 (0)