Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Themes/default/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
/* agree those values first and then check that each component reached for the
/* right one. */
:root[data-mode="dark"],
:root[data-mode="system"] {
:root[data-mode="system"],
body[contenteditable="true"][data-mode="dark"],
body[contenteditable="true"][data-mode="system"] {

/* The surfaces, from the page behind everything up to the topmost thing
/* that floats above it, then the two hairline weights, the three text
Expand Down
37 changes: 20 additions & 17 deletions Themes/default/css/jquery.sceditor.default.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ html {
}
body {
flex: 1;
color: #111;
background: #fff;
font: 13px / 1.5 Verdana, Arial, Helvetica, sans-serif;
background: var(--body-bg);
font: var(--body-font-size)/150% var(--body-font-family);
color: var(--body-color);
}

ul, ol {
Expand All @@ -23,7 +23,7 @@ ul, ol {
}

table, td {
border: 1px dotted #000;
border: var(--bbc-table-border-width) var(--bbc-table-border-style) var(--bbc-table-border-color);
empty-cells: show;
min-width: 0.5ch;
}
Expand All @@ -46,37 +46,40 @@ table td {
.bbc_code {
margin-top: 1.5em;
position: relative;
background: #eee;
border: 1px solid #aaa;
background: var(--code-bg);
border-color: var(--code-border-color);
border-style: var(--code-border-style);
border-width: var(--code-border-width);
border-radius: var(--code-border-radius);
white-space: pre-wrap;
padding: .25em;
display: block;
}

span.phpcode, font[face=monospace] {
background-color: rgba(127, 127, 127, 0.25);
background: var(--code-bg);
padding: 0 0.2ch;
display: inline;
}

blockquote {
margin: 0 0 8px 0;
padding: 6px 10px;
font-size: small;
border: 1px solid #d6dfe2;
border-left: 2px solid #aaa;
border-right: 2px solid #aaa;
background-color: #e0e6f6;
background-color: var(--quote-bg);
font-size: var(--quote-font-size);
border-color: var(--quote-border-color);
border-style: var(--quote-border-style);
border-width: var(--quote-border-width);
}
blockquote cite {
display: block;
border-bottom: 1px solid #aaa;
border-bottom: var(--quote-cite-border-width) var(--quote-cite-border-style) var(--quote-cite-border-color);
font-size: 0.9em;
margin-bottom: 0.5em;
}

blockquote cite::before {
color: #aaa;
color: var(--bbc-cite-color);
font-size: 22px;
font-style: normal;
content: '\275D';
Expand Down Expand Up @@ -157,16 +160,16 @@ img {
}

.bbc_details {
border: 1px dotted #aaa;
border: var(--bbc-details-border-width) var(--bbc-details-border-style) var(--bbc-details-border-color);
}
.bbc_summary,
.bbc_details_content {
margin: 5px;
}
.bbc_details[open] .bbc_summary {
padding-bottom: 5px;
border-bottom: 1px dotted #aaa;
border-bottom: var(--bbc-details-border-width) var(--bbc-details-border-style) var(--bbc-details-border-color);
}
.bbc_inline_spoiler {
outline: 2px dashed #aaa;
outline: var(--bbc-spoiler-outline-width) var(--bbc-spoiler-outline-style) var(--bbc-spoiler-outline-color);
}
18 changes: 18 additions & 0 deletions Themes/default/scripts/sceditor.plugins.smf.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,24 @@
css += rule.cssText;
}
}
} else if (sheet.href?.includes('/dark')) {
const currentMode = document.documentElement.getAttribute('data-mode') ?? 'system';
const runningDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');

// If we are forcing dark mode or have it running on system, copy the rules.
if (currentMode === "dark" || (currentMode === "system" && runningDarkMode)) {
for (const rule of sheet.cssRules) {
css += rule.cssText;
}
iframe.contentDocument.body.setAttribute('data-mode', currentMode === "dark" || runningDarkMode.matches ? 'dark' : 'light');

// Attach a listener to see if we switch from dark to light mode.
if (currentMode === "system") {
runningDarkMode.addEventListener('change', e => {
iframe.contentDocument.body.setAttribute('data-mode', runningDarkMode.matches ? 'dark' : 'light');
});
}
}
}
}
el.innerHTML = css;
Expand Down
Loading