Skip to content
Merged
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: 4 additions & 0 deletions _includes/Footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h6>
// Theme toggle
const themeToggle = document.querySelector('.theme-toggle');
const root = document.documentElement;
const body = document.body;

function setTheme(theme) {
root.setAttribute('data-theme', theme);
Expand All @@ -33,6 +34,9 @@ <h6>
}

themeToggle.addEventListener('click', function() {
root.classList.add('theme-transition');
body.classList.add('theme-transition');

const isDark = root.getAttribute('data-theme') === 'dark';
setTheme(isDark ? 'light' : 'dark');
});
Expand Down
4 changes: 3 additions & 1 deletion assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
--border: #33343a;
}

html, body {
/* smooth transition on theme switching */
html.theme-transition,
body.theme-transition {
transition: background 0.3s, color 0.3s;
}

Expand Down