From 500777d88f21bdce71a1053de3ad9f32c7c91029 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 27 Jul 2026 00:46:00 +0200 Subject: Consolidate all main nav items in a single partial --- app/views/layouts/_nav_controls.html.erb | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/views/layouts/_nav_controls.html.erb (limited to 'app/views/layouts/_nav_controls.html.erb') 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 @@ +<% if current_user %> + <%= link_to icon("home", library: "tabler", "aria-hidden": true), admin_path, "aria-label": t(".dashboard"), title: t(".dashboard") %> + " title="<%= t(".search") %>"><%= icon("search", library: "tabler", "aria-hidden": true) %> +<% end %> + + + <%= link_to url_for(locale: (:en unless I18n.locale == :en)), + class: "nav_toggle nav_locale", + "aria-label" => t(".switch_locale"), title: t(".switch_locale") do %> + <%= I18n.locale == :en ? "DE" : "EN" %> + <% end %> + <%= check_box_tag "scheme_override", 1, false, class: "nav_toggle_input" %> + <%= label_tag "scheme_override", class: "nav_toggle", + "aria-label" => t(".scheme_override"), title: t(".scheme_override") do %> + <%= icon("contrast", library: "tabler", "aria-hidden": true) %> + <% end %> + + +<%= javascript_tag nonce: true do %> + (function () { + var box = document.getElementById("scheme_override"); + try { + if (localStorage.getItem("override-prefers-color-scheme")) box.checked = true; + box.addEventListener("change", function () { + if (box.checked) localStorage.setItem("override-prefers-color-scheme", 1); + else localStorage.removeItem("override-prefers-color-scheme"); + }); + } catch (e) { /* storage unavailable: the toggle still works per page */ } + })(); +<% end %> + +<% if current_user %> + <%= button_to logout_path, method: :delete, aria: { label: t(".log_out") }, title: t(".log_out") do %> + <%= icon("logout", library: "tabler", "aria-hidden": true) %> + <% end %> +<% end %> -- cgit v1.3