Aggiunge i18n IT/EN/FR/DE/ES, pagine pubbliche squadre e UX archivio.
Il selettore lingua funziona sul web e sulle app native; su Android la preferenza è persistita e applicata al riavvio. Incluse anche eliminazione replay a scope e campi pagina pubblica squadra. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<%# Selettore lingua a bandiere (allineato a destra nel menu) %>
|
||||
<% current = current_language_option %>
|
||||
<div class="lang-switcher" data-lang-switcher>
|
||||
<button
|
||||
type="button"
|
||||
class="lang-switcher__toggle"
|
||||
id="lang-switcher-toggle"
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded="false"
|
||||
aria-controls="lang-switcher-menu"
|
||||
aria-label="<%= t('language.choose') %>: <%= current[:native] %>"
|
||||
title="<%= current[:native] %>"
|
||||
>
|
||||
<span class="lang-switcher__flag" aria-hidden="true"><%= current[:flag] %></span>
|
||||
<span class="lang-switcher__chevron" aria-hidden="true"></span>
|
||||
</button>
|
||||
|
||||
<div
|
||||
class="lang-switcher__menu"
|
||||
id="lang-switcher-menu"
|
||||
role="listbox"
|
||||
aria-label="<%= t('language.label') %>"
|
||||
hidden
|
||||
>
|
||||
<% language_options.each do |opt| %>
|
||||
<% selected = opt[:code].to_s == current_locale.to_s %>
|
||||
<%= button_to public_locale_path,
|
||||
method: :patch,
|
||||
params: { locale: opt[:code] },
|
||||
class: "lang-switcher__option#{' is-active' if selected}",
|
||||
form: { class: "lang-switcher__option-form" },
|
||||
role: "option",
|
||||
aria: { selected: selected, label: opt[:native] },
|
||||
title: opt[:native] do %>
|
||||
<span class="lang-switcher__flag" aria-hidden="true"><%= opt[:flag] %></span>
|
||||
<span class="visually-hidden"><%= opt[:native] %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var root = document.querySelector("[data-lang-switcher]");
|
||||
if (!root || root.dataset.bound === "1") return;
|
||||
root.dataset.bound = "1";
|
||||
|
||||
var toggle = root.querySelector(".lang-switcher__toggle");
|
||||
var menu = root.querySelector(".lang-switcher__menu");
|
||||
if (!toggle || !menu) return;
|
||||
|
||||
function setOpen(open) {
|
||||
menu.hidden = !open;
|
||||
toggle.setAttribute("aria-expanded", open ? "true" : "false");
|
||||
root.classList.toggle("is-open", open);
|
||||
}
|
||||
|
||||
toggle.addEventListener("click", function (e) {
|
||||
e.stopPropagation();
|
||||
setOpen(menu.hidden);
|
||||
});
|
||||
|
||||
document.addEventListener("click", function (e) {
|
||||
if (!root.contains(e.target)) setOpen(false);
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Escape") setOpen(false);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user