Skip to content

Commit 5f298cf

Browse files
authored
Merge pull request #12514 from quarto-dev/bugfix/light-overlays-dark
honor the dark = light + dark stylesheet convention
2 parents 7707c79 + b95f45d commit 5f298cf

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/command/render/pandoc-html.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export async function resolveSassBundles(
142142
)
143143
? "dark"
144144
: "light";
145-
const targets: SassTarget[] = [{
145+
let targets: SassTarget[] = [{
146146
name: `${dependency}.min.css`,
147147
bundles: (bundles as any),
148148
attribs: {
@@ -175,10 +175,22 @@ export async function resolveSassBundles(
175175
...attribForThemeStyle("dark"),
176176
},
177177
};
178-
if (defaultStyle === "dark") {
178+
if (defaultStyle === "dark") { // light, dark
179179
targets.push(darkTarget);
180-
} else {
181-
targets.unshift(darkTarget);
180+
} else { // light, dark, light
181+
const lightTargetExtra = {
182+
...targets[0],
183+
attribs: {
184+
...targets[0].attribs,
185+
class: "quarto-color-scheme-extra",
186+
},
187+
};
188+
189+
targets = [
190+
targets[0],
191+
darkTarget,
192+
lightTargetExtra,
193+
];
182194
}
183195

184196
hasDarkStyles = true;

src/resources/formats/html/templates/quarto-html-before-body.ejs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
4242
manageTransitions('#quarto-margin-sidebar .nav-link', false);
4343
if (alternate) {
44-
disableStylesheet(primaryStylesheets)
44+
// note: dark is layered on light, we don't disable primary!
4545
enableStylesheet(alternateStylesheets);
4646
for (const sheetNode of alternateStylesheets) {
4747
if (sheetNode.id === "quarto-bootstrap") {
@@ -170,6 +170,10 @@
170170
<% } else { %>
171171
const darkModeDefault = <%= darkModeDefault %>;
172172
<% } %>
173+
174+
<% if (!darkModeDefault) { %>
175+
document.querySelector('link.quarto-color-scheme-extra').rel = 'disabled-stylesheet';
176+
<% } %>
173177
174178
let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default';
175179

0 commit comments

Comments
 (0)