summaryrefslogtreecommitdiff
path: root/app/views/layouts/_nav_controls.html.erb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-27 00:46:00 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-27 00:46:00 +0200
commit500777d88f21bdce71a1053de3ad9f32c7c91029 (patch)
tree02deff98b9e73cab1f2897e456bd145914b5c0f1 /app/views/layouts/_nav_controls.html.erb
parent174ecd3115438ebd4049e1e5ea40e210a7e49509 (diff)
Consolidate all main nav items in a single partial
Diffstat (limited to 'app/views/layouts/_nav_controls.html.erb')
-rw-r--r--app/views/layouts/_nav_controls.html.erb36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/views/layouts/_nav_controls.html.erb b/app/views/layouts/_nav_controls.html.erb
new file mode 100644
index 00000000..d6053dab
--- /dev/null
+++ b/app/views/layouts/_nav_controls.html.erb
@@ -0,0 +1,36 @@
1<% if current_user %>
2 <%= link_to icon("home", library: "tabler", "aria-hidden": true), admin_path, "aria-label": t(".dashboard"), title: t(".dashboard") %>
3 <a href="#" onclick="admin_search.display_toggle(); return false;" aria-label="<%= t(".search") %>" title="<%= t(".search") %>"><%= icon("search", library: "tabler", "aria-hidden": true) %></a>
4<% end %>
5
6<span class="nav_group">
7 <%= link_to url_for(locale: (:en unless I18n.locale == :en)),
8 class: "nav_toggle nav_locale",
9 "aria-label" => t(".switch_locale"), title: t(".switch_locale") do %>
10 <%= I18n.locale == :en ? "DE" : "EN" %>
11 <% end %>
12 <%= check_box_tag "scheme_override", 1, false, class: "nav_toggle_input" %>
13 <%= label_tag "scheme_override", class: "nav_toggle",
14 "aria-label" => t(".scheme_override"), title: t(".scheme_override") do %>
15 <%= icon("contrast", library: "tabler", "aria-hidden": true) %>
16 <% end %>
17</span>
18
19<%= javascript_tag nonce: true do %>
20 (function () {
21 var box = document.getElementById("scheme_override");
22 try {
23 if (localStorage.getItem("override-prefers-color-scheme")) box.checked = true;
24 box.addEventListener("change", function () {
25 if (box.checked) localStorage.setItem("override-prefers-color-scheme", 1);
26 else localStorage.removeItem("override-prefers-color-scheme");
27 });
28 } catch (e) { /* storage unavailable: the toggle still works per page */ }
29 })();
30<% end %>
31
32<% if current_user %>
33 <%= button_to logout_path, method: :delete, aria: { label: t(".log_out") }, title: t(".log_out") do %>
34 <%= icon("logout", library: "tabler", "aria-hidden": true) %>
35 <% end %>
36<% end %>