diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js
index d95a281ac..43154c300 100644
--- a/assets/js/darkmode.js
+++ b/assets/js/darkmode.js
@@ -6,24 +6,32 @@ if (currentTheme) {
}
const switchTheme = (e) => {
- if (e.target.checked) {
+ if (e.checked) {
document.documentElement.setAttribute('saved-theme', 'dark')
localStorage.setItem('theme', 'dark')
+ document.querySelector('#darkmode-icon').setAttribute('class', 'fa fa-moon-o')
}
else {
document.documentElement.setAttribute('saved-theme', 'light')
localStorage.setItem('theme', 'light')
+ document.querySelector('#darkmode-icon').setAttribute('class', 'fa fa-sun-o')
}
}
window.addEventListener('DOMContentLoaded', () => {
// Darkmode toggle
const toggleSwitch = document.querySelector('#darkmode-toggle')
+ const dmSwitch = document.querySelector('#darkmode-switch')
// listen for toggle
- toggleSwitch.addEventListener('change', switchTheme, false)
+ dmSwitch.addEventListener('click', (e) => {
+ toggleSwitch.checked = !toggleSwitch.checked;
+ switchTheme(toggleSwitch);
+ }, false);
+
if (currentTheme === 'dark') {
toggleSwitch.checked = true
+ document.querySelector('#darkmode-icon').setAttribute('class', 'fa fa-moon-o')
}
})
diff --git a/assets/styles/darkmode.scss b/assets/styles/darkmode.scss
index 61967d797..3f0a7fb99 100644
--- a/assets/styles/darkmode.scss
+++ b/assets/styles/darkmode.scss
@@ -1,8 +1,8 @@
.darkmode {
- float: right;
+ // float: right;
padding: 1em;
min-width: 30px;
- position: relative;
+ // position: relative;
@media all and (max-width: 450px) {
padding: 1em;
diff --git a/assets/styles/header.scss b/assets/styles/header.scss
new file mode 100644
index 000000000..8d40c2835
--- /dev/null
+++ b/assets/styles/header.scss
@@ -0,0 +1,53 @@
+.header {
+ overflow: hidden;
+ width: 100%;
+ }
+
+ /* Style the header links */
+ .header a {
+ float: left;
+ text-align: center;
+ padding: 12px;
+ text-decoration: none;
+ font-size: 14px;
+ line-height: 25px;
+ border-radius: 4px;
+ }
+
+ /* Style the logo link (notice that we set the same value of line-height and font-size to prevent the header to increase when the font gets bigger */
+ .header a.logo {
+ font-size: 2em;
+ font-weight: bold;
+ padding-left: 0px;
+ padding-right: 0px;
+ // padding: 0px;
+ }
+
+ /* Change the background color on mouse-over */
+ .header a:hover {
+ background-color: #ddd;
+ color: black;
+ }
+
+ /* Style the active/current link*/
+ .header a.active {
+ background-color: dodgerblue;
+ color: white;
+ }
+
+ /* Float the link section to the right */
+ .header-right {
+ float: right;
+ }
+
+ /* Add media queries for responsiveness - when the screen is 500px wide or less, stack the links on top of each other */
+ @media screen and (max-width: 600px) {
+ .header a {
+ float: none;
+ display: block;
+ text-align: left;
+ }
+ .header-right {
+ float: none;
+ }
+ }
\ No newline at end of file
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 3230d4d96..39244dd80 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,11 +1,17 @@
+
-
-
-
-
-
-
-
-
- {{partial "darkmode.html" .}}
+