Skip to content

Commit 2ba8f13

Browse files
committed
doc: modernize site + dark theme
- remove the default ascii doctor theme - add dark theme - use atom-one-dark as highlight - fix #3859
1 parent e94507b commit 2ba8f13

5 files changed

Lines changed: 521 additions & 221 deletions

File tree

docs/asciidoc/docinfo-footer.html

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
1+
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle Dark Mode">
2+
<svg class="sun-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18.75a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75zM6.166 18.894a.75.75 0 01-1.06-1.06l1.59-1.591a.75.75 0 111.061 1.06l-1.59 1.591zM2.25 12a.75.75 0 01.75-.75h2.25a.75.75 0 010 1.5H3a.75.75 0 01-.75-.75zM5.106 6.166a.75.75 0 011.06-1.06l1.591 1.59a.75.75 0 11-1.06 1.061l-1.591-1.59z"/></svg>
3+
<svg class="moon-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M9.528 1.718a.75.75 0 01.162.819A8.97 8.97 0 009 6a9 9 0 009 9 8.97 8.97 0 003.463-.69.75.75 0 01.981.98 10.503 10.503 0 01-9.694 6.46c-5.799 0-10.5-4.701-10.5-10.5 0-4.368 2.667-8.112 6.46-9.694a.75.75 0 01.818.162z" clip-rule="evenodd"/></svg>
4+
</button>
5+
16
<script src="/js/clipboard.min.js"></script>
27
<script src="/js/toc.js"></script>
38

49
<script>
5-
// Replacing $(function() { ... }) with native DOMContentLoaded
610
document.addEventListener('DOMContentLoaded', () => {
7-
/** Tabs: */
11+
12+
/** 1. Theme Switcher Logic */
13+
const themeToggle = document.getElementById('theme-toggle');
14+
const htmlElement = document.documentElement;
15+
const hljsThemeLink = document.getElementById('hljs-theme'); // Grab the CSS link
16+
17+
if (themeToggle) {
18+
themeToggle.addEventListener('click', () => {
19+
if (htmlElement.getAttribute('data-theme') === 'dark') {
20+
// Switch to Light Mode
21+
htmlElement.removeAttribute('data-theme');
22+
localStorage.setItem('jooby-theme', 'light');
23+
24+
// Switch code block to Agate
25+
if (hljsThemeLink) hljsThemeLink.href = 'js/styles/agate.min.css';
26+
27+
} else {
28+
// Switch to Dark Mode
29+
htmlElement.setAttribute('data-theme', 'dark');
30+
localStorage.setItem('jooby-theme', 'dark');
31+
32+
// Switch code block to Atom One Dark
33+
if (hljsThemeLink) hljsThemeLink.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css';
34+
}
35+
});
36+
}
37+
38+
/** 2. Tabs Logic */
839
const tabButtons = document.querySelectorAll('.primary .switch .switch--item');
940
const contents = document.querySelectorAll('.primary .content');
1041

1142
tabButtons.forEach(button => {
1243
button.addEventListener('click', function () {
13-
// Extract option number (e.g., '1' from 'option-1')
1444
const match = this.className.match(/option-(\d+)/);
1545
if (!match) return;
1646
const option = match[1];
@@ -28,11 +58,24 @@
2858
});
2959
});
3060

31-
/** Clipboard.js Initialization */
32-
// Note: Since you're already loading clipboard.min.js, we just use the native constructor
61+
/** 3. Clipboard.js Initialization */
3362
const clipboard = new ClipboardJS('.clipboard');
3463
clipboard.on('success', (e) => {
3564
e.clearSelection();
65+
const btn = e.trigger;
66+
const originalHTML = btn.innerHTML;
67+
68+
// Temporarily change background and insert a checkmark SVG
69+
btn.style.backgroundColor = '#10b981'; // Tailwind emerald-500
70+
btn.style.borderColor = '#059669';
71+
btn.innerHTML = `<svg fill="none" stroke="white" stroke-width="2.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"></path></svg>`;
72+
73+
// Revert back after 2 seconds
74+
setTimeout(() => {
75+
btn.style.backgroundColor = '';
76+
btn.style.borderColor = '';
77+
btn.innerHTML = originalHTML;
78+
}, 2000);
3679
});
3780
});
3881
</script>

docs/asciidoc/docinfo.html

Lines changed: 9 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,9 @@
1-
<link rel="stylesheet" href="/js/styles/toc.css">
2-
<style>
3-
/** Tabs */
4-
.hidden {
5-
display: none;
6-
}
7-
8-
.switch {
9-
display: inline-block;
10-
}
11-
12-
.switch--item {
13-
padding: 5px 10px;
14-
color: #fff;
15-
display: inline-block;
16-
cursor: pointer;
17-
background-color: #333;
18-
border-left: 1px solid #ffa;
19-
}
20-
21-
.switch--item:not(:first-child) {
22-
}
23-
24-
.switch--item:last-child {
25-
border-radius: 0 5px 0 0;
26-
}
27-
28-
.switch--item.selected {
29-
color: #ffa;
30-
border-bottom: 1px solid #ffa;
31-
}
32-
33-
.clipboard {
34-
position: absolute;
35-
bottom: .1rem;
36-
right: .1rem;
37-
display: inline-block;
38-
padding: 4px 8px;
39-
font-size: 13px;
40-
font-weight: 700;
41-
line-height: 20px;
42-
color: #333;
43-
white-space: nowrap;
44-
vertical-align: middle;
45-
cursor: pointer;
46-
background-color: #eee;
47-
background-image: linear-gradient(#fcfcfc, #eee);
48-
border: 1px solid #d5d5d5;
49-
border-radius: 3px;
50-
-webkit-user-select: none;
51-
-moz-user-select: none;
52-
-ms-user-select: none;
53-
user-select: none;
54-
-webkit-appearance: none
55-
}
56-
57-
.clipboard i {
58-
font-style: normal;
59-
font-weight: 500;
60-
opacity: .6
61-
}
62-
63-
.clipboard .octicon {
64-
vertical-align: text-top
65-
}
66-
67-
.clipboard .counter {
68-
text-shadow: none;
69-
background-color: #e5e5e5
70-
}
71-
72-
.clipboard:focus {
73-
text-decoration: none;
74-
border-color: #51a7e8;
75-
outline: none;
76-
box-shadow: 0 0 5px rgba(81, 167, 232, .5)
77-
}
78-
79-
.clipboard:focus:hover, .clipboard.selected:focus {
80-
border-color: #51a7e8
81-
}
82-
83-
.clipboard:hover, .clipboard:active, .clipboard.zeroclipboard-is-hover, .clipboard.zeroclipboard-is-active {
84-
text-decoration: none;
85-
background-color: #ddd;
86-
background-image: linear-gradient(#eee, #ddd);
87-
border-color: #ccc
88-
}
89-
90-
.clipboard:active, .clipboard.selected, .clipboard.zeroclipboard-is-active {
91-
background-color: #dcdcdc;
92-
background-image: none;
93-
border-color: #b5b5b5;
94-
box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15)
95-
}
96-
97-
.clipboard.selected:hover {
98-
background-color: #cfcfcf
99-
}
100-
101-
.clipboard:disabled, .clipboard:disabled:hover, .clipboard.disabled, .clipboard.disabled:hover {
102-
color: rgba(102, 102, 102, .5);
103-
cursor: default;
104-
background-color: rgba(229, 229, 229, .5);
105-
background-image: none;
106-
border-color: rgba(197, 197, 197, .5);
107-
box-shadow: none
108-
}
109-
</style>
1+
<script>
2+
// This MUST be in the <head>. It runs before the body is rendered, preventing the white flash.
3+
(function() {
4+
const savedTheme = localStorage.getItem('jooby-theme');
5+
if (savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
6+
document.documentElement.setAttribute('data-theme', 'dark');
7+
}
8+
})();
9+
</script>

0 commit comments

Comments
 (0)