Files
website/themes/exectos/layouts/partials/header.html
T
belliash 5e5d203966
Builds / ExectOS WebSite (push) Successful in 33s
Add dark theme
2026-11-29 21:04:43 +01:00

48 lines
2.3 KiB
HTML

<div class="wrapper_header">
<div class="header">
<h1><a href="{{ .Site.BaseURL }}"><img src="/images/exectos_logo.png" alt="LOGO" width="50px" /> {{ .Site.Title }}</a></h1>
<ul>
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ .Name }}<span class="caret"></span></a>
<ul class="dropdown-menu">
{{ range .Children }}
<li><a href="{{ .URL }}">{{ .Pre }}{{ .Name }}{{ .Post }}</a></li>
{{ end }}
</ul>
{{ else }}
<li><a href="{{ .URL }}">{{ .Pre }}<b>{{ $text := print .Name | safeHTML }}{{ $text }}{{ .Post }}</b></a></li>
{{ end }}
{{ end }}
</ul>
<button type="button" id="theme-toggle" class="theme-toggle" aria-label="Switch to dark theme" title="Switch to dark theme">
<svg class="theme-toggle-track-icon sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>
<svg class="theme-toggle-track-icon moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
<span class="theme-toggle-thumb">
<svg class="sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>
<svg class="moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
</span>
</button>
</div>
</div>
<script>
(function() {
var root = document.documentElement;
var button = document.getElementById("theme-toggle");
function update() {
var label = root.getAttribute("data-theme") === "dark" ? "Switch to light theme" : "Switch to dark theme";
button.setAttribute("aria-label", label);
button.setAttribute("title", label);
}
button.addEventListener("click", function() {
var theme = root.getAttribute("data-theme") === "dark" ? "light" : "dark";
root.setAttribute("data-theme", theme);
try {
localStorage.setItem("exectos-theme", theme);
} catch (e) {}
update();
});
update();
})();
</script>