Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ae6740d
Upgrade Bootstrap to 5.3 for dark theme support
yihao03 Mar 9, 2026
e2cbbe5
Refresh CLI functional outputs for dark mode
yihao03 Mar 9, 2026
a06e8dd
Add runtime page theme switching
yihao03 Mar 9, 2026
a1f02db
Add dark mode toggle and component overrides
yihao03 Mar 9, 2026
19d5368
Update tests
yihao03 Mar 11, 2026
78dcb37
Update hard coded mark and blockquote colors
yihao03 Mar 18, 2026
aa1c98f
Merge branch 'master' into feat/dark-mode
yihao03 Mar 18, 2026
403247f
Run npm i
yihao03 Mar 18, 2026
ddb44d9
Update page nav to use bootstrap colours
yihao03 Mar 18, 2026
e419ccb
Use bootstrap adaptive colors instead of hard coded value for nav
yihao03 Mar 18, 2026
60d6df8
Update previous_next colour
yihao03 Mar 18, 2026
81801be
Add adaptive theme for hot reload loading page
yihao03 Mar 18, 2026
c9ac37d
Add adaptive theme for panels
yihao03 Mar 18, 2026
24bb019
Explicitly specify border colors for boxes
yihao03 Mar 18, 2026
317f499
Define mark in markbind.css instead of main.css
yihao03 Mar 19, 2026
bf22300
Build web and update tests
yihao03 Mar 19, 2026
cd774d6
Respect site.json for darkmode config
yihao03 Mar 20, 2026
7260cdb
Update tests
yihao03 Mar 20, 2026
883b5ef
Merge branch 'master' into feat/dark-mode
yihao03 Mar 20, 2026
08491f9
Merge branch 'master' into feat/dark-mode
yihao03 Mar 23, 2026
f109002
Update package lock
yihao03 Mar 23, 2026
c5ad891
Use bs vars instead of theme overrides
yihao03 Mar 23, 2026
c4af618
Refactor panel to stop using isLightBg
yihao03 Mar 23, 2026
81d0684
Remove conditional rendering in toggle vue
yihao03 Mar 23, 2026
462aa72
Merge branch 'master' into feat/dark-mode
yihao03 Mar 26, 2026
f37c491
Merge branch 'master' into feat/dark-mode
yihao03 Mar 27, 2026
2d74dea
Revert light mode highlight behavioural change
yihao03 Mar 27, 2026
e387406
Refactor inline scripts out of page.njk
yihao03 Mar 27, 2026
54ad07b
Update tests
yihao03 Mar 27, 2026
0c02d85
Merge branch 'master' into feat/dark-mode
yihao03 Mar 27, 2026
a0c16a7
Fixed thead divider regression
yihao03 Mar 27, 2026
3732cdf
Merge branch 'master' into feat/dark-mode
Harjun751 Mar 28, 2026
2d34770
Merge branch 'master' into feat/dark-mode
yihao03 Mar 28, 2026
2c73b5d
Build web
yihao03 Mar 28, 2026
adf3f93
Merge branch 'feat/dark-mode' of github.com:yihao03/markbind into fea…
yihao03 Mar 28, 2026
60352c3
Fix disappeared toggle
yihao03 Mar 30, 2026
3a9134f
Move darkmode config into style object
yihao03 Mar 30, 2026
14d0951
Add visual separator for navbar
yihao03 Mar 30, 2026
4d6f446
Build and update test
yihao03 Mar 30, 2026
22491ae
Update site/page-nav border color
yihao03 Mar 30, 2026
0978692
Use variables instead of override for Box
yihao03 Mar 30, 2026
e53e693
Merge branch 'master' into feat/dark-mode
yihao03 Mar 31, 2026
32de6a1
Build and updatetest
yihao03 Mar 31, 2026
39c1306
Add comments in page.njk
yihao03 Apr 1, 2026
05d686b
Merge branch 'master' into feat/dark-mode
yihao03 Apr 1, 2026
bf34a5e
Update docs
yihao03 Apr 1, 2026
dce7cb6
Update docs
yihao03 Apr 1, 2026
4d31eb1
Update site nav color
yihao03 Apr 1, 2026
bd89dd7
Update quizzes
yihao03 Apr 1, 2026
0860e61
Remove hardcoded white background in docs
yihao03 Apr 1, 2026
e022eb9
Enable dark mode in dg
yihao03 Apr 1, 2026
6a4dccc
Merge branch 'feat/dark-mode' of github.com:yihao03/markbind into fea…
yihao03 Apr 1, 2026
a5f8cd0
Build and update test
yihao03 Apr 1, 2026
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
2 changes: 1 addition & 1 deletion docs/_markbind/boilerplates/codeAndOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%%OUTPUT:%%
<div class="indented">

<box border-left-color="grey" background-color="white">
<box border-left-color="grey">

{{ code | safe }}
</box>
Expand Down
2 changes: 1 addition & 1 deletion docs/_markbind/boilerplates/codeAndOutputCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%%OUTPUT:%%
<div class="indented">

<box border-left-color="grey" background-color="white">
<box border-left-color="grey">

{{ code | safe }}
</box>
Expand Down
2 changes: 1 addition & 1 deletion docs/_markbind/boilerplates/codeAndOutputSeparate.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%%OUTPUT:%%
<div class="indented">

<box border-left-color="grey" background-color="white">
<box border-left-color="grey">

{{ output | safe }}
</box>
Expand Down
1 change: 1 addition & 0 deletions docs/_markbind/layouts/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [Using Plugins]({{baseUrl}}/userGuide/usingPlugins.html)
* [Making the Site Searchable]({{baseUrl}}/userGuide/makingTheSiteSearchable.html)
* [Applying Themes]({{baseUrl}}/userGuide/themes.html)
* [Dark Mode]({{baseUrl}}/userGuide/darkMode.html)
* [Deploying the Site]({{baseUrl}}/userGuide/deployingTheSite.html)
* [MarkBind in the Project Workflow]({{baseUrl}}/userGuide/markBindInTheProjectWorkflow.html)
* [Redirecting to a Custom 404 Page]({{baseUrl}}/userGuide/redirectingToACustom404Page.html)
Expand Down
11 changes: 2 additions & 9 deletions docs/css/main.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
mark {
background-color: #ff0;
border-radius: 5px;
padding-top: 0;
padding-bottom: 0;
}

.indented {
padding-left: 20px;
}
Expand Down Expand Up @@ -74,7 +67,7 @@ mark {
}

#site-nav {
border-right: 1px solid lightgrey;
border-right: 1px solid var(--bs-border-color);
padding-bottom: 20px;
z-index: 999;
}
Expand All @@ -89,7 +82,7 @@ mark {
}

#page-nav {
border-left: 1px solid lightgrey;
border-left: 1px solid var(--bs-border-color);
}

@media screen and (width <= 1299.98px) {
Expand Down
1 change: 1 addition & 0 deletions docs/dg-site.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"baseUrl": "/devdocs",
"titlePrefix": "MarkBind",
"style": {
"darkMode": true,
"codeTheme": "light"
},
"pages": [
Expand Down
4 changes: 2 additions & 2 deletions docs/njk/common.njk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% macro previous_next(previous_page, next_page) %}
<div class="clearfix">
{% if previous_page != ''%}
<span class="float-start"><a class="btn btn-light" href="{{ previous_page }}.html"><md>:far-arrow-alt-circle-left: <include src="{{ previous_page }}.md#title" inline /></md></a></span>
<span class="float-start"><a class="btn" href="{{ previous_page }}.html"><md>:far-arrow-alt-circle-left: <include src="{{ previous_page }}.md#title" inline /></md></a></span>
{% endif %}
{% if next_page != ''%}
<span class="float-end"><a class="btn btn-light" href="{{ next_page }}.html"><md><include src="{{ next_page }}.md#title" inline /> :far-arrow-alt-circle-right:</md></a></span>
<span class="float-end"><a class="btn" href="{{ next_page }}.html"><md><include src="{{ next_page }}.md#title" inline /> :far-arrow-alt-circle-right:</md></a></span>
{% endif %}
</div>
<br>
Expand Down
3 changes: 2 additions & 1 deletion docs/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"timeZone": "Asia/Singapore",
"titlePrefix": "MarkBind",
"style": {
"codeTheme": "light"
"codeTheme": "light",
"darkMode": true
},
"pages": [
{
Expand Down
65 changes: 65 additions & 0 deletions docs/userGuide/darkMode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% set title = "Dark Mode" %}
{% set filename = "darkMode" %}
<span id="title" class="d-none">{{ title }}</span>

<frontmatter>
title: "User Guide: {{ title }}"
layout: userGuide.md
</frontmatter>

<span id="link" class="d-none">
<md>[_User Guide → {{ title }}_]({{ filename }}.html)</md>
</span>

# Dark Mode

<div class="lead" id="overview">

**MarkBind now supports _dark mode_**

</div>

#### Enabling Dark Mode

You can enable dark mode for your site by using the [`style.darkMode` property](siteJsonFile.html#style) of your `site.json` configuration file.

```json {heading="site.json"}
{
"style": {
"darkMode": true
}
}
```

Enabling dark mode causes the site to default to the user's system preference.
Readers can also switch between light and dark mode at any time using the
`<dark-mode-toggle/>` component, which appears in the navigation bar to the
right of the search bar. This setting will be remembered for future visits to
the site.

#### Adapting Existing Sites to Dark Mode

##### Updating stylesheet

After enabling dark mode, replace your `/css/main.css` in your markbind site
directory with the latest version [here](https://github.com/yihao03/markbind/raw/05d686b4375078a6d4200e15dcef4831bd37f61e/docs/css/main.css)
to override the default Bootstrap styles with the new dark mode compatible styles.

##### Adapting your contents

We recognise that some of your existing contents e.g. images with transparent
backgrounds and diagrams might have some visibility issues when viewed in dark
mode. We recommend that:

- You wrap your images in a `<box>` tag with light background to improve visibility.

```md
<box background-color="#f8f9fa">
your existing content
</box>
```

- Adapt your diagrams to use colours that are more visible in both modes

{% from "njk/common.njk" import previous_next %}
{{ previous_next('themes', 'deployingTheSite') }}
2 changes: 1 addition & 1 deletion docs/userGuide/deployingTheSite.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,4 @@ For more information on Surge, you may refer to [Surge's docs](https://surge.sh/
</panel>

{% from "njk/common.njk" import previous_next %}
{{ previous_next('themes', 'markBindInTheProjectWorkflow') }}
{{ previous_next('darkMode', 'markBindInTheProjectWorkflow') }}
2 changes: 1 addition & 1 deletion docs/userGuide/markBindSyntaxOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ MarkBind has Vue.js components built on the popular [BootStrap](https://getboots
%%OUTPUT:%%
<div class="indented">

<box border-left-color="grey" background-color="white">
<box border-left-color="grey">

<ul>
{% for item in [1, 2, 3, 4] %}
Expand Down
5 changes: 5 additions & 0 deletions docs/userGuide/siteJsonFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Here is a typical `site.json` file:
"titlePrefix": "FooBar Dev Docs",
"titleSuffix": "FooBar",
"style": {
darkMode: true,
"bootstrapTheme": "bootswatch-cerulean",
"codeTheme": "light",
"codeLineNumbers": true
Expand Down Expand Up @@ -113,6 +114,10 @@ Note: `baseUrl` does not support [live preview](glossary.md#live-preview) as the

_(Optional)_ **The styling options to be applied to the site.** This includes:

* `darkMode`
* [Optional. Default: `false`](/userGuide/darkMode.html#enabling-dark-mode)<br>
Toggles whether to enable dark mode for the site.

* **`bootstrapTheme`**
_(Optional)_ The theme for the generated site.<br>
Uses the default Bootstrap theme if not specified. See [User Guide: Themes](themes.html) for more details.
Expand Down
32 changes: 32 additions & 0 deletions docs/userGuide/syntax/darkModeToggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Dark Mode Toggle

<div id="content">

The `dark-mode-toggle` component provides a button that lets readers switch between light and dark themes.

****Usage****

Add `<dark-mode-toggle></dark-mode-toggle>` to your layout or navbar file. The component is only rendered when dark mode is enabled for the site (via the `enableDarkMode` site property).

****How It Works****

- Defaults to the user's OS-level `prefers-color-scheme` setting
- Persists the user's choice in `localStorage` under the key `markbind-theme`

****Placing in the Navbar****

The toggle is automatically included inside the navbar when dark mode is enabled. You can also place it manually anywhere on the page:

</div>

<div id="short">

```html
<dark-mode-toggle></dark-mode-toggle>
```
</div>

<div id="examples" class="d-none">

You can see an example of the dark mode toggle in the navbar at the top of this page.
</div>
1 change: 1 addition & 0 deletions docs/userGuide/syntax/fullSyntaxSet.njk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
siteNavigationMenus : ['Site Navigation Menus', 'site-navigation-menus', ['navigation', 'reader-facing']],
pageNavigationMenus : ['Page Navigation Menus', 'page-navigation-menus', ['navigation', 'reader-facing']],
scrollTopButton : ['Scroll To Top Button', 'scroll-to-top-button', ['navigation', 'reader-facing']],
darkModeToggle : ['Dark Mode Toggle', 'dark-mode-toggle', ['navigation', 'reader-facing']],
questions : ['Questions and Quizzes', 'questions-and-quizzes', ['others', 'reader-facing']]
} %}

Expand Down
2 changes: 1 addition & 1 deletion docs/userGuide/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ Currently, MarkBind supports all light themes from [Bootswatch](https://bootswat
</div>

{% from "njk/common.njk" import previous_next %}
{{ previous_next('makingTheSiteSearchable', 'deployingTheSite') }}
{{ previous_next('makingTheSiteSearchable', 'darkMode') }}
14 changes: 9 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<html data-dark-mode="false" data-code-theme="dark">

<head>
<script src="/test_site/markbind/js/theme-manager.js"></script>

<meta name="default-head-top">
<script src="/test_site/headFiles/customScriptTop.js"></script>
Expand All @@ -14,7 +15,11 @@
<link rel="stylesheet" href="/test_site/markbind/css/bootstrap.min.css">
<link rel="stylesheet" href="/test_site/markbind/fontawesome/css/all.min.css">
<link rel="stylesheet" href="/test_site/markbind/glyphicons/css/bootstrap-glyphicons.min.css">
<link rel="stylesheet" href="/test_site/markbind/css/codeblock-dark.min.css">


<link rel="stylesheet" id="markbind-highlight-light" href="/test_site/markbind/css/codeblock-light.min.css">
<link rel="stylesheet" id="markbind-highlight-dark" href="/test_site/markbind/css/codeblock-dark.min.css">
<script src="/test_site/markbind/js/code-theme.js"></script>
<link rel="stylesheet" href="/test_site/markbind/css/markbind.min.css">
<link rel="stylesheet" href="/test_site/plugins/testMarkbindPlugin/testMarkbindPluginStylesheet.css">
<link rel="stylesheet" href="/test_site/plugins/web3Form/web-3-form.css">
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/test/functional/test_site/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<html data-dark-mode="false" data-code-theme="dark">

<head>
<script src="/test_site/markbind/js/theme-manager.js"></script>

<meta name="default-head-top">
<script src="/test_site/headFiles/customScriptTop.js"></script>
Expand All @@ -14,7 +15,11 @@
<link rel="stylesheet" href="/test_site/markbind/css/bootstrap.min.css">
<link rel="stylesheet" href="/test_site/markbind/fontawesome/css/all.min.css">
<link rel="stylesheet" href="/test_site/markbind/glyphicons/css/bootstrap-glyphicons.min.css">
<link rel="stylesheet" href="/test_site/markbind/css/codeblock-dark.min.css">


<link rel="stylesheet" id="markbind-highlight-light" href="/test_site/markbind/css/codeblock-light.min.css">
<link rel="stylesheet" id="markbind-highlight-dark" href="/test_site/markbind/css/codeblock-dark.min.css">
<script src="/test_site/markbind/js/code-theme.js"></script>
<link rel="stylesheet" href="/test_site/markbind/css/markbind.min.css">
<link rel="stylesheet" href="/test_site/plugins/testMarkbindPlugin/testMarkbindPluginStylesheet.css">
<link rel="stylesheet" href="/test_site/plugins/web3Form/web-3-form.css">
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Loaded immediately after the highlight stylesheet <link> elements.
* Disables the stylesheet that doesn't match the active theme.
*
* Reads from window.__MARKBIND_THEME__ (set by theme-manager.js) or falls back
* to the data-code-theme attribute on <html> set by the server.
*/
(function () {
const theme = window.__MARKBIND_THEME__
|| document.documentElement.getAttribute('data-code-theme')
|| 'light';

const lightSheet = document.getElementById('markbind-highlight-light');
const darkSheet = document.getElementById('markbind-highlight-dark');

if (lightSheet && darkSheet) {
lightSheet.disabled = theme !== 'light';
darkSheet.disabled = theme !== 'dark';
}
}());

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Loaded as early as possible in <head> to prevent flash of unstyled content (FOUC).
* Sets data-bs-theme on <html> before any stylesheets are applied.
*
* Reads from <html> attributes set by the server:
* - data-dark-mode="true|false"
*/
(function () {
if (document.documentElement.getAttribute('data-dark-mode') !== 'true') return;

const STORAGE_KEY = 'markbind-theme';
let stored;
try { stored = localStorage.getItem(STORAGE_KEY); } catch (e) { /* ignore */ }

let theme;
if (stored === 'dark' || stored === 'light') {
theme = stored;
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark';
} else {
theme = 'light';
}
document.documentElement.setAttribute('data-bs-theme', theme);
window.__MARKBIND_THEME__ = theme;
window.__MARKBIND_DARK_MODE__ = true;
}());
Loading
Loading