Skip to content

New logo, dark mode on landing page #1549

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

Merged
merged 2 commits into from
May 20, 2024
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
Prev Previous commit
Add dark mode to landing page
  • Loading branch information
bkoelman committed May 20, 2024
commit dd61f78e97c1f793e558f6ef9d2ea33d0c9c6d8d
16 changes: 16 additions & 0 deletions docs/home/assets/dark-mode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
html {
background-color: #171717 !important;
filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(85%);
-webkit-filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(85%);
}

body {
background-color: #FFF !important;
}

img,
video,
body * [style*="background-image"] {
filter: hue-rotate(180deg) contrast(100%) invert(100%);
-webkit-filter: hue-rotate(180deg) contrast(100%) invert(100%);
}
8 changes: 8 additions & 0 deletions docs/home/assets/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,11 @@ div[sponsor]:hover {
padding: 3px 0;
}
}

/*--------------------------------------------------------------
# Theme selection
--------------------------------------------------------------*/
.btn-theme:focus,
.btn-theme:active {
box-shadow: none !important;
}
29 changes: 29 additions & 0 deletions docs/home/assets/home.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
function setTheme(theme) {
const darkModeStyleSheet = document.getElementById('dark-mode-style-sheet');
const activeTheme = document.getElementById('active-theme');

if (theme === "auto") {
darkModeStyleSheet.disabled = !window.matchMedia("(prefers-color-scheme: dark)").matches;
activeTheme.className = "bi-circle-half";
}
else if (theme === "dark") {
darkModeStyleSheet.disabled = false;
activeTheme.className = "bi bi-moon";
} else if (theme === "light") {
darkModeStyleSheet.disabled = true;
activeTheme.className = "bi bi-sun";
}

localStorage.setItem("theme", theme)
}

$('.theme-choice').click(function () {
setTheme(this.dataset.theme);
})

function initTheme() {
const theme = localStorage.getItem("theme") || "auto";
setTheme(theme);
}

!(function($) {
"use strict";

Expand Down Expand Up @@ -89,6 +117,7 @@
}
$(window).on('load', function() {
aos_init();
initTheme();
});

})(jQuery);
28 changes: 28 additions & 0 deletions docs/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,41 @@
<link href="favicon.ico" rel="apple-touch-icon">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,600,600i,700,700i" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<link href="https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.0/styles/default.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/aos/2.3.4/aos.css" rel="stylesheet">
<link href="styles/home.css" rel="stylesheet">
<link href="styles/icofont.min.css" rel="stylesheet">
<link href="styles/dark-mode.css" rel="stylesheet" id="dark-mode-style-sheet" disabled>
<script>
// Running this early to prevent an initial white flash on page load when dark mode is the default theme.
const darkModeStyleSheet = document.getElementById('dark-mode-style-sheet');
const theme = localStorage.getItem("theme") || "auto";

if (theme === "auto") {
darkModeStyleSheet.disabled = !window.matchMedia("(prefers-color-scheme: dark)").matches;
}
else if (theme === "dark") {
darkModeStyleSheet.disabled = false;
} else if (theme === "light") {
darkModeStyleSheet.disabled = true;
}
</script>
</head>
<body>
<div class="container-xl">
<div class="dropdown p-3 float-right">
<a class="btn btn-theme dropdown-toggle" href="#" role="button" id="themeSelector" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i id="active-theme"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="themeSelector">
<a class="dropdown-item theme-choice" data-theme="light" href="#"><i class="bi bi-sun"></i> Light</a>
<a class="dropdown-item theme-choice" data-theme="dark" href="#"><i class="bi bi-moon"></i> Dark</a>
<a class="dropdown-item theme-choice" data-theme="auto" href="#"><i class="bi-circle-half"></i> Auto</a>
</div>
</div>
</div>
<section id="hero" class="d-flex align-items-center">
<div class="container">
<div class="row">
Expand Down