Skip to content

Commit 55e9a8a

Browse files
committed
Add button for switching to dark mode. At least for now.
1 parent 1fd0022 commit 55e9a8a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

Diff for: docs/_includes/nav.html

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<nav role="navigation" aria-label="Main navigation">
2+
<p>
3+
<button class="btn js-toggle-dark-mode">Switch to dark</button>
4+
</p>
5+
6+
<script>
7+
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode')
8+
const cssFile = document.querySelector('[rel="stylesheet"]')
9+
const originalCssRef = cssFile.getAttribute('href')
10+
const darkModeCssRef = originalCssRef.replace('just-the-docs.css', 'dark-mode-preview.css')
11+
12+
addEvent(toggleDarkMode, 'click', function () {
13+
if (cssFile.getAttribute('href') === originalCssRef) {
14+
cssFile.setAttribute('href', darkModeCssRef)
15+
} else {
16+
cssFile.setAttribute('href', originalCssRef)
17+
}
18+
})
19+
</script>
20+
<ul class="navigation-list">
21+
{% assign pages_list = site.html_pages | sort:"nav_order" %}
22+
{% for node in pages_list %}
23+
{% unless node.nav_exclude %}
24+
{% if node.parent == nil %}
25+
<li class="navigation-list-item{% if page.url == node.url or page.parent == node.title or page.grand_parent == node.title %} active{% endif %}">
26+
{% if page.parent == node.title or page.grand_parent == node.title %}
27+
{% assign first_level_url = node.url | absolute_url %}
28+
{% endif %}
29+
<a href="{{ node.url | absolute_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
30+
{% if node.has_children %}
31+
{% assign children_list = site.html_pages | sort:"nav_order" %}
32+
<ul class="navigation-list-child-list ">
33+
{% for child in children_list %}
34+
{% if child.parent == node.title %}
35+
<li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
36+
{% if page.url == child.url or page.parent == child.title %}
37+
{% assign second_level_url = child.url | absolute_url %}
38+
{% endif %}
39+
<a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
40+
{% if child.has_children %}
41+
{% assign grand_children_list = site.html_pages | sort:"nav_order" %}
42+
<ul class="navigation-list-child-list">
43+
{% for grand_child in grand_children_list %}
44+
{% if grand_child.parent == child.title %}
45+
<li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}">
46+
<a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
47+
</li>
48+
{% endif %}
49+
{% endfor %}
50+
</ul>
51+
{% endif %}
52+
</li>
53+
{% endif %}
54+
{% endfor %}
55+
</ul>
56+
{% endif %}
57+
</li>
58+
{% endif %}
59+
{% endunless %}
60+
{% endfor %}
61+
</ul>
62+
</nav>

Diff for: docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
44

55
layout: default
6+
title: Index
67
---
78

89
<h2 align="center">Supporting Enqueue</h2>

0 commit comments

Comments
 (0)