Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dark mode toggle #88

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ github_username: chaincodelabs

# Build settings
theme: just-the-docs
# Color scheme supports "light" (default) and "dark"
color_scheme: dark
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the default colour scheme to dark.

I think, even as a dark-mode maximalist myself, light-by-default makes most sense on the web. @adamjonas what do you think?

plugins:
- asciidoctor-diagram
- jekyll-feed
Expand Down
17 changes: 17 additions & 0 deletions _includes/head_custom.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/asciidoc.css">

<button class="btn js-toggle-dark-mode"><i class="fa fa-sun-o"></i></button>

<script>
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');
const toggleIcon = toggleDarkMode.querySelector('i');

jtd.addEvent(toggleDarkMode, 'click', function() {
if (jtd.getTheme() === 'dark') {
jtd.setTheme('light');
toggleIcon.className = 'fa fa-moon-o';
} else {
jtd.setTheme('dark');
toggleIcon.className = 'fa fa-sun-o';
}
});
</script>
Loading