Skip to content

Commit 7e06952

Browse files
put dark stylesheet first
so that light style is shown when js is disabled
1 parent 3aad3b1 commit 7e06952

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/command/render/pandoc-html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export async function resolveSassBundles(
144144
bundle.key = bundle.key + "-dark";
145145
return bundle;
146146
});
147-
targets.push({
147+
targets.unshift({
148148
name: `${dependency}-dark.min.css`,
149149
bundles: darkBundles as any,
150150
attribs: {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
1717
const toggleBodyColorPrimary = () => {
18-
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
18+
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap:not([rel=disabled-stylesheet])");
1919
if (bsSheetEl) {
2020
toggleBodyColorMode(bsSheetEl);
2121
}
@@ -26,9 +26,11 @@
2626
2727
const toggleColorMode = (alternate) => {
2828
// Switch the stylesheets
29+
const primaryStylesheets = window.document.querySelectorAll('link.quarto-color-scheme:not(.quarto-color-alternate)');
2930
const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
3031
manageTransitions('#quarto-margin-sidebar .nav-link', false);
3132
if (alternate) {
33+
disableStylesheet(primaryStylesheets)
3234
enableStylesheet(alternateStylesheets);
3335
for (const sheetNode of alternateStylesheets) {
3436
if (sheetNode.id === "quarto-bootstrap") {
@@ -37,6 +39,7 @@
3739
}
3840
} else {
3941
disableStylesheet(alternateStylesheets);
42+
enableStylesheet(primaryStylesheets)
4043
toggleBodyColorPrimary();
4144
}
4245
manageTransitions('#quarto-margin-sidebar .nav-link', true);

0 commit comments

Comments
 (0)